public async Task <IdentityResult> AddClaimToClientAsync( Neo4jIdentityServer4Client client, Neo4jIdentityServer4ClientClaim claim, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); client.ThrowIfNull(nameof(client)); claim.ThrowIfNull(nameof(claim)); try { var cypher = $@" MATCH (client:{IdSrv4Client} {{ClientId: $p0}}) CREATE UNIQUE((client)-[:{Neo4jConstants.Relationships.HasClaim}]->(claim:{IdSrv4ClientClaim} {"$p1".AsMapForNoNull(claim)}))"; var result = await Session.RunAsync(cypher, Params.Create(client.ClientId, claim)); await RaiseClientChangeEventAsync(client); return(IdentityResult.Success); } catch (ClientException ex) { return(ex.ToIdentityResult()); } }
public async Task <IdentityResult> DeleteClaimAsync(Neo4jIdentityServer4Client client, Neo4jIdentityServer4ClientClaim claim, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); client.ThrowIfNull(nameof(client)); claim.ThrowIfNull(nameof(claim)); try { var cypher = $@" MATCH (client:{IdSrv4Client})-[:{Neo4jConstants.Relationships.HasClaim}]->(claim:{IdSrv4ClientClaim}) WHERE client.ClientId = $p0 AND claim.Type = $p1 AND claim.Value = $p2 DETACH DELETE claim"; await Session.RunAsync(cypher, Params.Create( client.ClientId, claim.Type, claim.Value )); return(IdentityResult.Success); } catch (ClientException ex) { return(ex.ToIdentityResult()); } }
public async Task <Neo4jIdentityServer4ClientClaim> FindClaimAsync(Neo4jIdentityServer4Client client, Neo4jIdentityServer4ClientClaim claim, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); client.ThrowIfNull(nameof(client)); claim.ThrowIfNull(nameof(claim)); var cypher = $@" MATCH (client:{IdSrv4Client})-[:{Neo4jConstants.Relationships.HasClaim}]->(claim:{IdSrv4ClientClaim}) WHERE client.ClientId = $p0 AND claim.Type = $p1 AND claim.Value = $p2 RETURN claim{{ .* }}"; var result = await Session.RunAsync(cypher, Params.Create( client.ClientId, claim.Type, claim.Value )); var foundRecord = await result.SingleOrDefaultAsync(r => r.MapTo <Neo4jIdentityServer4ClientClaim>("claim")); return(foundRecord); }
/// <summary> /// Maps an entity to a model. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public static Claim ToModel( this Neo4jIdentityServer4ClientClaim entity) { return(Mapper.Map <Claim>(entity)); }