private static void SeedRelyingPartyClaimMappings(IAdminStore <Entity.RelyingPartyClaimMapping> relyingPartyClaimMappingStore, Entity.RelyingParty relyingParty) { if (relyingParty.ClaimMappings == null) { return; } foreach (var mapping in relyingParty.ClaimMappings) { try { relyingPartyClaimMappingStore.CreateAsync(new Entity.RelyingPartyClaimMapping { FromClaimType = mapping.FromClaimType, Id = Guid.NewGuid().ToString(), RelyingPartyId = relyingParty.Id, ToClaimType = mapping.ToClaimType }).GetAwaiter().GetResult(); } catch (ArgumentException) { // silent } } }
/// <summary> /// Initializes a new instance of the <see cref="UserOnlyStore"/> class. /// </summary> /// <param name="store"></param> /// <param name="claimStore"></param> /// <param name="loginStore"></param> /// <param name="tokenStore"></param> /// <param name="describer">The <see cref="T:Microsoft.AspNetCore.Identity.IdentityErrorDescriber" /> used to describe store errors.</param> public UserOnlyStore(IAdminStore <User> store, IAdminStore <UserClaim> claimStore, IAdminStore <UserLogin> loginStore, IAdminStore <UserToken> tokenStore, IdentityErrorDescriber describer = null) : base(store, claimStore, loginStore, tokenStore, describer) { }
/// <summary> /// Initializes a new instance of the <see cref="UserStore{TUser}"/> class. /// </summary> /// <param name="store">The store.</param> /// <param name="userRoleStore">The user role store.</param> /// <param name="userOnlyStore">The user only store.</param> /// <param name="describer">The <see cref="T:Microsoft.AspNetCore.Identity.IdentityErrorDescriber" /> used to describe store errors.</param> public UserStore(IAdminStore <Role> store, IAdminStore <UserRole> userRoleStore, UserOnlyStore <TUser> userOnlyStore, IdentityErrorDescriber describer = null) : base(store, userRoleStore, userOnlyStore, describer) { }
private async Task RemoveExpiredTokensAsync(IAdminStore store, IEnumerable <IGrant> items, CancellationToken cancellationToken) { foreach (var token in items) { await store.DeleteAsync(token.Id, cancellationToken).ConfigureAwait(false); } }
public StringLocalizer(IAdminStore <LocalizedResource> store, IReadOnlyCultureStore cultureStore, ILogger <StringLocalizer> logger) { _store = store ?? throw new ArgumentNullException(nameof(store)); _cultureStore = cultureStore ?? throw new ArgumentNullException(nameof(cultureStore)); Logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
/// <summary> /// Initializes a new instance of the <see cref="ExternalClaimsTransformer{TUser}"/> class. /// </summary> /// <param name="userManager">The user manager.</param> /// <param name="claimTransformationStore">The claim transformation store.</param> /// <param name="externalProviderStore">The external provider store.</param> /// <exception cref="ArgumentNullException"> /// userManager /// or /// claimTransformationStore /// or /// externalProviderStore /// </exception> public ExternalClaimsTransformer(UserManager <TUser> userManager, IAdminStore <ExternalClaimTransformation> claimTransformationStore, IAdminStore <ExternalProvider> externalProviderStore) { _userManager = userManager ?? throw new ArgumentNullException(nameof(userManager)); _claimTransformationStore = claimTransformationStore ?? throw new ArgumentNullException(nameof(claimTransformationStore)); _externalProviderStore = externalProviderStore ?? throw new ArgumentNullException(nameof(externalProviderStore)); }
public QuotaManager( StatelessServiceContext context, IAdminStore store, RedisClient cache) { this.context = context; this.store = store; this.cache = cache; }
public StringLocalizer(HttpClient client, ILogger <AdminStore <LocalizedResource> > resourceLogger, ILogger <AdminStore <Culture> > cultureLogger, ILogger <StringLocalizer> logger) { _store = new AdminStore <LocalizedResource>(Task.FromResult(client), resourceLogger); _cultureStore = new AdminStore <Culture>(Task.FromResult(client), cultureLogger); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
private static void SeedClientUris(IAdminStore <Entity.ClientUri> clientUriStore, IdentityServer4.Models.Client client) { var uris = client.RedirectUris.Select(o => new Entity.ClientUri { Id = Guid.NewGuid().ToString(), ClientId = client.ClientId, Uri = o }).ToList(); foreach (var origin in client.AllowedCorsOrigins) { var cors = new Uri(origin); var uri = uris.FirstOrDefault(u => cors.CorsMatch(u.Uri)); var corsUri = new Uri(origin); var sanetized = $"{corsUri.Scheme.ToUpperInvariant()}://{corsUri.Host.ToUpperInvariant()}:{corsUri.Port}"; if (uri == null) { uris.Add(new Entity.ClientUri { Id = Guid.NewGuid().ToString(), ClientId = client.ClientId, Uri = origin, Kind = Entity.UriKinds.Cors, SanetizedCorsUri = sanetized }); continue; } uri.SanetizedCorsUri = sanetized; uri.Kind = Entity.UriKinds.Redirect | Entity.UriKinds.Cors; } foreach (var postLogout in client.PostLogoutRedirectUris) { var uri = uris.FirstOrDefault(u => u.Uri == postLogout); if (uri == null) { uris.Add(new Entity.ClientUri { Id = Guid.NewGuid().ToString(), ClientId = client.ClientId, Uri = postLogout, Kind = Entity.UriKinds.PostLogout }); continue; } uri.Kind |= Entity.UriKinds.Redirect; } foreach (var uri in uris) { clientUriStore.CreateAsync(uri).GetAwaiter().GetResult(); } }
public OneTimeTokenService(IAdminStore <OneTimeToken> store, AuthenticationStateProvider state, IAccessTokenProvider provider, IOptions <RemoteAuthenticationOptions <OidcProviderOptions> > options) { _store = store ?? throw new ArgumentNullException(nameof(store)); _stateProvider = state ?? throw new ArgumentNullException(nameof(state)); _provider = provider ?? throw new ArgumentNullException(nameof(provider)); _options = options ?? throw new ArgumentNullException(nameof(options)); }
public ResourceStore(IAdminStore <ProtectResource> apiStore, IAdminStore <IdentityResource> identityStore, IAdminStore <ApiScope> apiScopeStore, IAdminStore <ApiApiScope> apiApiScopeStore) { _apiStore = apiStore ?? throw new ArgumentNullException(nameof(apiStore)); _identityStore = identityStore ?? throw new ArgumentNullException(nameof(identityStore)); _apiScopeStore = apiScopeStore ?? throw new ArgumentNullException(nameof(apiScopeStore)); _apiApiScopeStore = apiApiScopeStore ?? throw new ArgumentNullException(nameof(apiApiScopeStore)); }
/// <summary> /// Initializes a new instance of the <see cref="StringLocalizer"/> class. /// </summary> /// <param name="provider">The provider.</param> /// <param name="baseName">Name of the base.</param> /// <param name="location">The location.</param> /// <exception cref="ArgumentNullException">store</exception> public StringLocalizer(IServiceProvider provider, string baseName, string location) { _provider = provider ?? throw new ArgumentNullException(nameof(provider)); _scope = provider.CreateScope(); var p = _scope.ServiceProvider; _store = p.GetRequiredService <IAdminStore <LocalizedResource> >(); _baseName = baseName; _location = location; _logger = p.GetRequiredService <ILogger <StringLocalizer> >(); }
private static void SeedApiScopeClaims(IAdminStore <Entity.ApiScopeClaim> apiScopeClaimStore, Duende.IdentityServer.Models.ApiScope resource) { foreach (var claim in resource.UserClaims) { apiScopeClaimStore.CreateAsync(new Entity.ApiScopeClaim { ApiScopeId = resource.Name, Id = Guid.NewGuid().ToString(), Type = claim }).GetAwaiter().GetResult(); } }
private static void SeedIdentityClaims(IAdminStore <Entity.IdentityClaim> identityClaimStore, IdentityServer4.Models.IdentityResource resource) { foreach (var claim in resource.UserClaims) { identityClaimStore.CreateAsync(new Entity.IdentityClaim { Id = Guid.NewGuid().ToString(), IdentityId = resource.Name, Type = claim }).GetAwaiter().GetResult(); } }
private static void SeedClientScopes(IAdminStore <Entity.ClientScope> clientScopeStore, Duende.IdentityServer.Models.Client client) { foreach (var clientScope in client.AllowedScopes) { clientScopeStore.CreateAsync(new Entity.ClientScope { ClientId = client.ClientId, Scope = clientScope, Id = Guid.NewGuid().ToString() }).GetAwaiter().GetResult(); } }
/// <summary> /// Initializes a new instance of the <see cref="PersistedGrantService"/> class. /// </summary> /// <param name="authorizationCodeStore">The authorization code store.</param> /// <param name="userConsentStore">The user consent store.</param> /// <param name="refreshTokenStore">The refresh token store.</param> /// <param name="referenceTokenStore">The reference token store.</param> /// <param name="serializer">The serializer.</param> /// <exception cref="ArgumentNullException"> /// authorizationCodeStore /// or /// userConsentStore /// or /// refreshTokenStore /// or /// referenceTokenStore /// or /// serializer /// </exception> public PersistedGrantService(IAdminStore <Entity.AuthorizationCode> authorizationCodeStore, IAdminStore <Entity.UserConsent> userConsentStore, IAdminStore <Entity.RefreshToken> refreshTokenStore, IAdminStore <Entity.ReferenceToken> referenceTokenStore, IPersistentGrantSerializer serializer) { _authorizationCodeStore = authorizationCodeStore ?? throw new ArgumentNullException(nameof(authorizationCodeStore)); _userConsentStore = userConsentStore ?? throw new ArgumentNullException(nameof(userConsentStore)); _refreshTokenStore = refreshTokenStore ?? throw new ArgumentNullException(nameof(refreshTokenStore)); _referenceTokenStore = referenceTokenStore ?? throw new ArgumentNullException(nameof(referenceTokenStore)); _serializer = serializer ?? throw new ArgumentNullException(nameof(serializer)); }
private static void SeedClientGrantType(IAdminStore <Entity.ClientGrantType> clientGrantTypeStore, IdentityServer4.Models.Client client) { foreach (var grantType in client.AllowedGrantTypes) { clientGrantTypeStore.CreateAsync(new Entity.ClientGrantType { ClientId = client.ClientId, GrantType = grantType, Id = Guid.NewGuid().ToString() }).GetAwaiter().GetResult(); } }
private static void SeedApiApiScopes(IAdminStore <Entity.ApiApiScope> apiApiScopeStore, IdentityServer4.Models.ApiResource resource) { foreach (var apiScope in resource.Scopes) { apiApiScopeStore.CreateAsync(new Entity.ApiApiScope { ApiId = resource.Name, ApiScopeId = apiScope, Id = Guid.NewGuid().ToString() }).GetAwaiter().GetResult(); } }
private static void SeedClientRestrictions(IAdminStore <Entity.ClientIdpRestriction> clientIdpRestrictionStore, IdentityServer4.Models.Client client) { foreach (var restriction in client.IdentityProviderRestrictions) { clientIdpRestrictionStore.CreateAsync(new Entity.ClientIdpRestriction { ClientId = client.ClientId, Id = Guid.NewGuid().ToString(), Provider = restriction }).GetAwaiter().GetResult(); } }
private static void SeedApiProperties(IAdminStore <Entity.ApiProperty> apiPropertyStore, IdentityServer4.Models.ApiResource resource) { foreach (var property in resource.Properties) { apiPropertyStore.CreateAsync(new Entity.ApiProperty { ApiId = resource.Name, Id = Guid.NewGuid().ToString(), Key = property.Key, Value = property.Value }).GetAwaiter().GetResult(); } }
private static void SeedClientClaims(IAdminStore <Entity.ClientClaim> clientClaimStore, IdentityServer4.Models.Client client) { foreach (var claim in client.Claims) { clientClaimStore.CreateAsync(new Entity.ClientClaim { ClientId = client.ClientId, Id = Guid.NewGuid().ToString(), Type = claim.Type, Value = claim.Value }).GetAwaiter().GetResult(); } }
private static void SeedClientProperties(IAdminStore <Entity.ClientProperty> clientPropertyStore, IdentityServer4.Models.Client client) { foreach (var property in client.Properties) { clientPropertyStore.CreateAsync(new Entity.ClientProperty { ClientId = client.ClientId, Id = Guid.NewGuid().ToString(), Key = property.Key, Value = property.Value }).GetAwaiter().GetResult(); } }
private static void SeedIdentityProperties(IAdminStore <Entity.IdentityProperty> identityPropertyStore, Duende.IdentityServer.Models.IdentityResource resource) { foreach (var property in resource.Properties) { identityPropertyStore.CreateAsync(new Entity.IdentityProperty { Id = Guid.NewGuid().ToString(), IdentityId = resource.Name, Key = property.Key, Value = property.Value }).GetAwaiter().GetResult(); } }
private static void SeedClientSecrets(IAdminStore <Entity.ClientSecret> clientSecretStore, IdentityServer4.Models.Client client) { foreach (var secret in client.ClientSecrets) { clientSecretStore.CreateAsync(new Entity.ClientSecret { ClientId = client.ClientId, Description = secret.Description, Expiration = secret.Expiration, Id = Guid.NewGuid().ToString(), Type = secret.Type, Value = secret.Value }).GetAwaiter().GetResult(); } }
private static void SeedApiSecrets(IAdminStore <Entity.ApiSecret> apiSecretStore, IdentityServer4.Models.ApiResource resource) { foreach (var secret in resource.ApiSecrets) { apiSecretStore.CreateAsync(new Entity.ApiSecret { ApiId = resource.Name, Expiration = secret.Expiration, Description = secret.Description, Id = Guid.NewGuid().ToString(), Type = secret.Type, Value = secret.Value }).GetAwaiter().GetResult(); } }
/// <summary> /// Initializes a new instance of the <see cref="RegisterClientService" /> class. /// </summary> /// <param name="clientStore">The client store.</param> /// <param name="clientUriStore">The client URI store.</param> /// <param name="clientResourceStore">The client resource store.</param> /// <param name="clientGrantTypeStore">The client grant type store.</param> /// <param name="clientPropertyStore">The client property store.</param> /// <param name="discoveryResponseGenerator">The discovery response generator.</param> /// <param name="identityServerOptions">The options.</param> /// <param name="dymamicClientRegistrationOptions">The dymamic client registration options.</param> /// <exception cref="ArgumentNullException">options /// or /// clientStore /// or /// clientUriStore /// or /// clientResourceStore /// or /// clientPropertyStore /// or /// clientGrantTypeStore /// or /// discoveryResponseGenerator</exception> public RegisterClientService(IAdminStore <Client> clientStore, IAdminStore <ClientUri> clientUriStore, IAdminStore <ClientLocalizedResource> clientResourceStore, IAdminStore <ClientGrantType> clientGrantTypeStore, IAdminStore <ClientProperty> clientPropertyStore, IDiscoveryResponseGenerator discoveryResponseGenerator, IdentityServer4.Configuration.IdentityServerOptions identityServerOptions, IOptions <DynamicClientRegistrationOptions> dymamicClientRegistrationOptions) { _identityServerOptions1 = identityServerOptions ?? throw new ArgumentNullException(nameof(identityServerOptions)); _dymamicClientRegistrationOptions = dymamicClientRegistrationOptions?.Value ?? throw new ArgumentNullException(nameof(dymamicClientRegistrationOptions)); _clientStore = clientStore ?? throw new ArgumentNullException(nameof(clientStore)); _clientUriStore = clientUriStore ?? throw new ArgumentNullException(nameof(clientUriStore)); _clientResourceStore = clientResourceStore ?? throw new ArgumentNullException(nameof(clientResourceStore)); _clientPropertyStore = clientPropertyStore ?? throw new ArgumentNullException(nameof(clientPropertyStore)); _clientGrantTypeStore = clientGrantTypeStore ?? throw new ArgumentNullException(nameof(clientGrantTypeStore)); _discoveryResponseGenerator = discoveryResponseGenerator ?? throw new ArgumentNullException(nameof(discoveryResponseGenerator)); }
private static void SeedApiApiScopes(IAdminStore <Entity.ApiApiScope> apiApiScopeStore, ISModels.ApiResource resource) { foreach (var apiScope in resource.Scopes) { try { apiApiScopeStore.CreateAsync(new Entity.ApiApiScope { ApiId = resource.Name, ApiScopeId = apiScope, Id = Guid.NewGuid().ToString() }).GetAwaiter().GetResult(); } catch (ArgumentException) { // silent } } }
private static void SeedIdentityClaims(IAdminStore <Entity.IdentityClaim> identityClaimStore, ISModels.IdentityResource resource) { foreach (var claim in resource.UserClaims) { try { identityClaimStore.CreateAsync(new Entity.IdentityClaim { Id = Guid.NewGuid().ToString(), IdentityId = resource.Name, Type = claim }).GetAwaiter().GetResult(); } catch (ArgumentException) { // silent } } }
private static void SeedClientRestrictions(IAdminStore <Entity.ClientIdpRestriction> clientIdpRestrictionStore, ISModels.Client client) { foreach (var restriction in client.IdentityProviderRestrictions) { try { clientIdpRestrictionStore.CreateAsync(new Entity.ClientIdpRestriction { ClientId = client.ClientId, Id = Guid.NewGuid().ToString(), Provider = restriction }).GetAwaiter().GetResult(); } catch (ArgumentException) { // silent } } }
private static void SeedClientGrantType(IAdminStore <Entity.ClientGrantType> clientGrantTypeStore, ISModels.Client client) { foreach (var grantType in client.AllowedGrantTypes) { try { clientGrantTypeStore.CreateAsync(new Entity.ClientGrantType { ClientId = client.ClientId, GrantType = grantType, Id = Guid.NewGuid().ToString() }).GetAwaiter().GetResult(); } catch (ArgumentException) { // silent } } }