@ -1,6 +1,7 @@
using Microsoft.Extensions.Configuration ;
using Microsoft.Extensions.Configuration ;
using OpenIddict.Abstractions ;
using OpenIddict.Abstractions ;
using System ;
using System ;
using System.Collections.Generic ;
using System.Globalization ;
using System.Globalization ;
using System.Threading.Tasks ;
using System.Threading.Tasks ;
using Volo.Abp.Authorization.Permissions ;
using Volo.Abp.Authorization.Permissions ;
@ -94,18 +95,18 @@ public class ClientDataSeederContributor : IDataSeedContributor, ITransientDepen
await _ applicationManager . CreateAsync ( new OpenIddictApplicationDescriptor
await _ applicationManager . CreateAsync ( new OpenIddictApplicationDescriptor
{
{
ClientId = vueClientId ,
ClientId = vueClientId ,
ClientSecret = "1q2w3e*" ,
ClientSecret = configurationSection [ "VueAdmin:ClientSecret" ] ,
ApplicationType = OpenIddictConstants . ApplicationTypes . Web ,
ApplicationType = OpenIddictConstants . ApplicationTypes . Web ,
ConsentType = OpenIddictConstants . ConsentTypes . Explicit ,
ConsentType = OpenIddictConstants . ConsentTypes . Explicit ,
DisplayName = "Abp Vue Admin Client" ,
DisplayName = "Abp Vue Admin Client" ,
PostLogoutRedirectUris =
PostLogoutRedirectUris =
{
{
new Uri ( vueClientRootUrl + "signout-callback-oidc " ) ,
new Uri ( vueClientRootUrl + "signout-callback" ) ,
new Uri ( vueClientRootUrl )
new Uri ( vueClientRootUrl )
} ,
} ,
RedirectUris =
RedirectUris =
{
{
new Uri ( vueClientRootUrl + "/signin-oidc " ) ,
new Uri ( vueClientRootUrl + "signin-callback " ) ,
new Uri ( vueClientRootUrl )
new Uri ( vueClientRootUrl )
} ,
} ,
Permissions =
Permissions =
@ -158,7 +159,7 @@ public class ClientDataSeederContributor : IDataSeedContributor, ITransientDepen
await _ applicationManager . CreateAsync ( new OpenIddictApplicationDescriptor
await _ applicationManager . CreateAsync ( new OpenIddictApplicationDescriptor
{
{
ClientId = internalServiceClientId ,
ClientId = internalServiceClientId ,
ClientSecret = "1q2w3e*" ,
ClientSecret = configurationSection [ "InternalService:ClientSecret" ] ,
ClientType = OpenIddictConstants . ClientTypes . Confidential ,
ClientType = OpenIddictConstants . ClientTypes . Confidential ,
ConsentType = OpenIddictConstants . ConsentTypes . Explicit ,
ConsentType = OpenIddictConstants . ConsentTypes . Explicit ,
ApplicationType = OpenIddictConstants . ApplicationTypes . Native ,
ApplicationType = OpenIddictConstants . ApplicationTypes . Native ,
@ -205,30 +206,22 @@ public class ClientDataSeederContributor : IDataSeedContributor, ITransientDepen
}
}
}
}
var oauthClientId = configurationSection [ "OAuthClient:ClientId" ] ;
var oauthClientId = configurationSection [ "Vue OAuthClient:ClientId" ] ;
if ( ! oauthClientId . IsNullOrWhiteSpace ( ) )
if ( ! oauthClientId . IsNullOrWhiteSpace ( ) )
{
{
var oauthClientRootUrl = configurationSection [ "OAuthClient:RootUrl" ] . EnsureEndsWith ( '/' ) ;
var oauthClientRootUrls = configurationSection . GetSection ( "VueOAuthClient:RootUrls" ) . Get < List < string > > ( ) ;
if ( await _ applicationRepository . FindByClientIdAsync ( oauthClientId ) = = null )
if ( await _ applicationRepository . FindByClientIdAsync ( oauthClientId ) = = null )
{
{
await _ applicationManager . CreateAsync ( new OpenIddictApplicationDescriptor
var application = new OpenIddictApplicationDescriptor
{
{
ClientId = oauthClientId ,
ClientId = oauthClientId ,
ClientSecret = null ,
ClientSecret = null ,
ApplicationType = OpenIddictConstants . ApplicationTypes . Web ,
ApplicationType = OpenIddictConstants . ApplicationTypes . Web ,
ConsentType = OpenIddictConstants . ConsentTypes . Implicit ,
ConsentType = OpenIddictConstants . ConsentTypes . Implicit ,
DisplayName = "OAuth Client" ,
DisplayName = "OAuth Client" ,
PostLogoutRedirectUris =
PostLogoutRedirectUris = { } ,
{
RedirectUris = { } ,
new Uri ( oauthClientRootUrl + "signout-callback" ) ,
new Uri ( oauthClientRootUrl )
} ,
RedirectUris =
{
new Uri ( oauthClientRootUrl + "/signin-callback" ) ,
new Uri ( oauthClientRootUrl )
} ,
Permissions =
Permissions =
{
{
OpenIddictConstants . Permissions . Endpoints . Authorization ,
OpenIddictConstants . Permissions . Endpoints . Authorization ,
@ -257,8 +250,20 @@ public class ClientDataSeederContributor : IDataSeedContributor, ITransientDepen
OpenIddictConstants . Permissions . Scopes . Phone ,
OpenIddictConstants . Permissions . Scopes . Phone ,
OpenIddictConstants . Permissions . Prefixes . Scope + scope
OpenIddictConstants . Permissions . Prefixes . Scope + scope
}
}
} ;
oauthClientRootUrls . ForEach ( url = >
{
application . PostLogoutRedirectUris . AddIfNotContains ( new Uri ( url . EnsureEndsWith ( '/' ) ) ) ;
application . PostLogoutRedirectUris . AddIfNotContains ( new Uri ( url . EnsureEndsWith ( '/' ) + "signout-callback" ) ) ;
application . RedirectUris . AddIfNotContains ( new Uri ( url ) ) ;
application . RedirectUris . AddIfNotContains ( new Uri ( url . EnsureEndsWith ( '/' ) + "signin-callback" ) ) ;
application . RedirectUris . AddIfNotContains ( new Uri ( url . EnsureEndsWith ( '/' ) + "swagger/oauth2-redirect.html" ) ) ;
} ) ;
} ) ;
await _ applicationManager . CreateAsync ( application ) ;
var oauthClientPermissions = new string [ 1 ]
var oauthClientPermissions = new string [ 1 ]
{
{
"AbpIdentity.UserLookup"
"AbpIdentity.UserLookup"