diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/appsettings.json b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/appsettings.json index d45a2093e7..17ce15c462 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/appsettings.json +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/appsettings.json @@ -11,7 +11,8 @@ }, "MyProjectName_App": { "ClientId": "MyProjectName_App", - "ClientSecret": "1q2w3e*" + "ClientSecret": "1q2w3e*", + "RootUrl": "http://localhost:4200" } } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/IdentityServer/IdentityServerDataSeedContributor.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/IdentityServer/IdentityServerDataSeedContributor.cs index 2bce06c77d..805bc0e424 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/IdentityServer/IdentityServerDataSeedContributor.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/IdentityServer/IdentityServerDataSeedContributor.cs @@ -126,15 +126,20 @@ namespace MyCompanyName.MyProjectName.IdentityServer ); } - //Console Test Client - var consoleClientId = configurationSection["MyProjectName_App:ClientId"]; - if (!consoleClientId.IsNullOrWhiteSpace()) + //Console Test / Angular Client + var consoleAndAngularClientId = configurationSection["MyProjectName_App:ClientId"]; + if (!consoleAndAngularClientId.IsNullOrWhiteSpace()) { + var webClientRootUrl = configurationSection["MyProjectName_App:RootUrl"]?.TrimEnd('/'); + await CreateClientAsync( - name: consoleClientId, + name: consoleAndAngularClientId, scopes: commonScopes, - grantTypes: new[] {"password", "client_credentials"}, - secret: (configurationSection["MyProjectName_App:ClientSecret"] ?? "1q2w3e*").Sha256() + grantTypes: new[] {"password", "client_credentials", "authorization_code"}, + secret: (configurationSection["MyProjectName_App:ClientSecret"] ?? "1q2w3e*").Sha256(), + requireClientSecret: false, + redirectUri: webClientRootUrl, + postLogoutRedirectUri: webClientRootUrl ); } } @@ -147,6 +152,8 @@ namespace MyCompanyName.MyProjectName.IdentityServer string redirectUri = null, string postLogoutRedirectUri = null, string frontChannelLogoutUri = null, + bool requireClientSecret = true, + bool requirePkce = false, IEnumerable permissions = null) { var client = await _clientRepository.FindByCliendIdAsync(name); @@ -168,7 +175,9 @@ namespace MyCompanyName.MyProjectName.IdentityServer AuthorizationCodeLifetime = 300, IdentityTokenLifetime = 300, RequireConsent = false, - FrontChannelLogoutUri = frontChannelLogoutUri + FrontChannelLogoutUri = frontChannelLogoutUri, + RequireClientSecret = requireClientSecret, + RequirePkce = requirePkce }, autoSave: true );