public async Task <IList <Neo4jIdentityServer4ClientRedirectUri> > GetRedirectUrisAsync( Neo4jIdentityServer4Client client, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); client.ThrowIfNull(nameof(client)); var cypher = $@" MATCH (client:{IdSrv4Client})-[:{Neo4jConstants.Relationships.HasRedirectUri}]->(red:{ IdSrv4ClientRedirectUri }) WHERE client.ClientId = $p0 RETURN red{{ .* }}"; var result = await Session.RunAsync(cypher, Params.Create(client.ClientId)); var records = await result.ToListAsync(r => r.MapTo <Neo4jIdentityServer4ClientRedirectUri>("red")); return(records); }
public async Task <IList <Neo4JIdentityServer4ClientIdpRestriction> > GetIDPRestrictionsAsync( Neo4jIdentityServer4Client client, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); client.ThrowIfNull(nameof(client)); var cypher = $@" MATCH (client:{IdSrv4Client})-[:{Neo4jConstants.Relationships.HasIdPRestriction}]->(idp:{ IdSrv4ClienTIDPRestriction }) WHERE client.ClientId = $p0 RETURN idp{{ .* }}"; var result = await Session.RunAsync(cypher, Params.Create(client.ClientId)); var ipds = await result.ToListAsync(r => r.MapTo <Neo4JIdentityServer4ClientIdpRestriction>("idp")); return(ipds); }
public async Task <IdentityServer4.Models.Client> GetRollupAsync(Neo4jIdentityServer4Client client, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); client.ThrowIfNull(nameof(client)); var cypher = $@" MATCH (c:{IdSrv4Client})-[:{Neo4jConstants.Relationships.HasRollup}]->(rollup:{IdSrv4ClientRollup}) WHERE c.ClientId = $p0 RETURN rollup{{ .* }}"; var result = await Session.RunAsync(cypher, Params.Create( client.ClientId)); IdentityServer4.Models.Client model = null; var foundRecord = await result.SingleOrDefaultAsync(r => r.MapTo <ClientRollup>("rollup")); if (foundRecord == null) { model = await RollupAsync(client, cancellationToken); } else { model = JsonConvert.DeserializeObject <IdentityServer4.Models.ClientExtra>(foundRecord.ClientJson); if (!string.IsNullOrEmpty(foundRecord.ClaimsJson)) { var claims = JsonConvert.DeserializeObject <List <Neo4jIdentityServer4ClientClaim> >(foundRecord.ClaimsJson); foreach (var item in claims) { model.Claims.Add(new Claim(item.Type, item.Value)); } } } return(model); }
public async Task <IdentityResult> UpdateClientAsync(Neo4jIdentityServer4Client client, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); client.ThrowIfNull(nameof(client)); try { var cypher = $@" MATCH (r:{IdSrv4Client}) WHERE r.ClientId = $p0 SET r = $p1"; await Session.RunAsync(cypher, Params.Create(client.ClientId, client.ConvertToMap())); await RaiseClientChangeEventAsync(client); return(IdentityResult.Success); } catch (ClientException ex) { return(ex.ToIdentityResult()); } }
public async Task <IdentityResult> DeleteRollupAsync(Neo4jIdentityServer4Client client, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); client.ThrowIfNull(nameof(client)); try { var cypher = $@" MATCH (c:{IdSrv4Client})-[:{Neo4jConstants.Relationships.HasRollup}]->(rollup:{IdSrv4ClientRollup}) WHERE c.ClientId = $p0 DETACH DELETE rollup"; await Session.RunAsync(cypher, Params.Create(client.ClientId)); return(IdentityResult.Success); } catch (ClientException ex) { return(ex.ToIdentityResult()); } }
public async Task <Neo4jIdentityServer4ClientScope> FindScopeAsync(Neo4jIdentityServer4Client client, Neo4jIdentityServer4ClientScope scope, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); client.ThrowIfNull(nameof(client)); scope.ThrowIfNull(nameof(scope)); var cypher = $@" MATCH (client:{IdSrv4Client})-[:{Neo4jConstants.Relationships.HasScope}]->(scope:{IdSrv4ClientScope}) WHERE client.ClientId = $p0 AND scope.Scope = $p1 RETURN scope{{ .* }}"; var result = await Session.RunAsync(cypher, Params.Create( client.ClientId, scope.Scope )); var foundRecord = await result.SingleOrDefaultAsync(r => r.MapTo <Neo4jIdentityServer4ClientScope>("scope")); return(foundRecord); }
public async Task <IdentityServer4.Models.Client> RollupAsync( Neo4jIdentityServer4Client client, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); client.ThrowIfNull(nameof(client)); await RaiseClientChangeEventAsync(client); var finalResult = new Client(); var clientFound = await FindClientByClientIdAsync(client.ClientId, cancellationToken); var model = clientFound.ToModel(); var secrets = await GetSecretsAsync(client, cancellationToken); if (secrets != null) { foreach (var secret in secrets) { model.ClientSecrets.Add(secret.ToModel()); } } var allowedGrants = await GetAllowedGrantTypesAsync(client, cancellationToken); if (allowedGrants != null) { foreach (var item in allowedGrants) { model.AllowedGrantTypes.Add(item.GrantType); } } var corsOrigins = await GetCorsOriginsAsync(client, cancellationToken); if (corsOrigins != null) { foreach (var item in corsOrigins) { model.AllowedCorsOrigins.Add(item.Origin); } } var idpRestrictions = await GetIDPRestrictionsAsync(client, cancellationToken); if (idpRestrictions != null) { foreach (var item in idpRestrictions) { model.IdentityProviderRestrictions.Add(item.Provider); } } var postLogoutRedirectUris = await GetPostLogoutRedirectUrisAsync(client, cancellationToken); if (postLogoutRedirectUris != null) { foreach (var item in postLogoutRedirectUris) { model.PostLogoutRedirectUris.Add(item.PostLogoutRedirectUri); } } var properties = await GetPropertiesAsync(client, cancellationToken); if (properties != null) { foreach (var item in properties) { model.Properties.Add(item.Key, item.Value); } } var redirectUris = await GetRedirectUrisAsync(client, cancellationToken); if (redirectUris != null) { foreach (var item in redirectUris) { model.RedirectUris.Add(item.RedirectUri); } } var scopes = await GetScopesAsync(client, cancellationToken); if (redirectUris != null) { foreach (var item in scopes) { model.AllowedScopes.Add(item.Scope); } } var claims = await GetClaimsAsync(client, cancellationToken); string claimsJson = null; if (claims != null) { claimsJson = JsonConvert.SerializeObject(claims); } var rollup = new ClientRollup() { ClientJson = JsonConvert.SerializeObject(model), ClaimsJson = claimsJson }; var result = await AddRollupToClientAsync(client, rollup, cancellationToken); if (claims != null) { foreach (var item in claims) { model.Claims.Add(new Claim(item.Type, item.Value)); } } return(model); }
public async Task <Neo4jIdentityServer4ClientRedirectUri> FindRedirectUriAsync(Neo4jIdentityServer4Client client, Neo4jIdentityServer4ClientRedirectUri redirectUri, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); client.ThrowIfNull(nameof(client)); redirectUri.ThrowIfNull(nameof(redirectUri)); var cypher = $@" MATCH (client:{IdSrv4Client})-[:{Neo4jConstants.Relationships.HasRedirectUri}]->(redirectUri:{ IdSrv4ClientRedirectUri }) WHERE client.ClientId = $p0 AND redirectUri.RedirectUri = $p1 RETURN redirectUri{{ .* }}"; var result = await Session.RunAsync(cypher, Params.Create( client.ClientId, redirectUri.RedirectUri )); var foundRecord = await result.SingleOrDefaultAsync(r => r.MapTo <Neo4jIdentityServer4ClientRedirectUri>("redirectUri")); return(foundRecord); }
/// <summary> /// Maps an entity to a model. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public static IdentityServer4.Models.ClientExtra ToModel( this Neo4jIdentityServer4Client entity) { return(Mapper.Map <IdentityServer4.Models.ClientExtra>(entity)); }
private Task RaiseClientChangeEventAsync( Neo4jIdentityServer4Client client) { return(_eventService.RaiseAsync(new ClientChangeEvent <Neo4jIdentityServer4Client>(client))); }
public async Task <IList <Neo4jIdentityServer4ClientSecret> > GetSecretsAsync(Neo4jIdentityServer4Client client, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); client.ThrowIfNull(nameof(client)); var cypher = $@" MATCH (c:{IdSrv4Client})-[:{Neo4jConstants.Relationships.HasSecret}]->(s:{IdSrv4ClientSecret}) WHERE c.ClientId = $p0 RETURN s{{ .* }}"; var result = await Session.RunAsync(cypher, Params.Create(client.ClientId)); var secrets = await result.ToListAsync(r => r.MapTo <Neo4jIdentityServer4ClientSecret>("s")); return(secrets); }