public async Task <IdentityResult> DeleteScopeAsync(Neo4jIdentityServer4Client client, Neo4jIdentityServer4ClientScope scope, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); client.ThrowIfNull(nameof(client)); scope.ThrowIfNull(nameof(scope)); try { var cypher = $@" MATCH (client:{IdSrv4Client})-[:{Neo4jConstants.Relationships.HasScope}]->(scope:{IdSrv4ClientScope}) WHERE client.ClientId = $p0 AND scope.Scope = $p1 DETACH DELETE scope"; await Session.RunAsync(cypher, Params.Create( client.ClientId, scope.Scope )); await RaiseClientChangeEventAsync(client); return(IdentityResult.Success); } catch (ClientException ex) { return(ex.ToIdentityResult()); } }
public async Task <IdentityResult> AddScopeToClientAsync(Neo4jIdentityServer4Client client, Neo4jIdentityServer4ClientScope scope, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); client.ThrowIfNull(nameof(client)); scope.ThrowIfNull(nameof(scope)); try { var cypher = $@" MATCH (client:{IdSrv4Client} {{ClientId: $p0}}) CREATE UNIQUE( (client)-[:{Neo4jConstants.Relationships.HasScope}]-> (:{IdSrv4ClientScope} {"$p1".AsMapForNoNull(scope)}))"; var result = await Session.RunAsync(cypher, Params.Create(client.ClientId, scope)); await RaiseClientChangeEventAsync(client); 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); }
/// <summary> /// Maps an entity to a model. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public static IdentityServer4.Models.Scope ToModel( this Neo4jIdentityServer4ClientScope entity) { return(Mapper.Map <IdentityServer4.Models.Scope>(entity)); }