Browse Source

Add authorization code grant to the App client (the angular client).

pull/5048/head
Halil İbrahim Kalkan 6 years ago
parent
commit
483210edb2
  1. 3
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/appsettings.json
  2. 23
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/IdentityServer/IdentityServerDataSeedContributor.cs

3
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"
}
}
}

23
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<string> 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
);

Loading…
Cancel
Save