/// <summary> /// Stores a new API resource /// </summary> /// <param name="resource"></param> /// <returns></returns> public async Task StoreAsync(ApiResource resource) { await _apiResources.InsertAsync(new ApiResourceEntity(resource.Name) { Description = resource.Description, DisplayName = resource.DisplayName, Enabled = resource.Enabled, }); foreach (var claim in resource.UserClaims) { await _apiResourceClaims.InsertAsync(new ApiResourceClaimEntity { Name = resource.Name, Claim = claim, }); } var secrets = resource.ApiSecrets.ToArray(); for (var index = 0; index < resource.ApiSecrets.Count; index++) { var secret = secrets[index]; await _apiSecrets.InsertAsync(new ApiSecretEntity { Name = resource.Name, Sequence = index, Description = secret.Description, Expiration = secret.Expiration, Value = secret.Value, Type = secret.Type, }); } foreach (var scope in resource.Scopes) { await _byScopes.InsertAsync(new ApiResourceNameByScope { Scope = scope.Name, Name = resource.Name, }); await _apiScopes.InsertAsync(new ApiScopeEntity { Name = resource.Name, Scope = scope.Name, Description = scope.Description, DisplayName = scope.DisplayName, Required = scope.Required, ShowInDiscoveryDocument = scope.ShowInDiscoveryDocument, }); foreach (var claim in scope.UserClaims) { await _apiScopeClaims.InsertAsync(new ApiScopeClaimEntity { Scope = $"{resource.Name}|{scope.Name}", Claim = claim, }); } } }
public async Task StoreAsync(IdentityResource resource) { await _identityResources.InsertAsync(new IdentityResourceEntity(resource.Name) { Description = resource.Description, DisplayName = resource.DisplayName, Enabled = resource.Enabled, Emphasize = resource.Emphasize, Required = resource.Required, ShowInDiscoveryDocument = resource.ShowInDiscoveryDocument, }); foreach (var claim in resource.UserClaims) { await _identityClaims.InsertAsync(new IdentityClaimEntity { Name = resource.Name, Claim = claim, }); } }
public async Task StoreAsync(Client client) { await _clients.InsertAsync(new ClientEntity { ClientId = client.ClientId, Enabled = client.Enabled, ProtocolType = client.ProtocolType, RequireClientSecret = client.RequireClientSecret, ClientName = client.ClientName, Description = client.Description, ClientUri = client.ClientUri, LogoUri = client.LogoUri, RequireConsent = client.RequireConsent, AllowRememberConsent = client.AllowRememberConsent, RequirePkce = client.RequirePkce, AllowPlainTextPkce = client.AllowPlainTextPkce, AllowAccessTokensViaBrowser = client.AllowAccessTokensViaBrowser, FrontChannelLogoutUri = client.FrontChannelLogoutUri, FrontChannelLogoutSessionRequired = client.FrontChannelLogoutSessionRequired, BackChannelLogoutUri = client.BackChannelLogoutUri, BackChannelLogoutSessionRequired = client.BackChannelLogoutSessionRequired, AllowOfflineAccess = client.AllowOfflineAccess, AlwaysIncludeUserClaimsInIdToken = client.AlwaysIncludeUserClaimsInIdToken, IdentityTokenLifetime = client.IdentityTokenLifetime, AccessTokenLifetime = client.AccessTokenLifetime, AuthorizationCodeLifetime = client.AuthorizationCodeLifetime, AbsoluteRefreshTokenLifetime = client.AbsoluteRefreshTokenLifetime, SlidingRefreshTokenLifetime = client.SlidingRefreshTokenLifetime, ConsentLifetime = client.ConsentLifetime, RefreshTokenUsage = client.RefreshTokenUsage, UpdateAccessTokenClaimsOnRefresh = client.UpdateAccessTokenClaimsOnRefresh, RefreshTokenExpiration = client.RefreshTokenExpiration, AccessTokenType = client.AccessTokenType, EnableLocalLogin = client.EnableLocalLogin, IncludeJwtId = client.IncludeJwtId, AlwaysSendClientClaims = client.AlwaysSendClientClaims, ClientClaimsPrefix = client.ClientClaimsPrefix, PairWiseSubjectSalt = client.PairWiseSubjectSalt, UserSsoLifetime = client.UserSsoLifetime, UserCodeType = client.UserCodeType, DeviceCodeLifetime = client.DeviceCodeLifetime, }); foreach (var claim in client.Claims) { await _claims.InsertAsync(new ClientClaimEntity { ClientId = client.ClientId, Type = claim.Type, Value = claim.Value, }); } foreach (var corsOrigin in client.AllowedCorsOrigins) { await _corsOrigins.InsertAsync(new ClientCorsOriginEntity { ClientId = client.ClientId, Origin = WebUtility.UrlEncode(corsOrigin), }); } foreach (var grantType in client.AllowedGrantTypes) { await _grantTypes.InsertAsync(new ClientGrantTypeEntity { ClientId = client.ClientId, GrantType = grantType, }); } foreach (var restriction in client.IdentityProviderRestrictions) { await _idPRestrictions.InsertAsync(new ClientIdPRestrictionEntity { ClientId = client.ClientId, Provider = restriction, }); } foreach (var redirectUri in client.PostLogoutRedirectUris) { await _postLogoutRedirectUris.InsertAsync(new ClientPostLogoutRedirectUriEntity { ClientId = client.ClientId, PostLogoutRedirectUri = WebUtility.UrlEncode(redirectUri), }); } foreach (var redirectUri in client.RedirectUris) { await _redirectUris.InsertAsync(new ClientRedirectUriEntity { ClientId = client.ClientId, RedirectUri = WebUtility.UrlEncode(redirectUri), }); } var secrets = client.ClientSecrets.ToArray(); for (var index = 0; index < client.ClientSecrets.Count; index++) { var secret = secrets[index]; await _secrets.InsertAsync(new ClientSecretEntity { ClientId = client.ClientId, Sequence = index, Description = secret.Description, Expiration = secret.Expiration, Type = secret.Type, Value = secret.Value, }); } foreach (var scope in client.AllowedScopes) { await _scopes.InsertAsync(new ClientScopeEntity { ClientId = client.ClientId, Scope = scope, }); } }