From 346db9bd3629056c9456cc5e01f8acd83cd55a30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Mon, 19 Oct 2020 14:49:46 +0300 Subject: [PATCH 1/2] Update IdentityServerDataSeedContributor.cs --- .../IdentityServerDataSeedContributor.cs | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) 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 dbb6c639df..0b81a8106e 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 @@ -52,10 +52,15 @@ namespace MyCompanyName.MyProjectName.IdentityServer { await _identityResourceDataSeeder.CreateStandardResourcesAsync(); await CreateApiResourcesAsync(); - await CreateApiScopeAsync(); + await CreateApiScopesAsync(); await CreateClientsAsync(); } + private async Task CreateApiScopesAsync() + { + await CreateApiScopeAsync("MyProjectName"); + } + private async Task CreateApiResourcesAsync() { var commonApiUserClaims = new[] @@ -97,13 +102,22 @@ namespace MyCompanyName.MyProjectName.IdentityServer return await _apiResourceRepository.UpdateAsync(apiResource); } - private async Task CreateApiScopeAsync() + private async Task CreateApiScopeAsync(string name) { - var apiScope = await _apiScopeRepository.GetByNameAsync("MyProjectName"); + var apiScope = await _apiScopeRepository.GetByNameAsync(name); if (apiScope == null) { - await _apiScopeRepository.InsertAsync(new ApiScope(_guidGenerator.Create(), "MyProjectName", "MyProjectName API"), autoSave: true); + apiScope = await _apiScopeRepository.InsertAsync( + new ApiScope( + _guidGenerator.Create(), + name, + name + " API" + ), + autoSave: true + ); } + + return apiScope; } private async Task CreateClientsAsync() From ec721067da1a30dd432d6ff843eb8297dcacf78c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Mon, 19 Oct 2020 14:51:23 +0300 Subject: [PATCH 2/2] Update IdentityServerDataSeedContributor.cs --- .../IdentityServerDataSeedContributor.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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 0b81a8106e..ebb027fa86 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 @@ -7,8 +7,8 @@ using Volo.Abp.Authorization.Permissions; using Volo.Abp.Data; using Volo.Abp.DependencyInjection; using Volo.Abp.Guids; -using Volo.Abp.IdentityServer.ApiScopes; using Volo.Abp.IdentityServer.ApiResources; +using Volo.Abp.IdentityServer.ApiScopes; using Volo.Abp.IdentityServer.Clients; using Volo.Abp.IdentityServer.IdentityResources; using Volo.Abp.PermissionManagement; @@ -130,7 +130,6 @@ namespace MyCompanyName.MyProjectName.IdentityServer "role", "phone", "address", - "MyProjectName" }; @@ -148,7 +147,7 @@ namespace MyCompanyName.MyProjectName.IdentityServer await CreateClientAsync( name: webClientId, scopes: commonScopes, - grantTypes: new[] {"hybrid"}, + grantTypes: new[] { "hybrid" }, secret: (configurationSection["MyProjectName_Web:ClientSecret"] ?? "1q2w3e*").Sha256(), redirectUri: $"{webClientRootUrl}signin-oidc", postLogoutRedirectUri: $"{webClientRootUrl}signout-callback-oidc", @@ -165,7 +164,7 @@ namespace MyCompanyName.MyProjectName.IdentityServer await CreateClientAsync( name: consoleAndAngularClientId, scopes: commonScopes, - grantTypes: new[] {"password", "client_credentials", "authorization_code"}, + grantTypes: new[] { "password", "client_credentials", "authorization_code" }, secret: (configurationSection["MyProjectName_App:ClientSecret"] ?? "1q2w3e*").Sha256(), requireClientSecret: false, redirectUri: webClientRootUrl, @@ -185,7 +184,6 @@ namespace MyCompanyName.MyProjectName.IdentityServer grantTypes: new[] { "authorization_code" }, secret: configurationSection["MyProjectName_Blazor:ClientSecret"]?.Sha256(), requireClientSecret: false, - requirePkce: true, redirectUri: $"{blazorRootUrl}/authentication/login-callback", postLogoutRedirectUri: $"{blazorRootUrl}/authentication/logout-callback" ); @@ -283,4 +281,4 @@ namespace MyCompanyName.MyProjectName.IdentityServer return await _clientRepository.UpdateAsync(client); } } -} +} \ No newline at end of file