mirror of https://github.com/abpframework/abp.git
committed by
GitHub
131 changed files with 8534 additions and 12392 deletions
@ -1,39 +0,0 @@ |
|||
using System; |
|||
using Microsoft.AspNetCore.Mvc.Abstractions; |
|||
using Microsoft.AspNetCore.Mvc.ActionConstraints; |
|||
using Microsoft.AspNetCore.Routing; |
|||
|
|||
namespace Volo.Abp.OpenIddict; |
|||
|
|||
public class AbpFormValueRequiredAttribute : ActionMethodSelectorAttribute |
|||
{ |
|||
private readonly string _name; |
|||
|
|||
public AbpFormValueRequiredAttribute(string name) |
|||
{ |
|||
_name = name; |
|||
} |
|||
|
|||
public override bool IsValidForRequest(RouteContext routeContext, ActionDescriptor action) |
|||
{ |
|||
if (string.Equals(routeContext.HttpContext.Request.Method, "GET", StringComparison.OrdinalIgnoreCase) || |
|||
string.Equals(routeContext.HttpContext.Request.Method, "HEAD", StringComparison.OrdinalIgnoreCase) || |
|||
string.Equals(routeContext.HttpContext.Request.Method, "DELETE", StringComparison.OrdinalIgnoreCase) || |
|||
string.Equals(routeContext.HttpContext.Request.Method, "TRACE", StringComparison.OrdinalIgnoreCase)) |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
if (string.IsNullOrEmpty(routeContext.HttpContext.Request.ContentType)) |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
if (!routeContext.HttpContext.Request.ContentType.StartsWith("application/x-www-form-urlencoded", StringComparison.OrdinalIgnoreCase)) |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
return !string.IsNullOrEmpty(routeContext.HttpContext.Request.Form[_name]); |
|||
} |
|||
} |
|||
File diff suppressed because it is too large
File diff suppressed because it is too large
@ -1,271 +0,0 @@ |
|||
using IdentityServer4.Models; |
|||
using Volo.Abp.Authorization.Permissions; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Guids; |
|||
using Volo.Abp.IdentityServer.ApiResources; |
|||
using Volo.Abp.IdentityServer.ApiScopes; |
|||
using Volo.Abp.IdentityServer.Clients; |
|||
using Volo.Abp.IdentityServer.IdentityResources; |
|||
using Volo.Abp.MultiTenancy; |
|||
using Volo.Abp.PermissionManagement; |
|||
using Volo.Abp.Uow; |
|||
using ApiResource = Volo.Abp.IdentityServer.ApiResources.ApiResource; |
|||
using ApiScope = Volo.Abp.IdentityServer.ApiScopes.ApiScope; |
|||
using Client = Volo.Abp.IdentityServer.Clients.Client; |
|||
|
|||
namespace MyCompanyName.MyProjectName.Data; |
|||
|
|||
public class IdentityServerDataSeedContributor : IDataSeedContributor, ITransientDependency |
|||
{ |
|||
private readonly IApiResourceRepository _apiResourceRepository; |
|||
private readonly IApiScopeRepository _apiScopeRepository; |
|||
private readonly IClientRepository _clientRepository; |
|||
private readonly IIdentityResourceDataSeeder _identityResourceDataSeeder; |
|||
private readonly IGuidGenerator _guidGenerator; |
|||
private readonly IPermissionDataSeeder _permissionDataSeeder; |
|||
private readonly IConfiguration _configuration; |
|||
private readonly ICurrentTenant _currentTenant; |
|||
|
|||
public IdentityServerDataSeedContributor( |
|||
IClientRepository clientRepository, |
|||
IApiResourceRepository apiResourceRepository, |
|||
IApiScopeRepository apiScopeRepository, |
|||
IIdentityResourceDataSeeder identityResourceDataSeeder, |
|||
IGuidGenerator guidGenerator, |
|||
IPermissionDataSeeder permissionDataSeeder, |
|||
IConfiguration configuration, |
|||
ICurrentTenant currentTenant) |
|||
{ |
|||
_clientRepository = clientRepository; |
|||
_apiResourceRepository = apiResourceRepository; |
|||
_apiScopeRepository = apiScopeRepository; |
|||
_identityResourceDataSeeder = identityResourceDataSeeder; |
|||
_guidGenerator = guidGenerator; |
|||
_permissionDataSeeder = permissionDataSeeder; |
|||
_configuration = configuration; |
|||
_currentTenant = currentTenant; |
|||
} |
|||
|
|||
[UnitOfWork] |
|||
public virtual async Task SeedAsync(DataSeedContext context) |
|||
{ |
|||
using (_currentTenant.Change(context?.TenantId)) |
|||
{ |
|||
await _identityResourceDataSeeder.CreateStandardResourcesAsync(); |
|||
await CreateApiResourcesAsync(); |
|||
await CreateApiScopesAsync(); |
|||
await CreateClientsAsync(); |
|||
} |
|||
} |
|||
|
|||
private async Task CreateApiScopesAsync() |
|||
{ |
|||
await CreateApiScopeAsync("MyProjectName"); |
|||
} |
|||
|
|||
private async Task CreateApiResourcesAsync() |
|||
{ |
|||
var commonApiUserClaims = new[] {"email", "email_verified", "name", "phone_number", "phone_number_verified", "role"}; |
|||
await CreateApiResourceAsync("MyProjectName", commonApiUserClaims); |
|||
} |
|||
|
|||
private async Task<ApiResource> CreateApiResourceAsync(string name, IEnumerable<string> claims) |
|||
{ |
|||
var apiResource = await _apiResourceRepository.FindByNameAsync(name); |
|||
if (apiResource == null) |
|||
{ |
|||
apiResource = await _apiResourceRepository.InsertAsync( |
|||
new ApiResource( |
|||
_guidGenerator.Create(), |
|||
name, |
|||
name + " API" |
|||
), |
|||
autoSave: true |
|||
); |
|||
} |
|||
|
|||
foreach (var claim in claims) |
|||
{ |
|||
if (apiResource.FindClaim(claim) == null) |
|||
{ |
|||
apiResource.AddUserClaim(claim); |
|||
} |
|||
} |
|||
|
|||
return await _apiResourceRepository.UpdateAsync(apiResource); |
|||
} |
|||
|
|||
private async Task<ApiScope> CreateApiScopeAsync(string name) |
|||
{ |
|||
var apiScope = await _apiScopeRepository.FindByNameAsync(name); |
|||
if (apiScope == null) |
|||
{ |
|||
apiScope = await _apiScopeRepository.InsertAsync( |
|||
new ApiScope( |
|||
_guidGenerator.Create(), |
|||
name, |
|||
name + " API" |
|||
), |
|||
autoSave: true |
|||
); |
|||
} |
|||
|
|||
return apiScope; |
|||
} |
|||
|
|||
private async Task CreateClientsAsync() |
|||
{ |
|||
var commonScopes = new[] |
|||
{ |
|||
"email", |
|||
"openid", |
|||
"profile", |
|||
"role", |
|||
"phone", |
|||
"address", |
|||
"MyProjectName" |
|||
}; |
|||
|
|||
var configurationSection = _configuration.GetSection("IdentityServer:Clients"); |
|||
|
|||
// Angular Client
|
|||
var consoleAndAngularClientId = configurationSection["MyProjectName_App:ClientId"]; |
|||
if (!consoleAndAngularClientId.IsNullOrWhiteSpace()) |
|||
{ |
|||
var webClientRootUrl = configurationSection["MyProjectName_App:RootUrl"]?.TrimEnd('/'); |
|||
|
|||
await CreateClientAsync( |
|||
name: consoleAndAngularClientId, |
|||
scopes: commonScopes, |
|||
grantTypes: new[] { "password", "client_credentials", "authorization_code" }, |
|||
secret: (configurationSection["MyProjectName_App:ClientSecret"] ?? "1q2w3e*").Sha256(), |
|||
requireClientSecret: false, |
|||
redirectUri: webClientRootUrl, |
|||
postLogoutRedirectUri: webClientRootUrl, |
|||
corsOrigins: new[] { webClientRootUrl.RemovePostFix("/") } |
|||
); |
|||
} |
|||
|
|||
// Swagger Client
|
|||
var swaggerClientId = configurationSection["MyProjectName_Swagger:ClientId"]; |
|||
if (!swaggerClientId.IsNullOrWhiteSpace()) |
|||
{ |
|||
var swaggerRootUrl = configurationSection["MyProjectName_Swagger:RootUrl"].TrimEnd('/'); |
|||
|
|||
await CreateClientAsync( |
|||
name: swaggerClientId, |
|||
scopes: commonScopes, |
|||
grantTypes: new[] { "authorization_code" }, |
|||
secret: configurationSection["MyProjectName_Swagger:ClientSecret"]?.Sha256(), |
|||
requireClientSecret: false, |
|||
redirectUri: $"{swaggerRootUrl}/swagger/oauth2-redirect.html", |
|||
corsOrigins: new[] { swaggerRootUrl.RemovePostFix("/") } |
|||
); |
|||
} |
|||
} |
|||
|
|||
private async Task<Client> CreateClientAsync( |
|||
string name, |
|||
IEnumerable<string> scopes, |
|||
IEnumerable<string> grantTypes, |
|||
string secret = null, |
|||
string redirectUri = null, |
|||
string postLogoutRedirectUri = null, |
|||
string frontChannelLogoutUri = null, |
|||
bool requireClientSecret = true, |
|||
bool requirePkce = false, |
|||
IEnumerable<string> permissions = null, |
|||
IEnumerable<string> corsOrigins = null) |
|||
{ |
|||
var client = await _clientRepository.FindByClientIdAsync(name); |
|||
if (client == null) |
|||
{ |
|||
client = await _clientRepository.InsertAsync( |
|||
new Client( |
|||
_guidGenerator.Create(), |
|||
name |
|||
) |
|||
{ |
|||
ClientName = name, |
|||
ProtocolType = "oidc", |
|||
Description = name, |
|||
AlwaysIncludeUserClaimsInIdToken = true, |
|||
AllowOfflineAccess = true, |
|||
AbsoluteRefreshTokenLifetime = 31536000, //365 days
|
|||
AccessTokenLifetime = 31536000, //365 days
|
|||
AuthorizationCodeLifetime = 300, |
|||
IdentityTokenLifetime = 300, |
|||
RequireConsent = false, |
|||
FrontChannelLogoutUri = frontChannelLogoutUri, |
|||
RequireClientSecret = requireClientSecret, |
|||
RequirePkce = requirePkce |
|||
}, |
|||
autoSave: true |
|||
); |
|||
} |
|||
|
|||
foreach (var scope in scopes) |
|||
{ |
|||
if (client.FindScope(scope) == null) |
|||
{ |
|||
client.AddScope(scope); |
|||
} |
|||
} |
|||
|
|||
foreach (var grantType in grantTypes) |
|||
{ |
|||
if (client.FindGrantType(grantType) == null) |
|||
{ |
|||
client.AddGrantType(grantType); |
|||
} |
|||
} |
|||
|
|||
if (!secret.IsNullOrEmpty()) |
|||
{ |
|||
if (client.FindSecret(secret) == null) |
|||
{ |
|||
client.AddSecret(secret); |
|||
} |
|||
} |
|||
|
|||
if (redirectUri != null) |
|||
{ |
|||
if (client.FindRedirectUri(redirectUri) == null) |
|||
{ |
|||
client.AddRedirectUri(redirectUri); |
|||
} |
|||
} |
|||
|
|||
if (postLogoutRedirectUri != null) |
|||
{ |
|||
if (client.FindPostLogoutRedirectUri(postLogoutRedirectUri) == null) |
|||
{ |
|||
client.AddPostLogoutRedirectUri(postLogoutRedirectUri); |
|||
} |
|||
} |
|||
|
|||
if (permissions != null) |
|||
{ |
|||
await _permissionDataSeeder.SeedAsync( |
|||
ClientPermissionValueProvider.ProviderName, |
|||
name, |
|||
permissions, |
|||
null |
|||
); |
|||
} |
|||
|
|||
if (corsOrigins != null) |
|||
{ |
|||
foreach (var origin in corsOrigins) |
|||
{ |
|||
if (!origin.IsNullOrWhiteSpace() && client.FindCorsOrigin(origin) == null) |
|||
{ |
|||
client.AddCorsOrigin(origin); |
|||
} |
|||
} |
|||
} |
|||
|
|||
return await _clientRepository.UpdateAsync(client); |
|||
} |
|||
} |
|||
@ -0,0 +1,299 @@ |
|||
using JetBrains.Annotations; |
|||
using Microsoft.Extensions.Localization; |
|||
using OpenIddict.Abstractions; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Authorization.Permissions; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.PermissionManagement; |
|||
using Volo.Abp.Uow; |
|||
|
|||
namespace MyCompanyName.MyProjectName.Data; |
|||
|
|||
/* Creates initial data that is needed to property run the application |
|||
* and make client-to-server communication possible. |
|||
*/ |
|||
public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDependency |
|||
{ |
|||
private readonly IConfiguration _configuration; |
|||
private readonly IOpenIddictApplicationManager _applicationManager; |
|||
private readonly IOpenIddictScopeManager _scopeManager; |
|||
private readonly IPermissionDataSeeder _permissionDataSeeder; |
|||
private readonly IStringLocalizer<OpenIddictResponse> L; |
|||
|
|||
public OpenIddictDataSeedContributor( |
|||
IConfiguration configuration, |
|||
IOpenIddictApplicationManager applicationManager, |
|||
IOpenIddictScopeManager scopeManager, |
|||
IPermissionDataSeeder permissionDataSeeder, |
|||
IStringLocalizer<OpenIddictResponse> l) |
|||
{ |
|||
_configuration = configuration; |
|||
_applicationManager = applicationManager; |
|||
_scopeManager = scopeManager; |
|||
_permissionDataSeeder = permissionDataSeeder; |
|||
L = l; |
|||
} |
|||
|
|||
[UnitOfWork] |
|||
public virtual async Task SeedAsync(DataSeedContext context) |
|||
{ |
|||
await CreateScopesAsync(); |
|||
await CreateApplicationsAsync(); |
|||
} |
|||
|
|||
private async Task CreateScopesAsync() |
|||
{ |
|||
if (await _scopeManager.FindByNameAsync("MyProjectName") == null) |
|||
{ |
|||
await _scopeManager.CreateAsync(new OpenIddictScopeDescriptor |
|||
{ |
|||
Name = "MyProjectName", |
|||
DisplayName = "MyProjectName API", |
|||
Resources = |
|||
{ |
|||
"MyProjectName" |
|||
} |
|||
}); |
|||
} |
|||
} |
|||
|
|||
private async Task CreateApplicationsAsync() |
|||
{ |
|||
var commonScopes = new List<string> |
|||
{ |
|||
OpenIddictConstants.Permissions.Scopes.Address, |
|||
OpenIddictConstants.Permissions.Scopes.Email, |
|||
OpenIddictConstants.Permissions.Scopes.Phone, |
|||
OpenIddictConstants.Permissions.Scopes.Profile, |
|||
OpenIddictConstants.Permissions.Scopes.Roles, |
|||
"MyProjectName" |
|||
}; |
|||
|
|||
var configurationSection = _configuration.GetSection("OpenIddict:Applications"); |
|||
|
|||
//Console Test / Angular Client
|
|||
var consoleAndAngularClientId = configurationSection["MyProjectName_App:ClientId"]; |
|||
if (!consoleAndAngularClientId.IsNullOrWhiteSpace()) |
|||
{ |
|||
var webClientRootUrl = configurationSection["MyProjectName_App:RootUrl"]?.TrimEnd('/'); |
|||
await CreateApplicationAsync( |
|||
name: consoleAndAngularClientId, |
|||
type: OpenIddictConstants.ClientTypes.Public, |
|||
consentType: OpenIddictConstants.ConsentTypes.Implicit, |
|||
displayName: "Console Test / Angular Application", |
|||
secret: null, |
|||
grantTypes: new List<string> |
|||
{ |
|||
OpenIddictConstants.GrantTypes.AuthorizationCode, |
|||
OpenIddictConstants.GrantTypes.Password, |
|||
OpenIddictConstants.GrantTypes.ClientCredentials, |
|||
OpenIddictConstants.GrantTypes.RefreshToken |
|||
}, |
|||
scopes: commonScopes, |
|||
redirectUri: webClientRootUrl, |
|||
postLogoutRedirectUri: webClientRootUrl |
|||
); |
|||
} |
|||
|
|||
// Swagger Client
|
|||
var swaggerClientId = configurationSection["MyProjectName_Swagger:ClientId"]; |
|||
if (!swaggerClientId.IsNullOrWhiteSpace()) |
|||
{ |
|||
var swaggerRootUrl = configurationSection["MyProjectName_Swagger:RootUrl"].TrimEnd('/'); |
|||
|
|||
await CreateApplicationAsync( |
|||
name: swaggerClientId, |
|||
type: OpenIddictConstants.ClientTypes.Public, |
|||
consentType: OpenIddictConstants.ConsentTypes.Implicit, |
|||
displayName: "Swagger Application", |
|||
secret: null, |
|||
grantTypes: new List<string> |
|||
{ |
|||
OpenIddictConstants.GrantTypes.AuthorizationCode, |
|||
}, |
|||
scopes: commonScopes, |
|||
redirectUri: $"{swaggerRootUrl}/swagger/oauth2-redirect.html" |
|||
); |
|||
} |
|||
} |
|||
|
|||
private async Task CreateApplicationAsync( |
|||
[NotNull] string name, |
|||
[NotNull] string type, |
|||
[NotNull] string consentType, |
|||
string displayName, |
|||
string secret, |
|||
List<string> grantTypes, |
|||
List<string> scopes, |
|||
string redirectUri = null, |
|||
string postLogoutRedirectUri = null, |
|||
List<string> permissions = null) |
|||
{ |
|||
if (!string.IsNullOrEmpty(secret) && string.Equals(type, OpenIddictConstants.ClientTypes.Public, StringComparison.OrdinalIgnoreCase)) |
|||
{ |
|||
throw new BusinessException(L["NoClientSecretCanBeSetForPublicApplications"]); |
|||
} |
|||
|
|||
if (string.IsNullOrEmpty(secret) && string.Equals(type, OpenIddictConstants.ClientTypes.Confidential, StringComparison.OrdinalIgnoreCase)) |
|||
{ |
|||
throw new BusinessException(L["TheClientSecretIsRequiredForConfidentialApplications"]); |
|||
} |
|||
|
|||
if (!string.IsNullOrEmpty(name) && await _applicationManager.FindByClientIdAsync(name) != null) |
|||
{ |
|||
return; |
|||
//throw new BusinessException(L["TheClientIdentifierIsAlreadyTakenByAnotherApplication"]);
|
|||
} |
|||
|
|||
var client = await _applicationManager.FindByClientIdAsync(name); |
|||
if (client == null) |
|||
{ |
|||
var application = new OpenIddictApplicationDescriptor |
|||
{ |
|||
ClientId = name, |
|||
Type = type, |
|||
ClientSecret = secret, |
|||
ConsentType = consentType, |
|||
DisplayName = displayName |
|||
}; |
|||
|
|||
Check.NotNullOrEmpty(grantTypes, nameof(grantTypes)); |
|||
Check.NotNullOrEmpty(scopes, nameof(scopes)); |
|||
|
|||
if (new [] { OpenIddictConstants.GrantTypes.AuthorizationCode, OpenIddictConstants.GrantTypes.Implicit }.All(grantTypes.Contains)) |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.CodeIdToken); |
|||
|
|||
if (string.Equals(type, OpenIddictConstants.ClientTypes.Public, StringComparison.OrdinalIgnoreCase)) |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.CodeIdTokenToken); |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.CodeToken); |
|||
} |
|||
} |
|||
|
|||
if (!redirectUri.IsNullOrWhiteSpace() || !postLogoutRedirectUri.IsNullOrWhiteSpace()) |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Logout); |
|||
} |
|||
|
|||
foreach (var grantType in grantTypes) |
|||
{ |
|||
if (grantType == OpenIddictConstants.GrantTypes.AuthorizationCode) |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.AuthorizationCode); |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.Code); |
|||
} |
|||
|
|||
if (grantType == OpenIddictConstants.GrantTypes.AuthorizationCode || grantType == OpenIddictConstants.GrantTypes.Implicit) |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Authorization); |
|||
} |
|||
|
|||
if (grantType == OpenIddictConstants.GrantTypes.AuthorizationCode || |
|||
grantType == OpenIddictConstants.GrantTypes.ClientCredentials || |
|||
grantType == OpenIddictConstants.GrantTypes.Password || |
|||
grantType == OpenIddictConstants.GrantTypes.RefreshToken || |
|||
grantType == OpenIddictConstants.GrantTypes.DeviceCode) |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Token); |
|||
} |
|||
|
|||
if (grantType == OpenIddictConstants.GrantTypes.ClientCredentials) |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.ClientCredentials); |
|||
} |
|||
|
|||
if (grantType == OpenIddictConstants.GrantTypes.Implicit) |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.Implicit); |
|||
} |
|||
|
|||
if (grantType == OpenIddictConstants.GrantTypes.Password) |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.Password); |
|||
} |
|||
|
|||
if (grantType == OpenIddictConstants.GrantTypes.RefreshToken) |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.RefreshToken); |
|||
} |
|||
|
|||
if (grantType == OpenIddictConstants.GrantTypes.Implicit) |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.IdToken); |
|||
if (string.Equals(type, OpenIddictConstants.ClientTypes.Public, StringComparison.OrdinalIgnoreCase)) |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.IdTokenToken); |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.Token); |
|||
} |
|||
} |
|||
} |
|||
|
|||
var buildInScopes = new [] |
|||
{ |
|||
OpenIddictConstants.Permissions.Scopes.Address, |
|||
OpenIddictConstants.Permissions.Scopes.Email, |
|||
OpenIddictConstants.Permissions.Scopes.Phone, |
|||
OpenIddictConstants.Permissions.Scopes.Profile, |
|||
OpenIddictConstants.Permissions.Scopes.Roles |
|||
}; |
|||
|
|||
foreach (var scope in scopes) |
|||
{ |
|||
if (buildInScopes.Contains(scope)) |
|||
{ |
|||
application.Permissions.Add(scope); |
|||
} |
|||
else |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.Prefixes.Scope + scope); |
|||
} |
|||
} |
|||
|
|||
if (redirectUri != null) |
|||
{ |
|||
if (!redirectUri.IsNullOrEmpty()) |
|||
{ |
|||
if (!Uri.TryCreate(redirectUri, UriKind.Absolute, out var uri) || !uri.IsWellFormedOriginalString()) |
|||
{ |
|||
throw new BusinessException(L["InvalidRedirectUri", redirectUri]); |
|||
} |
|||
|
|||
if (application.RedirectUris.All(x => x != uri)) |
|||
{ |
|||
application.RedirectUris.Add(uri); |
|||
} |
|||
} |
|||
} |
|||
|
|||
if (postLogoutRedirectUri != null) |
|||
{ |
|||
if (!postLogoutRedirectUri.IsNullOrEmpty()) |
|||
{ |
|||
if (!Uri.TryCreate(postLogoutRedirectUri, UriKind.Absolute, out var uri) || !uri.IsWellFormedOriginalString()) |
|||
{ |
|||
throw new BusinessException(L["InvalidPostLogoutRedirectUri", postLogoutRedirectUri]); |
|||
} |
|||
|
|||
if (application.PostLogoutRedirectUris.All(x => x != uri)) |
|||
{ |
|||
application.PostLogoutRedirectUris.Add(uri); |
|||
} |
|||
} |
|||
} |
|||
|
|||
if (permissions != null) |
|||
{ |
|||
await _permissionDataSeeder.SeedAsync( |
|||
ClientPermissionValueProvider.ProviderName, |
|||
name, |
|||
permissions, |
|||
null |
|||
); |
|||
} |
|||
|
|||
await _applicationManager.CreateAsync(application); |
|||
} |
|||
} |
|||
} |
|||
@ -1,271 +0,0 @@ |
|||
using IdentityServer4.Models; |
|||
using Volo.Abp.Authorization.Permissions; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Guids; |
|||
using Volo.Abp.IdentityServer.ApiResources; |
|||
using Volo.Abp.IdentityServer.ApiScopes; |
|||
using Volo.Abp.IdentityServer.Clients; |
|||
using Volo.Abp.IdentityServer.IdentityResources; |
|||
using Volo.Abp.MultiTenancy; |
|||
using Volo.Abp.PermissionManagement; |
|||
using Volo.Abp.Uow; |
|||
using ApiResource = Volo.Abp.IdentityServer.ApiResources.ApiResource; |
|||
using ApiScope = Volo.Abp.IdentityServer.ApiScopes.ApiScope; |
|||
using Client = Volo.Abp.IdentityServer.Clients.Client; |
|||
|
|||
namespace MyCompanyName.MyProjectName.Data; |
|||
|
|||
public class IdentityServerDataSeedContributor : IDataSeedContributor, ITransientDependency |
|||
{ |
|||
private readonly IApiResourceRepository _apiResourceRepository; |
|||
private readonly IApiScopeRepository _apiScopeRepository; |
|||
private readonly IClientRepository _clientRepository; |
|||
private readonly IIdentityResourceDataSeeder _identityResourceDataSeeder; |
|||
private readonly IGuidGenerator _guidGenerator; |
|||
private readonly IPermissionDataSeeder _permissionDataSeeder; |
|||
private readonly IConfiguration _configuration; |
|||
private readonly ICurrentTenant _currentTenant; |
|||
|
|||
public IdentityServerDataSeedContributor( |
|||
IClientRepository clientRepository, |
|||
IApiResourceRepository apiResourceRepository, |
|||
IApiScopeRepository apiScopeRepository, |
|||
IIdentityResourceDataSeeder identityResourceDataSeeder, |
|||
IGuidGenerator guidGenerator, |
|||
IPermissionDataSeeder permissionDataSeeder, |
|||
IConfiguration configuration, |
|||
ICurrentTenant currentTenant) |
|||
{ |
|||
_clientRepository = clientRepository; |
|||
_apiResourceRepository = apiResourceRepository; |
|||
_apiScopeRepository = apiScopeRepository; |
|||
_identityResourceDataSeeder = identityResourceDataSeeder; |
|||
_guidGenerator = guidGenerator; |
|||
_permissionDataSeeder = permissionDataSeeder; |
|||
_configuration = configuration; |
|||
_currentTenant = currentTenant; |
|||
} |
|||
|
|||
[UnitOfWork] |
|||
public virtual async Task SeedAsync(DataSeedContext context) |
|||
{ |
|||
using (_currentTenant.Change(context?.TenantId)) |
|||
{ |
|||
await _identityResourceDataSeeder.CreateStandardResourcesAsync(); |
|||
await CreateApiResourcesAsync(); |
|||
await CreateApiScopesAsync(); |
|||
await CreateClientsAsync(); |
|||
} |
|||
} |
|||
|
|||
private async Task CreateApiScopesAsync() |
|||
{ |
|||
await CreateApiScopeAsync("MyProjectName"); |
|||
} |
|||
|
|||
private async Task CreateApiResourcesAsync() |
|||
{ |
|||
var commonApiUserClaims = new[] {"email", "email_verified", "name", "phone_number", "phone_number_verified", "role"}; |
|||
await CreateApiResourceAsync("MyProjectName", commonApiUserClaims); |
|||
} |
|||
|
|||
private async Task<ApiResource> CreateApiResourceAsync(string name, IEnumerable<string> claims) |
|||
{ |
|||
var apiResource = await _apiResourceRepository.FindByNameAsync(name); |
|||
if (apiResource == null) |
|||
{ |
|||
apiResource = await _apiResourceRepository.InsertAsync( |
|||
new ApiResource( |
|||
_guidGenerator.Create(), |
|||
name, |
|||
name + " API" |
|||
), |
|||
autoSave: true |
|||
); |
|||
} |
|||
|
|||
foreach (var claim in claims) |
|||
{ |
|||
if (apiResource.FindClaim(claim) == null) |
|||
{ |
|||
apiResource.AddUserClaim(claim); |
|||
} |
|||
} |
|||
|
|||
return await _apiResourceRepository.UpdateAsync(apiResource); |
|||
} |
|||
|
|||
private async Task<ApiScope> CreateApiScopeAsync(string name) |
|||
{ |
|||
var apiScope = await _apiScopeRepository.FindByNameAsync(name); |
|||
if (apiScope == null) |
|||
{ |
|||
apiScope = await _apiScopeRepository.InsertAsync( |
|||
new ApiScope( |
|||
_guidGenerator.Create(), |
|||
name, |
|||
name + " API" |
|||
), |
|||
autoSave: true |
|||
); |
|||
} |
|||
|
|||
return apiScope; |
|||
} |
|||
|
|||
private async Task CreateClientsAsync() |
|||
{ |
|||
var commonScopes = new[] |
|||
{ |
|||
"email", |
|||
"openid", |
|||
"profile", |
|||
"role", |
|||
"phone", |
|||
"address", |
|||
"MyProjectName" |
|||
}; |
|||
|
|||
var configurationSection = _configuration.GetSection("IdentityServer:Clients"); |
|||
|
|||
// Angular Client
|
|||
var consoleAndAngularClientId = configurationSection["MyProjectName_App:ClientId"]; |
|||
if (!consoleAndAngularClientId.IsNullOrWhiteSpace()) |
|||
{ |
|||
var webClientRootUrl = configurationSection["MyProjectName_App:RootUrl"]?.TrimEnd('/'); |
|||
|
|||
await CreateClientAsync( |
|||
name: consoleAndAngularClientId, |
|||
scopes: commonScopes, |
|||
grantTypes: new[] { "password", "client_credentials", "authorization_code" }, |
|||
secret: (configurationSection["MyProjectName_App:ClientSecret"] ?? "1q2w3e*").Sha256(), |
|||
requireClientSecret: false, |
|||
redirectUri: webClientRootUrl, |
|||
postLogoutRedirectUri: webClientRootUrl, |
|||
corsOrigins: new[] { webClientRootUrl.RemovePostFix("/") } |
|||
); |
|||
} |
|||
|
|||
// Swagger Client
|
|||
var swaggerClientId = configurationSection["MyProjectName_Swagger:ClientId"]; |
|||
if (!swaggerClientId.IsNullOrWhiteSpace()) |
|||
{ |
|||
var swaggerRootUrl = configurationSection["MyProjectName_Swagger:RootUrl"].TrimEnd('/'); |
|||
|
|||
await CreateClientAsync( |
|||
name: swaggerClientId, |
|||
scopes: commonScopes, |
|||
grantTypes: new[] { "authorization_code" }, |
|||
secret: configurationSection["MyProjectName_Swagger:ClientSecret"]?.Sha256(), |
|||
requireClientSecret: false, |
|||
redirectUri: $"{swaggerRootUrl}/swagger/oauth2-redirect.html", |
|||
corsOrigins: new[] { swaggerRootUrl.RemovePostFix("/") } |
|||
); |
|||
} |
|||
} |
|||
|
|||
private async Task<Client> CreateClientAsync( |
|||
string name, |
|||
IEnumerable<string> scopes, |
|||
IEnumerable<string> grantTypes, |
|||
string secret = null, |
|||
string redirectUri = null, |
|||
string postLogoutRedirectUri = null, |
|||
string frontChannelLogoutUri = null, |
|||
bool requireClientSecret = true, |
|||
bool requirePkce = false, |
|||
IEnumerable<string> permissions = null, |
|||
IEnumerable<string> corsOrigins = null) |
|||
{ |
|||
var client = await _clientRepository.FindByClientIdAsync(name); |
|||
if (client == null) |
|||
{ |
|||
client = await _clientRepository.InsertAsync( |
|||
new Client( |
|||
_guidGenerator.Create(), |
|||
name |
|||
) |
|||
{ |
|||
ClientName = name, |
|||
ProtocolType = "oidc", |
|||
Description = name, |
|||
AlwaysIncludeUserClaimsInIdToken = true, |
|||
AllowOfflineAccess = true, |
|||
AbsoluteRefreshTokenLifetime = 31536000, //365 days
|
|||
AccessTokenLifetime = 31536000, //365 days
|
|||
AuthorizationCodeLifetime = 300, |
|||
IdentityTokenLifetime = 300, |
|||
RequireConsent = false, |
|||
FrontChannelLogoutUri = frontChannelLogoutUri, |
|||
RequireClientSecret = requireClientSecret, |
|||
RequirePkce = requirePkce |
|||
}, |
|||
autoSave: true |
|||
); |
|||
} |
|||
|
|||
foreach (var scope in scopes) |
|||
{ |
|||
if (client.FindScope(scope) == null) |
|||
{ |
|||
client.AddScope(scope); |
|||
} |
|||
} |
|||
|
|||
foreach (var grantType in grantTypes) |
|||
{ |
|||
if (client.FindGrantType(grantType) == null) |
|||
{ |
|||
client.AddGrantType(grantType); |
|||
} |
|||
} |
|||
|
|||
if (!secret.IsNullOrEmpty()) |
|||
{ |
|||
if (client.FindSecret(secret) == null) |
|||
{ |
|||
client.AddSecret(secret); |
|||
} |
|||
} |
|||
|
|||
if (redirectUri != null) |
|||
{ |
|||
if (client.FindRedirectUri(redirectUri) == null) |
|||
{ |
|||
client.AddRedirectUri(redirectUri); |
|||
} |
|||
} |
|||
|
|||
if (postLogoutRedirectUri != null) |
|||
{ |
|||
if (client.FindPostLogoutRedirectUri(postLogoutRedirectUri) == null) |
|||
{ |
|||
client.AddPostLogoutRedirectUri(postLogoutRedirectUri); |
|||
} |
|||
} |
|||
|
|||
if (permissions != null) |
|||
{ |
|||
await _permissionDataSeeder.SeedAsync( |
|||
ClientPermissionValueProvider.ProviderName, |
|||
name, |
|||
permissions, |
|||
null |
|||
); |
|||
} |
|||
|
|||
if (corsOrigins != null) |
|||
{ |
|||
foreach (var origin in corsOrigins) |
|||
{ |
|||
if (!origin.IsNullOrWhiteSpace() && client.FindCorsOrigin(origin) == null) |
|||
{ |
|||
client.AddCorsOrigin(origin); |
|||
} |
|||
} |
|||
} |
|||
|
|||
return await _clientRepository.UpdateAsync(client); |
|||
} |
|||
} |
|||
@ -0,0 +1,299 @@ |
|||
using JetBrains.Annotations; |
|||
using Microsoft.Extensions.Localization; |
|||
using OpenIddict.Abstractions; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Authorization.Permissions; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.PermissionManagement; |
|||
using Volo.Abp.Uow; |
|||
|
|||
namespace MyCompanyName.MyProjectName.Data; |
|||
|
|||
/* Creates initial data that is needed to property run the application |
|||
* and make client-to-server communication possible. |
|||
*/ |
|||
public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDependency |
|||
{ |
|||
private readonly IConfiguration _configuration; |
|||
private readonly IOpenIddictApplicationManager _applicationManager; |
|||
private readonly IOpenIddictScopeManager _scopeManager; |
|||
private readonly IPermissionDataSeeder _permissionDataSeeder; |
|||
private readonly IStringLocalizer<OpenIddictResponse> L; |
|||
|
|||
public OpenIddictDataSeedContributor( |
|||
IConfiguration configuration, |
|||
IOpenIddictApplicationManager applicationManager, |
|||
IOpenIddictScopeManager scopeManager, |
|||
IPermissionDataSeeder permissionDataSeeder, |
|||
IStringLocalizer<OpenIddictResponse> l) |
|||
{ |
|||
_configuration = configuration; |
|||
_applicationManager = applicationManager; |
|||
_scopeManager = scopeManager; |
|||
_permissionDataSeeder = permissionDataSeeder; |
|||
L = l; |
|||
} |
|||
|
|||
[UnitOfWork] |
|||
public virtual async Task SeedAsync(DataSeedContext context) |
|||
{ |
|||
await CreateScopesAsync(); |
|||
await CreateApplicationsAsync(); |
|||
} |
|||
|
|||
private async Task CreateScopesAsync() |
|||
{ |
|||
if (await _scopeManager.FindByNameAsync("MyProjectName") == null) |
|||
{ |
|||
await _scopeManager.CreateAsync(new OpenIddictScopeDescriptor |
|||
{ |
|||
Name = "MyProjectName", |
|||
DisplayName = "MyProjectName API", |
|||
Resources = |
|||
{ |
|||
"MyProjectName" |
|||
} |
|||
}); |
|||
} |
|||
} |
|||
|
|||
private async Task CreateApplicationsAsync() |
|||
{ |
|||
var commonScopes = new List<string> |
|||
{ |
|||
OpenIddictConstants.Permissions.Scopes.Address, |
|||
OpenIddictConstants.Permissions.Scopes.Email, |
|||
OpenIddictConstants.Permissions.Scopes.Phone, |
|||
OpenIddictConstants.Permissions.Scopes.Profile, |
|||
OpenIddictConstants.Permissions.Scopes.Roles, |
|||
"MyProjectName" |
|||
}; |
|||
|
|||
var configurationSection = _configuration.GetSection("OpenIddict:Applications"); |
|||
|
|||
//Console Test / Angular Client
|
|||
var consoleAndAngularClientId = configurationSection["MyProjectName_App:ClientId"]; |
|||
if (!consoleAndAngularClientId.IsNullOrWhiteSpace()) |
|||
{ |
|||
var webClientRootUrl = configurationSection["MyProjectName_App:RootUrl"]?.TrimEnd('/'); |
|||
await CreateApplicationAsync( |
|||
name: consoleAndAngularClientId, |
|||
type: OpenIddictConstants.ClientTypes.Public, |
|||
consentType: OpenIddictConstants.ConsentTypes.Implicit, |
|||
displayName: "Console Test / Angular Application", |
|||
secret: null, |
|||
grantTypes: new List<string> |
|||
{ |
|||
OpenIddictConstants.GrantTypes.AuthorizationCode, |
|||
OpenIddictConstants.GrantTypes.Password, |
|||
OpenIddictConstants.GrantTypes.ClientCredentials, |
|||
OpenIddictConstants.GrantTypes.RefreshToken |
|||
}, |
|||
scopes: commonScopes, |
|||
redirectUri: webClientRootUrl, |
|||
postLogoutRedirectUri: webClientRootUrl |
|||
); |
|||
} |
|||
|
|||
// Swagger Client
|
|||
var swaggerClientId = configurationSection["MyProjectName_Swagger:ClientId"]; |
|||
if (!swaggerClientId.IsNullOrWhiteSpace()) |
|||
{ |
|||
var swaggerRootUrl = configurationSection["MyProjectName_Swagger:RootUrl"].TrimEnd('/'); |
|||
|
|||
await CreateApplicationAsync( |
|||
name: swaggerClientId, |
|||
type: OpenIddictConstants.ClientTypes.Public, |
|||
consentType: OpenIddictConstants.ConsentTypes.Implicit, |
|||
displayName: "Swagger Application", |
|||
secret: null, |
|||
grantTypes: new List<string> |
|||
{ |
|||
OpenIddictConstants.GrantTypes.AuthorizationCode, |
|||
}, |
|||
scopes: commonScopes, |
|||
redirectUri: $"{swaggerRootUrl}/swagger/oauth2-redirect.html" |
|||
); |
|||
} |
|||
} |
|||
|
|||
private async Task CreateApplicationAsync( |
|||
[NotNull] string name, |
|||
[NotNull] string type, |
|||
[NotNull] string consentType, |
|||
string displayName, |
|||
string secret, |
|||
List<string> grantTypes, |
|||
List<string> scopes, |
|||
string redirectUri = null, |
|||
string postLogoutRedirectUri = null, |
|||
List<string> permissions = null) |
|||
{ |
|||
if (!string.IsNullOrEmpty(secret) && string.Equals(type, OpenIddictConstants.ClientTypes.Public, StringComparison.OrdinalIgnoreCase)) |
|||
{ |
|||
throw new BusinessException(L["NoClientSecretCanBeSetForPublicApplications"]); |
|||
} |
|||
|
|||
if (string.IsNullOrEmpty(secret) && string.Equals(type, OpenIddictConstants.ClientTypes.Confidential, StringComparison.OrdinalIgnoreCase)) |
|||
{ |
|||
throw new BusinessException(L["TheClientSecretIsRequiredForConfidentialApplications"]); |
|||
} |
|||
|
|||
if (!string.IsNullOrEmpty(name) && await _applicationManager.FindByClientIdAsync(name) != null) |
|||
{ |
|||
return; |
|||
//throw new BusinessException(L["TheClientIdentifierIsAlreadyTakenByAnotherApplication"]);
|
|||
} |
|||
|
|||
var client = await _applicationManager.FindByClientIdAsync(name); |
|||
if (client == null) |
|||
{ |
|||
var application = new OpenIddictApplicationDescriptor |
|||
{ |
|||
ClientId = name, |
|||
Type = type, |
|||
ClientSecret = secret, |
|||
ConsentType = consentType, |
|||
DisplayName = displayName |
|||
}; |
|||
|
|||
Check.NotNullOrEmpty(grantTypes, nameof(grantTypes)); |
|||
Check.NotNullOrEmpty(scopes, nameof(scopes)); |
|||
|
|||
if (new [] { OpenIddictConstants.GrantTypes.AuthorizationCode, OpenIddictConstants.GrantTypes.Implicit }.All(grantTypes.Contains)) |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.CodeIdToken); |
|||
|
|||
if (string.Equals(type, OpenIddictConstants.ClientTypes.Public, StringComparison.OrdinalIgnoreCase)) |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.CodeIdTokenToken); |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.CodeToken); |
|||
} |
|||
} |
|||
|
|||
if (!redirectUri.IsNullOrWhiteSpace() || !postLogoutRedirectUri.IsNullOrWhiteSpace()) |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Logout); |
|||
} |
|||
|
|||
foreach (var grantType in grantTypes) |
|||
{ |
|||
if (grantType == OpenIddictConstants.GrantTypes.AuthorizationCode) |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.AuthorizationCode); |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.Code); |
|||
} |
|||
|
|||
if (grantType == OpenIddictConstants.GrantTypes.AuthorizationCode || grantType == OpenIddictConstants.GrantTypes.Implicit) |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Authorization); |
|||
} |
|||
|
|||
if (grantType == OpenIddictConstants.GrantTypes.AuthorizationCode || |
|||
grantType == OpenIddictConstants.GrantTypes.ClientCredentials || |
|||
grantType == OpenIddictConstants.GrantTypes.Password || |
|||
grantType == OpenIddictConstants.GrantTypes.RefreshToken || |
|||
grantType == OpenIddictConstants.GrantTypes.DeviceCode) |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Token); |
|||
} |
|||
|
|||
if (grantType == OpenIddictConstants.GrantTypes.ClientCredentials) |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.ClientCredentials); |
|||
} |
|||
|
|||
if (grantType == OpenIddictConstants.GrantTypes.Implicit) |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.Implicit); |
|||
} |
|||
|
|||
if (grantType == OpenIddictConstants.GrantTypes.Password) |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.Password); |
|||
} |
|||
|
|||
if (grantType == OpenIddictConstants.GrantTypes.RefreshToken) |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.RefreshToken); |
|||
} |
|||
|
|||
if (grantType == OpenIddictConstants.GrantTypes.Implicit) |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.IdToken); |
|||
if (string.Equals(type, OpenIddictConstants.ClientTypes.Public, StringComparison.OrdinalIgnoreCase)) |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.IdTokenToken); |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.Token); |
|||
} |
|||
} |
|||
} |
|||
|
|||
var buildInScopes = new [] |
|||
{ |
|||
OpenIddictConstants.Permissions.Scopes.Address, |
|||
OpenIddictConstants.Permissions.Scopes.Email, |
|||
OpenIddictConstants.Permissions.Scopes.Phone, |
|||
OpenIddictConstants.Permissions.Scopes.Profile, |
|||
OpenIddictConstants.Permissions.Scopes.Roles |
|||
}; |
|||
|
|||
foreach (var scope in scopes) |
|||
{ |
|||
if (buildInScopes.Contains(scope)) |
|||
{ |
|||
application.Permissions.Add(scope); |
|||
} |
|||
else |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.Prefixes.Scope + scope); |
|||
} |
|||
} |
|||
|
|||
if (redirectUri != null) |
|||
{ |
|||
if (!redirectUri.IsNullOrEmpty()) |
|||
{ |
|||
if (!Uri.TryCreate(redirectUri, UriKind.Absolute, out var uri) || !uri.IsWellFormedOriginalString()) |
|||
{ |
|||
throw new BusinessException(L["InvalidRedirectUri", redirectUri]); |
|||
} |
|||
|
|||
if (application.RedirectUris.All(x => x != uri)) |
|||
{ |
|||
application.RedirectUris.Add(uri); |
|||
} |
|||
} |
|||
} |
|||
|
|||
if (postLogoutRedirectUri != null) |
|||
{ |
|||
if (!postLogoutRedirectUri.IsNullOrEmpty()) |
|||
{ |
|||
if (!Uri.TryCreate(postLogoutRedirectUri, UriKind.Absolute, out var uri) || !uri.IsWellFormedOriginalString()) |
|||
{ |
|||
throw new BusinessException(L["InvalidPostLogoutRedirectUri", postLogoutRedirectUri]); |
|||
} |
|||
|
|||
if (application.PostLogoutRedirectUris.All(x => x != uri)) |
|||
{ |
|||
application.PostLogoutRedirectUris.Add(uri); |
|||
} |
|||
} |
|||
} |
|||
|
|||
if (permissions != null) |
|||
{ |
|||
await _permissionDataSeeder.SeedAsync( |
|||
ClientPermissionValueProvider.ProviderName, |
|||
name, |
|||
permissions, |
|||
null |
|||
); |
|||
} |
|||
|
|||
await _applicationManager.CreateAsync(application); |
|||
} |
|||
} |
|||
} |
|||
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
@ -1,13 +0,0 @@ |
|||
{ |
|||
"KeyId": "f788zGVUZh9H-HbWL1S-Mg", |
|||
"Parameters": { |
|||
"D": "F19hbC5PLO872DszGiJnVoU55ee7XGXmNf0KEKndJ/uGBv5lWklXA0QF80h1ytWXde0jV5isQPB1t7mPhRQlDoDTkywLi1CeOgBPbxzHEfLjZZ5c4olfeX0IJX9BDqgUntY0H1a/+Om/eDu4OZUz3EIJFFZBgz46YZSyTT6ZDvAEdpC/o66sNJmxvJIp+8zVoVDSqBUzxmc+oEamXLg7r2jdymxJMxau1kQFxEGLOrJnNxGsEe8UrYA3qSsm8m/Xg4uOh7RYgnuEEt88+KTvRq+CAMWhN3YNLtOJ3NmXowwE7e1Ma+jih9+UVfxZn14P5+SOJbQ2bYV2sCV+2vBiCQ==", |
|||
"DP": "oPiGO/qdOQfFEAS9fMInQnsrNylIZVpDYEVoDJ6/jQfE/IpuwxGcmsaGvCob3SKxZiJRLCWpwJYo1hCh/JOSVGWMkVyELky56nbbkkV5ymKLSGZ4JoetdQs+GchnPdR+k2P9Ij1Kjk13ylubN3htzNhcBASJpOfSEv5pPVzGKX0=", |
|||
"DQ": "z6imxLABHkyftbfUUtpeOlPanEHgpuIjmUdp3T1Ju1jziE63UEhuj0GPAXOF17uYxixwYE8JhOJ7+TyIK9oZeI3zH2OzJqQh8f5PCQ/E+0ULXZDeNV/ShDLCTufu3Fis9Rt64uTp/H/l21oMQ79jc0ysa8DTz1ReJLRc5qjL41U=", |
|||
"Exponent": "AQAB", |
|||
"InverseQ": "ieZcvSt5XYukKJKhXpv5Dm/1RD7iH88cZnhLSTEVTMoOUHoYWmApY5pNLGahbfjA9bxnkBWDYex/i7wE9uNNY5CsA6ovUaQLVJDt3kHvR9W+9QtN8D6jjG2TuRbbOdEg4RqhfjUaDfDIgTJX2Wxc8U98FOvOyGw1HzwUPFZKecM=", |
|||
"Modulus": "vk4z1Bmtmbo+gxITcY+FIlXzcO2wTOGlOXK5GMYj/6PUMFt7lbqkc72AkPsrAo5/JE8LYLhWj7fzSKbjvtowHCz5m2t+FlUYmuiKpvvnJsTqvQrckNlbZ1nm071q5PhP3Dar/OksfBhPtAX+c3+NjDnM/w53ccJJNaBDO/s9JYoN7vH5n6ed1pMSK71hmg4MPsxChcnc1f1PpnG2mqyJ253+GEUbj/kRyeBSmCCr9aadov2ZzxIKVaFNagJEHOzanQmorSLpP25GfOHCuy27Zkef94V/qU9elzjbH4uIKslVGx5T6H99TYh0sUGu11NytYJa5WNAZWow95CzurC2vw==", |
|||
"P": "4GMCQy+XTNzR5TsgFcdAZv2K6TcQR13fHVvPoxQp/b32V5YUJOBFEUAtqociy5ro4+KzpXP5WPSk1ZtznGKuNZyLq8gTnhpB3rwd0sdo4zxKnQ5nu+n1UhlhWNxg5A9V5TaciUAyPrHWJfLoYTQWygNTgJELQH5zZXi2ihC2uiU=", |
|||
"Q": "2R36pamnLAJggkPJxiW5qH6HizZ+bkQVg0BBftMLzkAM8Y9CwTW75GRUzGEJFpMckkw0GZSYb1Uwl3DVUpkcQ8LZ91IPYdPpDlYUshhIxl184M55pnO14besKxJtMZ64zhHKVAR2pBMO0n6W4/1iBXkkQqyPViJxdfvXPJMBbhM=" |
|||
} |
|||
} |
|||
@ -1,353 +0,0 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using IdentityServer4.Models; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Volo.Abp.Authorization.Permissions; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Guids; |
|||
using Volo.Abp.IdentityServer.ApiResources; |
|||
using Volo.Abp.IdentityServer.ApiScopes; |
|||
using Volo.Abp.IdentityServer.Clients; |
|||
using Volo.Abp.IdentityServer.IdentityResources; |
|||
using Volo.Abp.MultiTenancy; |
|||
using Volo.Abp.PermissionManagement; |
|||
using Volo.Abp.Uow; |
|||
using ApiResource = Volo.Abp.IdentityServer.ApiResources.ApiResource; |
|||
using ApiScope = Volo.Abp.IdentityServer.ApiScopes.ApiScope; |
|||
using Client = Volo.Abp.IdentityServer.Clients.Client; |
|||
|
|||
namespace MyCompanyName.MyProjectName.IdentityServer; |
|||
|
|||
public class IdentityServerDataSeedContributor : IDataSeedContributor, ITransientDependency |
|||
{ |
|||
private readonly IApiResourceRepository _apiResourceRepository; |
|||
private readonly IApiScopeRepository _apiScopeRepository; |
|||
private readonly IClientRepository _clientRepository; |
|||
private readonly IIdentityResourceDataSeeder _identityResourceDataSeeder; |
|||
private readonly IGuidGenerator _guidGenerator; |
|||
private readonly IPermissionDataSeeder _permissionDataSeeder; |
|||
private readonly IConfiguration _configuration; |
|||
private readonly ICurrentTenant _currentTenant; |
|||
|
|||
public IdentityServerDataSeedContributor( |
|||
IClientRepository clientRepository, |
|||
IApiResourceRepository apiResourceRepository, |
|||
IApiScopeRepository apiScopeRepository, |
|||
IIdentityResourceDataSeeder identityResourceDataSeeder, |
|||
IGuidGenerator guidGenerator, |
|||
IPermissionDataSeeder permissionDataSeeder, |
|||
IConfiguration configuration, |
|||
ICurrentTenant currentTenant) |
|||
{ |
|||
_clientRepository = clientRepository; |
|||
_apiResourceRepository = apiResourceRepository; |
|||
_apiScopeRepository = apiScopeRepository; |
|||
_identityResourceDataSeeder = identityResourceDataSeeder; |
|||
_guidGenerator = guidGenerator; |
|||
_permissionDataSeeder = permissionDataSeeder; |
|||
_configuration = configuration; |
|||
_currentTenant = currentTenant; |
|||
} |
|||
|
|||
[UnitOfWork] |
|||
public virtual async Task SeedAsync(DataSeedContext context) |
|||
{ |
|||
using (_currentTenant.Change(context?.TenantId)) |
|||
{ |
|||
await _identityResourceDataSeeder.CreateStandardResourcesAsync(); |
|||
await CreateApiResourcesAsync(); |
|||
await CreateApiScopesAsync(); |
|||
await CreateClientsAsync(); |
|||
} |
|||
} |
|||
|
|||
private async Task CreateApiScopesAsync() |
|||
{ |
|||
await CreateApiScopeAsync("MyProjectName"); |
|||
} |
|||
|
|||
private async Task CreateApiResourcesAsync() |
|||
{ |
|||
var commonApiUserClaims = new[] |
|||
{ |
|||
"email", |
|||
"email_verified", |
|||
"name", |
|||
"phone_number", |
|||
"phone_number_verified", |
|||
"role" |
|||
}; |
|||
|
|||
await CreateApiResourceAsync("MyProjectName", commonApiUserClaims); |
|||
} |
|||
|
|||
private async Task<ApiResource> CreateApiResourceAsync(string name, IEnumerable<string> claims) |
|||
{ |
|||
var apiResource = await _apiResourceRepository.FindByNameAsync(name); |
|||
if (apiResource == null) |
|||
{ |
|||
apiResource = await _apiResourceRepository.InsertAsync( |
|||
new ApiResource( |
|||
_guidGenerator.Create(), |
|||
name, |
|||
name + " API" |
|||
), |
|||
autoSave: true |
|||
); |
|||
} |
|||
|
|||
foreach (var claim in claims) |
|||
{ |
|||
if (apiResource.FindClaim(claim) == null) |
|||
{ |
|||
apiResource.AddUserClaim(claim); |
|||
} |
|||
} |
|||
|
|||
return await _apiResourceRepository.UpdateAsync(apiResource); |
|||
} |
|||
|
|||
private async Task<ApiScope> CreateApiScopeAsync(string name) |
|||
{ |
|||
var apiScope = await _apiScopeRepository.FindByNameAsync(name); |
|||
if (apiScope == null) |
|||
{ |
|||
apiScope = await _apiScopeRepository.InsertAsync( |
|||
new ApiScope( |
|||
_guidGenerator.Create(), |
|||
name, |
|||
name + " API" |
|||
), |
|||
autoSave: true |
|||
); |
|||
} |
|||
|
|||
return apiScope; |
|||
} |
|||
|
|||
private async Task CreateClientsAsync() |
|||
{ |
|||
var commonScopes = new[] |
|||
{ |
|||
"email", |
|||
"openid", |
|||
"profile", |
|||
"role", |
|||
"phone", |
|||
"address", |
|||
"MyProjectName" |
|||
}; |
|||
|
|||
var configurationSection = _configuration.GetSection("IdentityServer:Clients"); |
|||
|
|||
//<TEMPLATE-REMOVE IF-NOT='ui:mvc&&tiered'>
|
|||
|
|||
//Web Client
|
|||
var webClientId = configurationSection["MyProjectName_Web:ClientId"]; |
|||
if (!webClientId.IsNullOrWhiteSpace()) |
|||
{ |
|||
var webClientRootUrl = configurationSection["MyProjectName_Web:RootUrl"].EnsureEndsWith('/'); |
|||
|
|||
await CreateClientAsync( |
|||
name: webClientId, |
|||
scopes: commonScopes, |
|||
grantTypes: new[] { "hybrid" }, |
|||
secret: (configurationSection["MyProjectName_Web:ClientSecret"] ?? "1q2w3e*").Sha256(), |
|||
redirectUri: $"{webClientRootUrl}signin-oidc", |
|||
postLogoutRedirectUri: $"{webClientRootUrl}signout-callback-oidc", |
|||
frontChannelLogoutUri: $"{webClientRootUrl}Account/FrontChannelLogout", |
|||
corsOrigins: new[] { webClientRootUrl.RemovePostFix("/") } |
|||
); |
|||
} |
|||
|
|||
//</TEMPLATE-REMOVE>
|
|||
|
|||
//Console Test / Angular Client
|
|||
var consoleAndAngularClientId = configurationSection["MyProjectName_App:ClientId"]; |
|||
if (!consoleAndAngularClientId.IsNullOrWhiteSpace()) |
|||
{ |
|||
var webClientRootUrl = configurationSection["MyProjectName_App:RootUrl"]?.TrimEnd('/'); |
|||
|
|||
await CreateClientAsync( |
|||
name: consoleAndAngularClientId, |
|||
scopes: commonScopes, |
|||
grantTypes: new[] { "password", "client_credentials", "authorization_code" }, |
|||
secret: (configurationSection["MyProjectName_App:ClientSecret"] ?? "1q2w3e*").Sha256(), |
|||
requireClientSecret: false, |
|||
redirectUri: webClientRootUrl, |
|||
postLogoutRedirectUri: webClientRootUrl, |
|||
corsOrigins: new[] { webClientRootUrl.RemovePostFix("/") } |
|||
); |
|||
} |
|||
|
|||
//<TEMPLATE-REMOVE IF-NOT='ui:blazor'>
|
|||
|
|||
// Blazor Client
|
|||
var blazorClientId = configurationSection["MyProjectName_Blazor:ClientId"]; |
|||
if (!blazorClientId.IsNullOrWhiteSpace()) |
|||
{ |
|||
var blazorRootUrl = configurationSection["MyProjectName_Blazor:RootUrl"].TrimEnd('/'); |
|||
|
|||
await CreateClientAsync( |
|||
name: blazorClientId, |
|||
scopes: commonScopes, |
|||
grantTypes: new[] { "authorization_code" }, |
|||
secret: configurationSection["MyProjectName_Blazor:ClientSecret"]?.Sha256(), |
|||
requireClientSecret: false, |
|||
redirectUri: $"{blazorRootUrl}/authentication/login-callback", |
|||
postLogoutRedirectUri: $"{blazorRootUrl}/authentication/logout-callback", |
|||
corsOrigins: new[] { blazorRootUrl.RemovePostFix("/") } |
|||
); |
|||
} |
|||
|
|||
//</TEMPLATE-REMOVE>
|
|||
|
|||
//<TEMPLATE-REMOVE IF-NOT='ui:blazor-server&&tiered'>
|
|||
|
|||
//Blazor Server Tiered Client
|
|||
var blazorServerTieredClientId = configurationSection["MyProjectName_BlazorServerTiered:ClientId"]; |
|||
if (!blazorServerTieredClientId.IsNullOrWhiteSpace()) |
|||
{ |
|||
var blazorServerTieredClientRootUrl = configurationSection["MyProjectName_BlazorServerTiered:RootUrl"].EnsureEndsWith('/'); |
|||
|
|||
/* MyProjectName_BlazorServerTiered client is only needed if you created a tiered blazor server |
|||
* solution. Otherwise, you can delete this client. */ |
|||
|
|||
await CreateClientAsync( |
|||
name: blazorServerTieredClientId, |
|||
scopes: commonScopes, |
|||
grantTypes: new[] { "hybrid" }, |
|||
secret: (configurationSection["MyProjectName_BlazorServerTiered:ClientSecret"] ?? "1q2w3e*").Sha256(), |
|||
redirectUri: $"{blazorServerTieredClientRootUrl}signin-oidc", |
|||
postLogoutRedirectUri: $"{blazorServerTieredClientRootUrl}signout-callback-oidc", |
|||
frontChannelLogoutUri: $"{blazorServerTieredClientRootUrl}Account/FrontChannelLogout", |
|||
corsOrigins: new[] { blazorServerTieredClientRootUrl.RemovePostFix("/") } |
|||
); |
|||
} |
|||
|
|||
//</TEMPLATE-REMOVE>
|
|||
|
|||
// Swagger Client
|
|||
var swaggerClientId = configurationSection["MyProjectName_Swagger:ClientId"]; |
|||
if (!swaggerClientId.IsNullOrWhiteSpace()) |
|||
{ |
|||
var swaggerRootUrl = configurationSection["MyProjectName_Swagger:RootUrl"].TrimEnd('/'); |
|||
|
|||
await CreateClientAsync( |
|||
name: swaggerClientId, |
|||
scopes: commonScopes, |
|||
grantTypes: new[] { "authorization_code" }, |
|||
secret: configurationSection["MyProjectName_Swagger:ClientSecret"]?.Sha256(), |
|||
requireClientSecret: false, |
|||
redirectUri: $"{swaggerRootUrl}/swagger/oauth2-redirect.html", |
|||
corsOrigins: new[] { swaggerRootUrl.RemovePostFix("/") } |
|||
); |
|||
} |
|||
} |
|||
|
|||
private async Task<Client> CreateClientAsync( |
|||
string name, |
|||
IEnumerable<string> scopes, |
|||
IEnumerable<string> grantTypes, |
|||
string secret = null, |
|||
string redirectUri = null, |
|||
string postLogoutRedirectUri = null, |
|||
string frontChannelLogoutUri = null, |
|||
bool requireClientSecret = true, |
|||
bool requirePkce = false, |
|||
IEnumerable<string> permissions = null, |
|||
IEnumerable<string> corsOrigins = null) |
|||
{ |
|||
var client = await _clientRepository.FindByClientIdAsync(name); |
|||
if (client == null) |
|||
{ |
|||
client = await _clientRepository.InsertAsync( |
|||
new Client( |
|||
_guidGenerator.Create(), |
|||
name |
|||
) |
|||
{ |
|||
ClientName = name, |
|||
ProtocolType = "oidc", |
|||
Description = name, |
|||
AlwaysIncludeUserClaimsInIdToken = true, |
|||
AllowOfflineAccess = true, |
|||
AbsoluteRefreshTokenLifetime = 31536000, //365 days
|
|||
AccessTokenLifetime = 31536000, //365 days
|
|||
AuthorizationCodeLifetime = 300, |
|||
IdentityTokenLifetime = 300, |
|||
RequireConsent = false, |
|||
FrontChannelLogoutUri = frontChannelLogoutUri, |
|||
RequireClientSecret = requireClientSecret, |
|||
RequirePkce = requirePkce |
|||
}, |
|||
autoSave: true |
|||
); |
|||
} |
|||
|
|||
foreach (var scope in scopes) |
|||
{ |
|||
if (client.FindScope(scope) == null) |
|||
{ |
|||
client.AddScope(scope); |
|||
} |
|||
} |
|||
|
|||
foreach (var grantType in grantTypes) |
|||
{ |
|||
if (client.FindGrantType(grantType) == null) |
|||
{ |
|||
client.AddGrantType(grantType); |
|||
} |
|||
} |
|||
|
|||
if (!secret.IsNullOrEmpty()) |
|||
{ |
|||
if (client.FindSecret(secret) == null) |
|||
{ |
|||
client.AddSecret(secret); |
|||
} |
|||
} |
|||
|
|||
if (redirectUri != null) |
|||
{ |
|||
if (client.FindRedirectUri(redirectUri) == null) |
|||
{ |
|||
client.AddRedirectUri(redirectUri); |
|||
} |
|||
} |
|||
|
|||
if (postLogoutRedirectUri != null) |
|||
{ |
|||
if (client.FindPostLogoutRedirectUri(postLogoutRedirectUri) == null) |
|||
{ |
|||
client.AddPostLogoutRedirectUri(postLogoutRedirectUri); |
|||
} |
|||
} |
|||
|
|||
if (permissions != null) |
|||
{ |
|||
await _permissionDataSeeder.SeedAsync( |
|||
ClientPermissionValueProvider.ProviderName, |
|||
name, |
|||
permissions, |
|||
null |
|||
); |
|||
} |
|||
|
|||
if (corsOrigins != null) |
|||
{ |
|||
foreach (var origin in corsOrigins) |
|||
{ |
|||
if (!origin.IsNullOrWhiteSpace() && client.FindCorsOrigin(origin) == null) |
|||
{ |
|||
client.AddCorsOrigin(origin); |
|||
} |
|||
} |
|||
} |
|||
|
|||
return await _clientRepository.UpdateAsync(client); |
|||
} |
|||
} |
|||
@ -0,0 +1,374 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using JetBrains.Annotations; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.Localization; |
|||
using OpenIddict.Abstractions; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Authorization.Permissions; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.PermissionManagement; |
|||
using Volo.Abp.Uow; |
|||
|
|||
namespace MyCompanyName.MyProjectName.OpenIddict; |
|||
|
|||
/* Creates initial data that is needed to property run the application |
|||
* and make client-to-server communication possible. |
|||
*/ |
|||
public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDependency |
|||
{ |
|||
private readonly IConfiguration _configuration; |
|||
private readonly IOpenIddictApplicationManager _applicationManager; |
|||
private readonly IOpenIddictScopeManager _scopeManager; |
|||
private readonly IPermissionDataSeeder _permissionDataSeeder; |
|||
private readonly IStringLocalizer<OpenIddictResponse> L; |
|||
|
|||
public OpenIddictDataSeedContributor( |
|||
IConfiguration configuration, |
|||
IOpenIddictApplicationManager applicationManager, |
|||
IOpenIddictScopeManager scopeManager, |
|||
IPermissionDataSeeder permissionDataSeeder, |
|||
IStringLocalizer<OpenIddictResponse> l) |
|||
{ |
|||
_configuration = configuration; |
|||
_applicationManager = applicationManager; |
|||
_scopeManager = scopeManager; |
|||
_permissionDataSeeder = permissionDataSeeder; |
|||
L = l; |
|||
} |
|||
|
|||
[UnitOfWork] |
|||
public virtual async Task SeedAsync(DataSeedContext context) |
|||
{ |
|||
await CreateScopesAsync(); |
|||
await CreateApplicationsAsync(); |
|||
} |
|||
|
|||
private async Task CreateScopesAsync() |
|||
{ |
|||
if (await _scopeManager.FindByNameAsync("MyProjectName") == null) |
|||
{ |
|||
await _scopeManager.CreateAsync(new OpenIddictScopeDescriptor |
|||
{ |
|||
Name = "MyProjectName", |
|||
DisplayName = "MyProjectName API", |
|||
Resources = |
|||
{ |
|||
"MyProjectName" |
|||
} |
|||
}); |
|||
} |
|||
} |
|||
|
|||
private async Task CreateApplicationsAsync() |
|||
{ |
|||
var commonScopes = new List<string> |
|||
{ |
|||
OpenIddictConstants.Permissions.Scopes.Address, |
|||
OpenIddictConstants.Permissions.Scopes.Email, |
|||
OpenIddictConstants.Permissions.Scopes.Phone, |
|||
OpenIddictConstants.Permissions.Scopes.Profile, |
|||
OpenIddictConstants.Permissions.Scopes.Roles, |
|||
"MyProjectName" |
|||
}; |
|||
|
|||
var configurationSection = _configuration.GetSection("OpenIddict:Applications"); |
|||
|
|||
//Web Client
|
|||
var webClientId = configurationSection["MyProjectName_Web:ClientId"]; |
|||
if (!webClientId.IsNullOrWhiteSpace()) |
|||
{ |
|||
var webClientRootUrl = configurationSection["MyProjectName_Web:RootUrl"].EnsureEndsWith('/'); |
|||
|
|||
/* MyProjectName_Web client is only needed if you created a tiered |
|||
* solution. Otherwise, you can delete this client. */ |
|||
await CreateApplicationAsync( |
|||
name: webClientId, |
|||
type: OpenIddictConstants.ClientTypes.Confidential, |
|||
consentType: OpenIddictConstants.ConsentTypes.Implicit, |
|||
displayName: "Web Application", |
|||
secret: configurationSection["MyProjectName_App:ClientSecret"] ?? "1q2w3e*", |
|||
grantTypes: new List<string> //Hybrid flow
|
|||
{ |
|||
OpenIddictConstants.GrantTypes.AuthorizationCode, |
|||
OpenIddictConstants.GrantTypes.Implicit |
|||
}, |
|||
scopes: commonScopes, |
|||
redirectUri: $"{webClientRootUrl}signin-oidc", |
|||
postLogoutRedirectUri: $"{webClientRootUrl}signout-callback-oidc" |
|||
); |
|||
} |
|||
|
|||
//Console Test / Angular Client
|
|||
var consoleAndAngularClientId = configurationSection["MyProjectName_App:ClientId"]; |
|||
if (!consoleAndAngularClientId.IsNullOrWhiteSpace()) |
|||
{ |
|||
var webClientRootUrl = configurationSection["MyProjectName_App:RootUrl"]?.TrimEnd('/'); |
|||
await CreateApplicationAsync( |
|||
name: consoleAndAngularClientId, |
|||
type: OpenIddictConstants.ClientTypes.Public, |
|||
consentType: OpenIddictConstants.ConsentTypes.Implicit, |
|||
displayName: "Console Test / Angular Application", |
|||
secret: null, |
|||
grantTypes: new List<string> |
|||
{ |
|||
OpenIddictConstants.GrantTypes.AuthorizationCode, |
|||
OpenIddictConstants.GrantTypes.Password, |
|||
OpenIddictConstants.GrantTypes.ClientCredentials, |
|||
OpenIddictConstants.GrantTypes.RefreshToken |
|||
}, |
|||
scopes: commonScopes, |
|||
redirectUri: webClientRootUrl, |
|||
postLogoutRedirectUri: webClientRootUrl |
|||
); |
|||
} |
|||
|
|||
// Blazor Client
|
|||
var blazorClientId = configurationSection["MyProjectName_Blazor:ClientId"]; |
|||
if (!blazorClientId.IsNullOrWhiteSpace()) |
|||
{ |
|||
var blazorRootUrl = configurationSection["MyProjectName_Blazor:RootUrl"].TrimEnd('/'); |
|||
|
|||
await CreateApplicationAsync( |
|||
name: blazorClientId, |
|||
type: OpenIddictConstants.ClientTypes.Public, |
|||
consentType: OpenIddictConstants.ConsentTypes.Implicit, |
|||
displayName: "Blazor Application", |
|||
secret: null, |
|||
grantTypes: new List<string> |
|||
{ |
|||
OpenIddictConstants.GrantTypes.AuthorizationCode, |
|||
}, |
|||
scopes: commonScopes, |
|||
redirectUri: $"{blazorRootUrl}/authentication/login-callback", |
|||
postLogoutRedirectUri: $"{blazorRootUrl}/authentication/logout-callback" |
|||
); |
|||
} |
|||
|
|||
// Blazor Server Tiered Client
|
|||
var blazorServerTieredClientId = configurationSection["MyProjectName_BlazorServerTiered:ClientId"]; |
|||
if (!blazorServerTieredClientId.IsNullOrWhiteSpace()) |
|||
{ |
|||
var blazorServerTieredRootUrl = configurationSection["MyProjectName_BlazorServerTiered:RootUrl"].EnsureEndsWith('/'); |
|||
|
|||
await CreateApplicationAsync( |
|||
name: blazorServerTieredClientId, |
|||
type: OpenIddictConstants.ClientTypes.Confidential, |
|||
consentType: OpenIddictConstants.ConsentTypes.Implicit, |
|||
displayName: "Blazor Server Application", |
|||
secret: configurationSection["MyProjectName_BlazorServerTiered:ClientSecret"] ?? "1q2w3e*", |
|||
grantTypes: new List<string> //Hybrid flow
|
|||
{ |
|||
OpenIddictConstants.GrantTypes.AuthorizationCode, |
|||
OpenIddictConstants.GrantTypes.Implicit |
|||
}, |
|||
scopes: commonScopes, |
|||
redirectUri: $"{blazorServerTieredRootUrl}signin-oidc", |
|||
postLogoutRedirectUri: $"{blazorServerTieredRootUrl}signout-callback-oidc" |
|||
); |
|||
} |
|||
|
|||
// Swagger Client
|
|||
var swaggerClientId = configurationSection["MyProjectName_Swagger:ClientId"]; |
|||
if (!swaggerClientId.IsNullOrWhiteSpace()) |
|||
{ |
|||
var swaggerRootUrl = configurationSection["MyProjectName_Swagger:RootUrl"].TrimEnd('/'); |
|||
|
|||
await CreateApplicationAsync( |
|||
name: swaggerClientId, |
|||
type: OpenIddictConstants.ClientTypes.Public, |
|||
consentType: OpenIddictConstants.ConsentTypes.Implicit, |
|||
displayName: "Swagger Application", |
|||
secret: null, |
|||
grantTypes: new List<string> |
|||
{ |
|||
OpenIddictConstants.GrantTypes.AuthorizationCode, |
|||
}, |
|||
scopes: commonScopes, |
|||
redirectUri: $"{swaggerRootUrl}/swagger/oauth2-redirect.html" |
|||
); |
|||
} |
|||
} |
|||
|
|||
private async Task CreateApplicationAsync( |
|||
[NotNull] string name, |
|||
[NotNull] string type, |
|||
[NotNull] string consentType, |
|||
string displayName, |
|||
string secret, |
|||
List<string> grantTypes, |
|||
List<string> scopes, |
|||
string redirectUri = null, |
|||
string postLogoutRedirectUri = null, |
|||
List<string> permissions = null) |
|||
{ |
|||
if (!string.IsNullOrEmpty(secret) && string.Equals(type, OpenIddictConstants.ClientTypes.Public, StringComparison.OrdinalIgnoreCase)) |
|||
{ |
|||
throw new BusinessException(L["NoClientSecretCanBeSetForPublicApplications"]); |
|||
} |
|||
|
|||
if (string.IsNullOrEmpty(secret) && string.Equals(type, OpenIddictConstants.ClientTypes.Confidential, StringComparison.OrdinalIgnoreCase)) |
|||
{ |
|||
throw new BusinessException(L["TheClientSecretIsRequiredForConfidentialApplications"]); |
|||
} |
|||
|
|||
if (!string.IsNullOrEmpty(name) && await _applicationManager.FindByClientIdAsync(name) != null) |
|||
{ |
|||
return; |
|||
//throw new BusinessException(L["TheClientIdentifierIsAlreadyTakenByAnotherApplication"]);
|
|||
} |
|||
|
|||
var client = await _applicationManager.FindByClientIdAsync(name); |
|||
if (client == null) |
|||
{ |
|||
var application = new OpenIddictApplicationDescriptor |
|||
{ |
|||
ClientId = name, |
|||
Type = type, |
|||
ClientSecret = secret, |
|||
ConsentType = consentType, |
|||
DisplayName = displayName |
|||
}; |
|||
|
|||
Check.NotNullOrEmpty(grantTypes, nameof(grantTypes)); |
|||
Check.NotNullOrEmpty(scopes, nameof(scopes)); |
|||
|
|||
if (new [] { OpenIddictConstants.GrantTypes.AuthorizationCode, OpenIddictConstants.GrantTypes.Implicit }.All(grantTypes.Contains)) |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.CodeIdToken); |
|||
|
|||
if (string.Equals(type, OpenIddictConstants.ClientTypes.Public, StringComparison.OrdinalIgnoreCase)) |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.CodeIdTokenToken); |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.CodeToken); |
|||
} |
|||
} |
|||
|
|||
if (!redirectUri.IsNullOrWhiteSpace() || !postLogoutRedirectUri.IsNullOrWhiteSpace()) |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Logout); |
|||
} |
|||
|
|||
foreach (var grantType in grantTypes) |
|||
{ |
|||
if (grantType == OpenIddictConstants.GrantTypes.AuthorizationCode) |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.AuthorizationCode); |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.Code); |
|||
} |
|||
|
|||
if (grantType == OpenIddictConstants.GrantTypes.AuthorizationCode || grantType == OpenIddictConstants.GrantTypes.Implicit) |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Authorization); |
|||
} |
|||
|
|||
if (grantType == OpenIddictConstants.GrantTypes.AuthorizationCode || |
|||
grantType == OpenIddictConstants.GrantTypes.ClientCredentials || |
|||
grantType == OpenIddictConstants.GrantTypes.Password || |
|||
grantType == OpenIddictConstants.GrantTypes.RefreshToken || |
|||
grantType == OpenIddictConstants.GrantTypes.DeviceCode) |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Token); |
|||
} |
|||
|
|||
if (grantType == OpenIddictConstants.GrantTypes.ClientCredentials) |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.ClientCredentials); |
|||
} |
|||
|
|||
if (grantType == OpenIddictConstants.GrantTypes.Implicit) |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.Implicit); |
|||
} |
|||
|
|||
if (grantType == OpenIddictConstants.GrantTypes.Password) |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.Password); |
|||
} |
|||
|
|||
if (grantType == OpenIddictConstants.GrantTypes.RefreshToken) |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.RefreshToken); |
|||
} |
|||
|
|||
if (grantType == OpenIddictConstants.GrantTypes.Implicit) |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.IdToken); |
|||
if (string.Equals(type, OpenIddictConstants.ClientTypes.Public, StringComparison.OrdinalIgnoreCase)) |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.IdTokenToken); |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.Token); |
|||
} |
|||
} |
|||
} |
|||
|
|||
var buildInScopes = new [] |
|||
{ |
|||
OpenIddictConstants.Permissions.Scopes.Address, |
|||
OpenIddictConstants.Permissions.Scopes.Email, |
|||
OpenIddictConstants.Permissions.Scopes.Phone, |
|||
OpenIddictConstants.Permissions.Scopes.Profile, |
|||
OpenIddictConstants.Permissions.Scopes.Roles |
|||
}; |
|||
|
|||
foreach (var scope in scopes) |
|||
{ |
|||
if (buildInScopes.Contains(scope)) |
|||
{ |
|||
application.Permissions.Add(scope); |
|||
} |
|||
else |
|||
{ |
|||
application.Permissions.Add(OpenIddictConstants.Permissions.Prefixes.Scope + scope); |
|||
} |
|||
} |
|||
|
|||
if (redirectUri != null) |
|||
{ |
|||
if (!redirectUri.IsNullOrEmpty()) |
|||
{ |
|||
if (!Uri.TryCreate(redirectUri, UriKind.Absolute, out var uri) || !uri.IsWellFormedOriginalString()) |
|||
{ |
|||
throw new BusinessException(L["InvalidRedirectUri", redirectUri]); |
|||
} |
|||
|
|||
if (application.RedirectUris.All(x => x != uri)) |
|||
{ |
|||
application.RedirectUris.Add(uri); |
|||
} |
|||
} |
|||
} |
|||
|
|||
if (postLogoutRedirectUri != null) |
|||
{ |
|||
if (!postLogoutRedirectUri.IsNullOrEmpty()) |
|||
{ |
|||
if (!Uri.TryCreate(postLogoutRedirectUri, UriKind.Absolute, out var uri) || !uri.IsWellFormedOriginalString()) |
|||
{ |
|||
throw new BusinessException(L["InvalidPostLogoutRedirectUri", postLogoutRedirectUri]); |
|||
} |
|||
|
|||
if (application.PostLogoutRedirectUris.All(x => x != uri)) |
|||
{ |
|||
application.PostLogoutRedirectUris.Add(uri); |
|||
} |
|||
} |
|||
} |
|||
|
|||
if (permissions != null) |
|||
{ |
|||
await _permissionDataSeeder.SeedAsync( |
|||
ClientPermissionValueProvider.ProviderName, |
|||
name, |
|||
permissions, |
|||
null |
|||
); |
|||
} |
|||
|
|||
await _applicationManager.CreateAsync(application); |
|||
} |
|||
} |
|||
} |
|||
File diff suppressed because it is too large
@ -0,0 +1,623 @@ |
|||
using System; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
#nullable disable |
|||
|
|||
namespace MyCompanyName.MyProjectName.Migrations |
|||
{ |
|||
public partial class Removed_IdentityServer : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropTable( |
|||
name: "IdentityServerApiResourceClaims"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "IdentityServerApiResourceProperties"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "IdentityServerApiResourceScopes"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "IdentityServerApiResourceSecrets"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "IdentityServerApiScopeClaims"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "IdentityServerApiScopeProperties"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "IdentityServerClientClaims"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "IdentityServerClientCorsOrigins"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "IdentityServerClientGrantTypes"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "IdentityServerClientIdPRestrictions"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "IdentityServerClientPostLogoutRedirectUris"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "IdentityServerClientProperties"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "IdentityServerClientRedirectUris"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "IdentityServerClientScopes"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "IdentityServerClientSecrets"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "IdentityServerDeviceFlowCodes"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "IdentityServerIdentityResourceClaims"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "IdentityServerIdentityResourceProperties"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "IdentityServerPersistedGrants"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "IdentityServerApiResources"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "IdentityServerApiScopes"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "IdentityServerClients"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "IdentityServerIdentityResources"); |
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.CreateTable( |
|||
name: "IdentityServerApiResources", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
|||
AllowedAccessTokenSigningAlgorithms = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true), |
|||
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true), |
|||
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false), |
|||
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
DeleterId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true), |
|||
Description = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true), |
|||
DisplayName = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true), |
|||
Enabled = table.Column<bool>(type: "bit", nullable: false), |
|||
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
IsDeleted = table.Column<bool>(type: "bit", nullable: false, defaultValue: false), |
|||
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true), |
|||
LastModifierId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
Name = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false), |
|||
ShowInDiscoveryDocument = table.Column<bool>(type: "bit", nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_IdentityServerApiResources", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "IdentityServerApiScopes", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
|||
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true), |
|||
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false), |
|||
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
DeleterId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true), |
|||
Description = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true), |
|||
DisplayName = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true), |
|||
Emphasize = table.Column<bool>(type: "bit", nullable: false), |
|||
Enabled = table.Column<bool>(type: "bit", nullable: false), |
|||
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
IsDeleted = table.Column<bool>(type: "bit", nullable: false, defaultValue: false), |
|||
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true), |
|||
LastModifierId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
Name = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false), |
|||
Required = table.Column<bool>(type: "bit", nullable: false), |
|||
ShowInDiscoveryDocument = table.Column<bool>(type: "bit", nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_IdentityServerApiScopes", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "IdentityServerClients", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
|||
AbsoluteRefreshTokenLifetime = table.Column<int>(type: "int", nullable: false), |
|||
AccessTokenLifetime = table.Column<int>(type: "int", nullable: false), |
|||
AccessTokenType = table.Column<int>(type: "int", nullable: false), |
|||
AllowAccessTokensViaBrowser = table.Column<bool>(type: "bit", nullable: false), |
|||
AllowOfflineAccess = table.Column<bool>(type: "bit", nullable: false), |
|||
AllowPlainTextPkce = table.Column<bool>(type: "bit", nullable: false), |
|||
AllowRememberConsent = table.Column<bool>(type: "bit", nullable: false), |
|||
AllowedIdentityTokenSigningAlgorithms = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true), |
|||
AlwaysIncludeUserClaimsInIdToken = table.Column<bool>(type: "bit", nullable: false), |
|||
AlwaysSendClientClaims = table.Column<bool>(type: "bit", nullable: false), |
|||
AuthorizationCodeLifetime = table.Column<int>(type: "int", nullable: false), |
|||
BackChannelLogoutSessionRequired = table.Column<bool>(type: "bit", nullable: false), |
|||
BackChannelLogoutUri = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: true), |
|||
ClientClaimsPrefix = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true), |
|||
ClientId = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false), |
|||
ClientName = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true), |
|||
ClientUri = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: true), |
|||
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true), |
|||
ConsentLifetime = table.Column<int>(type: "int", nullable: true), |
|||
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false), |
|||
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
DeleterId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true), |
|||
Description = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true), |
|||
DeviceCodeLifetime = table.Column<int>(type: "int", nullable: false), |
|||
EnableLocalLogin = table.Column<bool>(type: "bit", nullable: false), |
|||
Enabled = table.Column<bool>(type: "bit", nullable: false), |
|||
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
FrontChannelLogoutSessionRequired = table.Column<bool>(type: "bit", nullable: false), |
|||
FrontChannelLogoutUri = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: true), |
|||
IdentityTokenLifetime = table.Column<int>(type: "int", nullable: false), |
|||
IncludeJwtId = table.Column<bool>(type: "bit", nullable: false), |
|||
IsDeleted = table.Column<bool>(type: "bit", nullable: false, defaultValue: false), |
|||
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true), |
|||
LastModifierId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
LogoUri = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: true), |
|||
PairWiseSubjectSalt = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true), |
|||
ProtocolType = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false), |
|||
RefreshTokenExpiration = table.Column<int>(type: "int", nullable: false), |
|||
RefreshTokenUsage = table.Column<int>(type: "int", nullable: false), |
|||
RequireClientSecret = table.Column<bool>(type: "bit", nullable: false), |
|||
RequireConsent = table.Column<bool>(type: "bit", nullable: false), |
|||
RequirePkce = table.Column<bool>(type: "bit", nullable: false), |
|||
RequireRequestObject = table.Column<bool>(type: "bit", nullable: false), |
|||
SlidingRefreshTokenLifetime = table.Column<int>(type: "int", nullable: false), |
|||
UpdateAccessTokenClaimsOnRefresh = table.Column<bool>(type: "bit", nullable: false), |
|||
UserCodeType = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true), |
|||
UserSsoLifetime = table.Column<int>(type: "int", nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_IdentityServerClients", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "IdentityServerDeviceFlowCodes", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
|||
ClientId = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false), |
|||
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true), |
|||
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false), |
|||
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
Data = table.Column<string>(type: "nvarchar(max)", maxLength: 50000, nullable: false), |
|||
Description = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true), |
|||
DeviceCode = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false), |
|||
Expiration = table.Column<DateTime>(type: "datetime2", nullable: false), |
|||
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
SessionId = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true), |
|||
SubjectId = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true), |
|||
UserCode = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_IdentityServerDeviceFlowCodes", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "IdentityServerIdentityResources", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
|||
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true), |
|||
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false), |
|||
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
DeleterId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true), |
|||
Description = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true), |
|||
DisplayName = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true), |
|||
Emphasize = table.Column<bool>(type: "bit", nullable: false), |
|||
Enabled = table.Column<bool>(type: "bit", nullable: false), |
|||
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
IsDeleted = table.Column<bool>(type: "bit", nullable: false, defaultValue: false), |
|||
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true), |
|||
LastModifierId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
Name = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false), |
|||
Required = table.Column<bool>(type: "bit", nullable: false), |
|||
ShowInDiscoveryDocument = table.Column<bool>(type: "bit", nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_IdentityServerIdentityResources", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "IdentityServerPersistedGrants", |
|||
columns: table => new |
|||
{ |
|||
Key = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false), |
|||
ClientId = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false), |
|||
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true), |
|||
ConsumedTime = table.Column<DateTime>(type: "datetime2", nullable: true), |
|||
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false), |
|||
Data = table.Column<string>(type: "nvarchar(max)", maxLength: 50000, nullable: false), |
|||
Description = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true), |
|||
Expiration = table.Column<DateTime>(type: "datetime2", nullable: true), |
|||
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
|||
SessionId = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true), |
|||
SubjectId = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true), |
|||
Type = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_IdentityServerPersistedGrants", x => x.Key); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "IdentityServerApiResourceClaims", |
|||
columns: table => new |
|||
{ |
|||
ApiResourceId = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
|||
Type = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_IdentityServerApiResourceClaims", x => new { x.ApiResourceId, x.Type }); |
|||
table.ForeignKey( |
|||
name: "FK_IdentityServerApiResourceClaims_IdentityServerApiResources_ApiResourceId", |
|||
column: x => x.ApiResourceId, |
|||
principalTable: "IdentityServerApiResources", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "IdentityServerApiResourceProperties", |
|||
columns: table => new |
|||
{ |
|||
ApiResourceId = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
|||
Key = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false), |
|||
Value = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_IdentityServerApiResourceProperties", x => new { x.ApiResourceId, x.Key, x.Value }); |
|||
table.ForeignKey( |
|||
name: "FK_IdentityServerApiResourceProperties_IdentityServerApiResources_ApiResourceId", |
|||
column: x => x.ApiResourceId, |
|||
principalTable: "IdentityServerApiResources", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "IdentityServerApiResourceScopes", |
|||
columns: table => new |
|||
{ |
|||
ApiResourceId = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
|||
Scope = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_IdentityServerApiResourceScopes", x => new { x.ApiResourceId, x.Scope }); |
|||
table.ForeignKey( |
|||
name: "FK_IdentityServerApiResourceScopes_IdentityServerApiResources_ApiResourceId", |
|||
column: x => x.ApiResourceId, |
|||
principalTable: "IdentityServerApiResources", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "IdentityServerApiResourceSecrets", |
|||
columns: table => new |
|||
{ |
|||
ApiResourceId = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
|||
Type = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false), |
|||
Value = table.Column<string>(type: "nvarchar(4000)", maxLength: 4000, nullable: false), |
|||
Description = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true), |
|||
Expiration = table.Column<DateTime>(type: "datetime2", nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_IdentityServerApiResourceSecrets", x => new { x.ApiResourceId, x.Type, x.Value }); |
|||
table.ForeignKey( |
|||
name: "FK_IdentityServerApiResourceSecrets_IdentityServerApiResources_ApiResourceId", |
|||
column: x => x.ApiResourceId, |
|||
principalTable: "IdentityServerApiResources", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "IdentityServerApiScopeClaims", |
|||
columns: table => new |
|||
{ |
|||
ApiScopeId = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
|||
Type = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_IdentityServerApiScopeClaims", x => new { x.ApiScopeId, x.Type }); |
|||
table.ForeignKey( |
|||
name: "FK_IdentityServerApiScopeClaims_IdentityServerApiScopes_ApiScopeId", |
|||
column: x => x.ApiScopeId, |
|||
principalTable: "IdentityServerApiScopes", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "IdentityServerApiScopeProperties", |
|||
columns: table => new |
|||
{ |
|||
ApiScopeId = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
|||
Key = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false), |
|||
Value = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_IdentityServerApiScopeProperties", x => new { x.ApiScopeId, x.Key, x.Value }); |
|||
table.ForeignKey( |
|||
name: "FK_IdentityServerApiScopeProperties_IdentityServerApiScopes_ApiScopeId", |
|||
column: x => x.ApiScopeId, |
|||
principalTable: "IdentityServerApiScopes", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "IdentityServerClientClaims", |
|||
columns: table => new |
|||
{ |
|||
ClientId = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
|||
Type = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false), |
|||
Value = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_IdentityServerClientClaims", x => new { x.ClientId, x.Type, x.Value }); |
|||
table.ForeignKey( |
|||
name: "FK_IdentityServerClientClaims_IdentityServerClients_ClientId", |
|||
column: x => x.ClientId, |
|||
principalTable: "IdentityServerClients", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "IdentityServerClientCorsOrigins", |
|||
columns: table => new |
|||
{ |
|||
ClientId = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
|||
Origin = table.Column<string>(type: "nvarchar(150)", maxLength: 150, nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_IdentityServerClientCorsOrigins", x => new { x.ClientId, x.Origin }); |
|||
table.ForeignKey( |
|||
name: "FK_IdentityServerClientCorsOrigins_IdentityServerClients_ClientId", |
|||
column: x => x.ClientId, |
|||
principalTable: "IdentityServerClients", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "IdentityServerClientGrantTypes", |
|||
columns: table => new |
|||
{ |
|||
ClientId = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
|||
GrantType = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_IdentityServerClientGrantTypes", x => new { x.ClientId, x.GrantType }); |
|||
table.ForeignKey( |
|||
name: "FK_IdentityServerClientGrantTypes_IdentityServerClients_ClientId", |
|||
column: x => x.ClientId, |
|||
principalTable: "IdentityServerClients", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "IdentityServerClientIdPRestrictions", |
|||
columns: table => new |
|||
{ |
|||
ClientId = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
|||
Provider = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_IdentityServerClientIdPRestrictions", x => new { x.ClientId, x.Provider }); |
|||
table.ForeignKey( |
|||
name: "FK_IdentityServerClientIdPRestrictions_IdentityServerClients_ClientId", |
|||
column: x => x.ClientId, |
|||
principalTable: "IdentityServerClients", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "IdentityServerClientPostLogoutRedirectUris", |
|||
columns: table => new |
|||
{ |
|||
ClientId = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
|||
PostLogoutRedirectUri = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_IdentityServerClientPostLogoutRedirectUris", x => new { x.ClientId, x.PostLogoutRedirectUri }); |
|||
table.ForeignKey( |
|||
name: "FK_IdentityServerClientPostLogoutRedirectUris_IdentityServerClients_ClientId", |
|||
column: x => x.ClientId, |
|||
principalTable: "IdentityServerClients", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "IdentityServerClientProperties", |
|||
columns: table => new |
|||
{ |
|||
ClientId = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
|||
Key = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false), |
|||
Value = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_IdentityServerClientProperties", x => new { x.ClientId, x.Key, x.Value }); |
|||
table.ForeignKey( |
|||
name: "FK_IdentityServerClientProperties_IdentityServerClients_ClientId", |
|||
column: x => x.ClientId, |
|||
principalTable: "IdentityServerClients", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "IdentityServerClientRedirectUris", |
|||
columns: table => new |
|||
{ |
|||
ClientId = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
|||
RedirectUri = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_IdentityServerClientRedirectUris", x => new { x.ClientId, x.RedirectUri }); |
|||
table.ForeignKey( |
|||
name: "FK_IdentityServerClientRedirectUris_IdentityServerClients_ClientId", |
|||
column: x => x.ClientId, |
|||
principalTable: "IdentityServerClients", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "IdentityServerClientScopes", |
|||
columns: table => new |
|||
{ |
|||
ClientId = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
|||
Scope = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_IdentityServerClientScopes", x => new { x.ClientId, x.Scope }); |
|||
table.ForeignKey( |
|||
name: "FK_IdentityServerClientScopes_IdentityServerClients_ClientId", |
|||
column: x => x.ClientId, |
|||
principalTable: "IdentityServerClients", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "IdentityServerClientSecrets", |
|||
columns: table => new |
|||
{ |
|||
ClientId = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
|||
Type = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false), |
|||
Value = table.Column<string>(type: "nvarchar(4000)", maxLength: 4000, nullable: false), |
|||
Description = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: true), |
|||
Expiration = table.Column<DateTime>(type: "datetime2", nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_IdentityServerClientSecrets", x => new { x.ClientId, x.Type, x.Value }); |
|||
table.ForeignKey( |
|||
name: "FK_IdentityServerClientSecrets_IdentityServerClients_ClientId", |
|||
column: x => x.ClientId, |
|||
principalTable: "IdentityServerClients", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "IdentityServerIdentityResourceClaims", |
|||
columns: table => new |
|||
{ |
|||
IdentityResourceId = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
|||
Type = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_IdentityServerIdentityResourceClaims", x => new { x.IdentityResourceId, x.Type }); |
|||
table.ForeignKey( |
|||
name: "FK_IdentityServerIdentityResourceClaims_IdentityServerIdentityResources_IdentityResourceId", |
|||
column: x => x.IdentityResourceId, |
|||
principalTable: "IdentityServerIdentityResources", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "IdentityServerIdentityResourceProperties", |
|||
columns: table => new |
|||
{ |
|||
IdentityResourceId = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
|||
Key = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false), |
|||
Value = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_IdentityServerIdentityResourceProperties", x => new { x.IdentityResourceId, x.Key, x.Value }); |
|||
table.ForeignKey( |
|||
name: "FK_IdentityServerIdentityResourceProperties_IdentityServerIdentityResources_IdentityResourceId", |
|||
column: x => x.IdentityResourceId, |
|||
principalTable: "IdentityServerIdentityResources", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
}); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_IdentityServerClients_ClientId", |
|||
table: "IdentityServerClients", |
|||
column: "ClientId"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_IdentityServerDeviceFlowCodes_DeviceCode", |
|||
table: "IdentityServerDeviceFlowCodes", |
|||
column: "DeviceCode", |
|||
unique: true); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_IdentityServerDeviceFlowCodes_Expiration", |
|||
table: "IdentityServerDeviceFlowCodes", |
|||
column: "Expiration"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_IdentityServerDeviceFlowCodes_UserCode", |
|||
table: "IdentityServerDeviceFlowCodes", |
|||
column: "UserCode"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_IdentityServerPersistedGrants_Expiration", |
|||
table: "IdentityServerPersistedGrants", |
|||
column: "Expiration"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_IdentityServerPersistedGrants_SubjectId_ClientId_Type", |
|||
table: "IdentityServerPersistedGrants", |
|||
columns: new[] { "SubjectId", "ClientId", "Type" }); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_IdentityServerPersistedGrants_SubjectId_SessionId_Type", |
|||
table: "IdentityServerPersistedGrants", |
|||
columns: new[] { "SubjectId", "SessionId", "Type" }); |
|||
} |
|||
} |
|||
} |
|||
File diff suppressed because it is too large
@ -0,0 +1,189 @@ |
|||
using System; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
#nullable disable |
|||
|
|||
namespace MyCompanyName.MyProjectName.Migrations |
|||
{ |
|||
public partial class Installed_OpenIddict_Module : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.CreateTable( |
|||
name: "OpenIddictApplications", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
|||
ClientId = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true), |
|||
ClientSecret = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
ConsentType = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true), |
|||
DisplayName = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
DisplayNames = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
Permissions = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
PostLogoutRedirectUris = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
Properties = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
RedirectUris = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
Requirements = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
Type = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true), |
|||
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true), |
|||
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false), |
|||
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true), |
|||
LastModifierId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
IsDeleted = table.Column<bool>(type: "bit", nullable: false, defaultValue: false), |
|||
DeleterId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_OpenIddictApplications", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "OpenIddictScopes", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
|||
Description = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
Descriptions = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
DisplayName = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
DisplayNames = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
Name = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true), |
|||
Properties = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
Resources = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true), |
|||
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false), |
|||
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true), |
|||
LastModifierId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
IsDeleted = table.Column<bool>(type: "bit", nullable: false, defaultValue: false), |
|||
DeleterId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_OpenIddictScopes", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "OpenIddictAuthorizations", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
|||
ApplicationId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: true), |
|||
Properties = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
Scopes = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
Status = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true), |
|||
Subject = table.Column<string>(type: "nvarchar(400)", maxLength: 400, nullable: true), |
|||
Type = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true), |
|||
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true), |
|||
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false), |
|||
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true), |
|||
LastModifierId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
IsDeleted = table.Column<bool>(type: "bit", nullable: false, defaultValue: false), |
|||
DeleterId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_OpenIddictAuthorizations", x => x.Id); |
|||
table.ForeignKey( |
|||
name: "FK_OpenIddictAuthorizations_OpenIddictApplications_ApplicationId", |
|||
column: x => x.ApplicationId, |
|||
principalTable: "OpenIddictApplications", |
|||
principalColumn: "Id"); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "OpenIddictTokens", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
|||
ApplicationId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
AuthorizationId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: true), |
|||
ExpirationDate = table.Column<DateTime>(type: "datetime2", nullable: true), |
|||
Payload = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
Properties = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
RedemptionDate = table.Column<DateTime>(type: "datetime2", nullable: true), |
|||
ReferenceId = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true), |
|||
Status = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true), |
|||
Subject = table.Column<string>(type: "nvarchar(400)", maxLength: 400, nullable: true), |
|||
Type = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true), |
|||
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true), |
|||
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false), |
|||
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true), |
|||
LastModifierId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
IsDeleted = table.Column<bool>(type: "bit", nullable: false, defaultValue: false), |
|||
DeleterId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_OpenIddictTokens", x => x.Id); |
|||
table.ForeignKey( |
|||
name: "FK_OpenIddictTokens_OpenIddictApplications_ApplicationId", |
|||
column: x => x.ApplicationId, |
|||
principalTable: "OpenIddictApplications", |
|||
principalColumn: "Id"); |
|||
table.ForeignKey( |
|||
name: "FK_OpenIddictTokens_OpenIddictAuthorizations_AuthorizationId", |
|||
column: x => x.AuthorizationId, |
|||
principalTable: "OpenIddictAuthorizations", |
|||
principalColumn: "Id"); |
|||
}); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_OpenIddictApplications_ClientId", |
|||
table: "OpenIddictApplications", |
|||
column: "ClientId"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_OpenIddictAuthorizations_ApplicationId_Status_Subject_Type", |
|||
table: "OpenIddictAuthorizations", |
|||
columns: new[] { "ApplicationId", "Status", "Subject", "Type" }); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_OpenIddictScopes_Name", |
|||
table: "OpenIddictScopes", |
|||
column: "Name"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_OpenIddictTokens_ApplicationId_Status_Subject_Type", |
|||
table: "OpenIddictTokens", |
|||
columns: new[] { "ApplicationId", "Status", "Subject", "Type" }); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_OpenIddictTokens_AuthorizationId", |
|||
table: "OpenIddictTokens", |
|||
column: "AuthorizationId"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_OpenIddictTokens_ReferenceId", |
|||
table: "OpenIddictTokens", |
|||
column: "ReferenceId"); |
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropTable( |
|||
name: "OpenIddictScopes"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "OpenIddictTokens"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "OpenIddictAuthorizations"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "OpenIddictApplications"); |
|||
} |
|||
} |
|||
} |
|||
File diff suppressed because it is too large
@ -1 +0,0 @@ |
|||
{"KeyId":"600caa200caf5d805eba9f06ace9e236","Parameters":{"D":"KCNDHA96eimN+UqchSKocgYITGflaAIwxzCS5KqSTkYAFliPthQx7LySuLor4F1+uLvwnh3ZocyI3y43GZu+eVHD256sxdV8/UsQz1HC23RRFqcUiAZjze8K5VMVStrBOxaa/Ds1U9/bpuNE7jZdcgFIEHsdZtCACqwtlE4nlIs1/GLiokqjBOESgxJMy9WUeDbWcvoo+YdwgKf5jt6AZHOYSS+TokLL+Y7TEfGMXe3jZD9VtSMkBSM8wGB89zNGR0FZB9maCG/BCoRJqxdYRyeb4FFXJclQtK3DexyDVqlNZQaNKVHu0tVAnVNKKcd7Iex8gA+5DNqqucUA7C/F6Q==","DP":"fr9iaNb1W4YZ/NJ56+N3SCeDQYuKobq1qeaQWmHlQsOHKoHhNZJQZ5x0M9PQilou16AwVlNGCJncMwxsSUxXn6itG0LcBnvfMeo2v3xKcij1BtFR9qfXecwEn2nnhI3mpXtZxyCdP3NIYUp9qViLJUjGJqrbQk+OIAGRQd2rRe0=","DQ":"o1umLkDodtwvpCsDguQYSjd3iob+WHNmfe/9HyjADmUehP8b9SpUgcrb+QF301J8YmQMnYZKWW5rEwKOtwsWNswgXfMnXeWerlZmz0tj9y38YczS70liU0vETsRefhrRCaXHraMvneqYNNedhsrCNalWK+DNwcixi4L59vA8ofs=","Exponent":"AQAB","InverseQ":"btd1nwwxl/E3ryfDi2bN12TuVDvv7yoPvryIlLgu+FiLpe4vaA1omDLliQBcl7oeyA563HBUop4D5oE7si+jD64N8XgFz37dD3KqUokeQ4lrTSSOePT1K+nWIl30sqDd7YE4auz4CvSjm2wXmN31+CXW1hp3YWN2972yrUt+R5U=","Modulus":"uwMB6reAVtm/Cq0BRPZ0ozBq6g3wDh2kzqFKBf8I7u8d9p7i5ExLSrOWPupHwPr/IW1VUn2TKHrJ8OnyYhznKIRxqlxj0U3D2GXijz5kfFOoHK+mlfKaDMqweRoS0UzEz58kMlgwUoDraUj6dTHTPCVPo3TqA2ImRw50j6D+jobFrY5321EFvlirZViMPDAgB8Ca7wGCqNBcCxvIPYw1O6WZmcVmjG7umelD3XjcUIQlEbIyAmi/3gXAo7NdPmgOamla6bnSWsy429HfsNpXyCfPBzV3QS3ubpTekWPoPcOVZbWwVPYtFQbhRh8PmWATRx0cV6oePZNZGxGeJl8WYQ==","P":"wplelBfVmiOPmr6iUxtOgIzuvwSqvP6Rqmh8dhaGDiJjU8OqZ0tZhuh0G+xnMLPIHb2fMeg0dqZMJZ5iXaIi1QycYn/JKz1i4cUonJ6IIQeKKf67tvzn/BY0V0N8rJw8hVfzou+/5sRBCbiHtJ2KIN1YJQuWGFFfrZJOJzc95ss=","Q":"9gTGKoDiOdrY8kqIXJ2nMhoeNryAH4q3EUrROJ7simqc28oYlGx24Sco/wOoeB2xxrdcF5JYOlyJ7H2YY/huLvJISaw/wHLPskiKiYQ78tuNwW0ip+5ceB1dSToHcEe3sR30+OeTh0Z4ZKoqthKziFGIt3EhEgiGq1gjZuWB5gM="}} |
|||
@ -0,0 +1,4 @@ |
|||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. |
|||
# yarn lockfile v1 |
|||
|
|||
|
|||
@ -1 +0,0 @@ |
|||
{"KeyId":"5eb863b25811a7099f9bc925c0fdf680","Parameters":{"D":"gqn7NAeMkug4twJJHFz/qPseDzQCx7R+6Maj649xrG4vPsMANV9mfR78Er2SuHUS0ZihM2MQEILI5Sf41Uuubv8swCNSE3Dw7GQrBIbTAJ7BZKbQMVgtGkMDtHrtri6d9cOi3EOTSJINICk9r80M49oBMOZihEKascfBSIUYVQvWLEMYfryEiDeFUPbobr10OxF5tZ1unvEKgZe190BdNKWQuFhJelcgsZumjEYNsOz5DHrK73WLhfTy01DmsTKx8i1XVnLtq6W89MqAhMZP9QO9Vj8lR0ANnmdOsY6hJfwUbXiI36t4V9rAZvXR5ESorjb4mnXzT6QPuOfy1fbdSQ==","DP":"ItYIpEqw6aDjDc/swDifUe0Dq6yl4yim3UyQ4B9NBPQR5M6b7D3vbCnvwql4zJK4s+0N4lRViBtkF+20Td1yc2v8S+THCYZCVxCf2e9Q7Ff/sKecJ9/JmdzHkztCfs0xb+4X3CPEQP+JIYtMGmwOLQgE5XgmUYKr0ahZDhYTCwE=","DQ":"v35mgxfyF/nwnWwWlR9cF3mg0v7SyPfKkwdxGaVnGH6G8nPWpPlO+zueflA5QDXEwGtk/1k3PAzI/OLUwJiKBubx/UMhsqt5+/bKTrFDNHxLANCvGNZggMZIzFZBYRucuXRZbiBe5qpCkKkniUct7w6jd/V1mnsESiJZ7btcxU0=","Exponent":"AQAB","InverseQ":"Vbg2a+wtaYvhTV8AzqJsVvaz0kfC4HFbmwEgA8+BAbS3GEoS3RHFSfB3DHndpnNihIg72DctDNLmV2GMMiTu18uyI+7AUaYNR836fByxptfyhPtSQfw4kINZ3V0GWKJGzzZ5NAOct4/FpRl8xliHetayCfUIuK9jwk0z9i6V6bA=","Modulus":"xlzmN1sBi2V1971MsPD5MTND9dAGncIzYqxa3H+9jx1mNDivY6JgKijUWm5a3D2Y1UPMB3kx6qUf3iH6pZHjq5bk938qRhxrPy9muW55U03HTiW4V5/ga0+OqXj5Tj4lz+29OiQHPErxLRgfXT+WBgrGb75ElzkHajKpJnPgzAZuarlUCwupJNQlav/crwOFrgkhGsnaOW13M8htiSLZozw5lxkbhYIei7YTTQZ3l6rVH1dPL8CvzRJJOTwbnU8k0sUmWiuOhrLzuinlr6uuOTocAVgbj943/witVFtN5B0yhetxEVgFCwxRDTOO1EKVHFtCiAyZBUOlK4gwZ+SbGQ==","P":"7dFfbAkZSdx/ieSMYJHoY1DKC4dLg80RObEEmuJ72MaVJLTtFuBPoRpYOrMUNuupIyPjZZsW8fHRlPRhKW7xFv+Q2aDudh1UaJzFZs3xYKoiXTU/j0B3TB3nrifVLMqsS+8kHOWOojwA4dMjI6GCYCpKmYVvMOE1cuJrQ9EYxoM=","Q":"1YdN8mLchLVoTEwD34Pi3T2U7EjjBDgDCzhjl7x5FBG73TyKMz1n7/KXkXcJ2rqIAsnLqCWpYUeRcWl+IQEQxFKoMwkvmQ33lRkOE0SBZ+FnUAMivRyxOD5qM9z4ccqx0ga4ZRgb1lR85f7VYtMSfIosOuSFxWAbV1e29utxhTM="}} |
|||
@ -1 +0,0 @@ |
|||
{"KeyId":"ac0d2edf3c04d13cd95cc41b9b33ab03","Parameters":{"D":"FFymEWbX3XBT5YnTngOKwtz3XKsyaQbyDvvw9jbmkdvLKUmrb1hkmylqVYwU/3G1u79rrD8AZXJDoYVLegyZymK/iNeePMLI4i5vScF7PdQXn/g6CvQ8j3J60YYyfDWuxjBH8nCEUIfQIv14BpcH6CWi1BVZUbnbWcpe2ji8D5I3FHOZpvksQztst5eE836ODdN9jgk35kgrdUQ14MEFHA6m6fAzvFI1csFxD3Kwej4rI8RYZ0WYLkndz9ID88+v9VxqI8+wN6wR6tIOR510uT1FI5wONBVBUzgeZ6cCEpg0jC9tgqcP03gMDpmE7vKp34ExxH/iOWyhQ0gAxHOVlQ==","DP":"qSQfNZvEkepgY12d+uwTbRoOp+0g1CBiMU9kqyoIB56hAUnzENSCDzunjLRrvDLFPgXiUcoccskyVRnKKOGPOqPE6VjgzBrdLgA/hBf8hPg0GnTVoPyLxR9G6GsGUKsAYVn8G7cnK5wXzK4jCjsflkfxCzFfdASJ/+sa5QPWZMM=","DQ":"u+56T1+rhMvlurid9kBS2Ypfm4vOiNAXLD9kGz2wx8Ob0yYlWo55kn11qPs6Ej9bnQIY3N+TY2tXMamfhAhntoHaKrFjOpCmlHZ0GAeQOJVuWSlFvu/NBoxfjZzcUCNua22oJjy++wSdkkLLGEqau62byaQoSSqUxUzwL36RexM=","Exponent":"AQAB","InverseQ":"E+uq9g6D5LjUk+M7gtt0srnT8duwu8P83AgFqjtGOnSCy71omSboxb4zC9bGq/WaEFauFBwqxbkXwFyXuYNfIelfmSERulU9jgf0+KH6QmFdtjrJ5UO7VArqET1WUquwiDvOyO8udCxi8RRAiM5G3dTzIs5JTalGhlKEZSAgPtQ=","Modulus":"rgHACxzqvuE72RF/NdDTLsIEy3F/n6P4lkgrER60FU8uRNwSmAMRxvxYOaE3Ot/krRYcw2+MP8ewR1VBXywXVT1zuACA3SacMHJYmZQ2UkuwsD9bmpjvqoMhR/hjsI74jTzKpclHtEu7D7WYDZaIPAEIs/8+5H/z1mXVfgACaeaQt3C0OhwXSOPPDP71VKGfoFucXYED1keZ0PKxYAlhiHOe7cnSlfJseujwD2Rhyq8mUhe6aEMTYBjuruWgpfvnSOARAqu5vwzK35KpAirHwa1DJSZyanNMFdlLkVNKWUKEqd6PwRneiHacmaaDF6oQQstuSbf9cuJeSMbKh7WVQQ==","P":"0CJDit2NHk0Z1bN5ZVIYZRUYbrAI2bEOafAKqfffcA/Os7yXsY14Ye4pSpDxfdZGcPGRL04HPkJsogFtyI7k4ujrvsC66I5cg45+BhBMM0zyLJ7LZkD2HGwX2+a/xrXhhIIOnGWWy2zzW3dkayRhi1bR9krfTA5uBw1LX9qZ3Yc=","Q":"1gZITAaB+r0+PgOfyDCeVzSnTyQuKSkgbUkIgQP9jQZa6edrbAXogdJipxmUTrW7JaxifG1z9ubK+TOqhjZHqT4gd8U8Bh7jCBizZNVe60pez1OtNGpEOW2N+ZrXBSMNcV8PFaMg/B+fcaX+i7NWpTqmztR/V0DGXmD+XosuaPc="}} |
|||
@ -1 +0,0 @@ |
|||
{"KeyId":"ac0d2edf3c04d13cd95cc41b9b33ab03","Parameters":{"D":"FFymEWbX3XBT5YnTngOKwtz3XKsyaQbyDvvw9jbmkdvLKUmrb1hkmylqVYwU/3G1u79rrD8AZXJDoYVLegyZymK/iNeePMLI4i5vScF7PdQXn/g6CvQ8j3J60YYyfDWuxjBH8nCEUIfQIv14BpcH6CWi1BVZUbnbWcpe2ji8D5I3FHOZpvksQztst5eE836ODdN9jgk35kgrdUQ14MEFHA6m6fAzvFI1csFxD3Kwej4rI8RYZ0WYLkndz9ID88+v9VxqI8+wN6wR6tIOR510uT1FI5wONBVBUzgeZ6cCEpg0jC9tgqcP03gMDpmE7vKp34ExxH/iOWyhQ0gAxHOVlQ==","DP":"qSQfNZvEkepgY12d+uwTbRoOp+0g1CBiMU9kqyoIB56hAUnzENSCDzunjLRrvDLFPgXiUcoccskyVRnKKOGPOqPE6VjgzBrdLgA/hBf8hPg0GnTVoPyLxR9G6GsGUKsAYVn8G7cnK5wXzK4jCjsflkfxCzFfdASJ/+sa5QPWZMM=","DQ":"u+56T1+rhMvlurid9kBS2Ypfm4vOiNAXLD9kGz2wx8Ob0yYlWo55kn11qPs6Ej9bnQIY3N+TY2tXMamfhAhntoHaKrFjOpCmlHZ0GAeQOJVuWSlFvu/NBoxfjZzcUCNua22oJjy++wSdkkLLGEqau62byaQoSSqUxUzwL36RexM=","Exponent":"AQAB","InverseQ":"E+uq9g6D5LjUk+M7gtt0srnT8duwu8P83AgFqjtGOnSCy71omSboxb4zC9bGq/WaEFauFBwqxbkXwFyXuYNfIelfmSERulU9jgf0+KH6QmFdtjrJ5UO7VArqET1WUquwiDvOyO8udCxi8RRAiM5G3dTzIs5JTalGhlKEZSAgPtQ=","Modulus":"rgHACxzqvuE72RF/NdDTLsIEy3F/n6P4lkgrER60FU8uRNwSmAMRxvxYOaE3Ot/krRYcw2+MP8ewR1VBXywXVT1zuACA3SacMHJYmZQ2UkuwsD9bmpjvqoMhR/hjsI74jTzKpclHtEu7D7WYDZaIPAEIs/8+5H/z1mXVfgACaeaQt3C0OhwXSOPPDP71VKGfoFucXYED1keZ0PKxYAlhiHOe7cnSlfJseujwD2Rhyq8mUhe6aEMTYBjuruWgpfvnSOARAqu5vwzK35KpAirHwa1DJSZyanNMFdlLkVNKWUKEqd6PwRneiHacmaaDF6oQQstuSbf9cuJeSMbKh7WVQQ==","P":"0CJDit2NHk0Z1bN5ZVIYZRUYbrAI2bEOafAKqfffcA/Os7yXsY14Ye4pSpDxfdZGcPGRL04HPkJsogFtyI7k4ujrvsC66I5cg45+BhBMM0zyLJ7LZkD2HGwX2+a/xrXhhIIOnGWWy2zzW3dkayRhi1bR9krfTA5uBw1LX9qZ3Yc=","Q":"1gZITAaB+r0+PgOfyDCeVzSnTyQuKSkgbUkIgQP9jQZa6edrbAXogdJipxmUTrW7JaxifG1z9ubK+TOqhjZHqT4gd8U8Bh7jCBizZNVe60pez1OtNGpEOW2N+ZrXBSMNcV8PFaMg/B+fcaX+i7NWpTqmztR/V0DGXmD+XosuaPc="}} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue