예제 #1
0
        public async Task <IdentityResult> DeleteAllowedGrantTypeToClientAsync(Neo4jIdentityServer4Client client,
                                                                               Neo4JIdentityServer4GrantType identityServer4GrantType, CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.ThrowIfCancellationRequested();
            ThrowIfDisposed();
            client.ThrowIfNull(nameof(client));
            identityServer4GrantType.ThrowIfNull(nameof(identityServer4GrantType));
            try
            {
                var cypher = $@"
                MATCH 
                    (client:{IdSrv4Client})
                    -[:{Neo4jConstants.Relationships.HasGrantType}]->
                    (allowedGT:{IdSrv4AllowedGrantType})
                WHERE client.ClientId = $p0 AND allowedGT.IdentityServer4GrantType = $p1 
                DETACH DELETE allowedGT";

                var result = await Session.RunAsync(cypher, Params.Create(client.ClientId, identityServer4GrantType.GrantType));
                await RaiseClientChangeEventAsync(client);

                return(IdentityResult.Success);
            }
            catch (ClientException ex)
            {
                return(ex.ToIdentityResult());
            }
        }
예제 #2
0
        public async Task <IdentityResult> AddAllowedGrantTypeToClientAsync(
            Neo4jIdentityServer4Client client,
            Neo4JIdentityServer4GrantType identityServer4GrantType,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.ThrowIfCancellationRequested();
            ThrowIfDisposed();
            client.ThrowIfNull(nameof(client));
            identityServer4GrantType.ThrowIfNull(nameof(identityServer4GrantType));
            try
            {
                var cypher = $@"
                MATCH (client:{IdSrv4Client} {{ClientId: $p0}})
                CREATE UNIQUE(
                    (client)-[:{Neo4jConstants.Relationships.HasGrantType}]->
                    (:{IdSrv4AllowedGrantType} {"$p1".AsMapForNoNull(identityServer4GrantType)}))";


                var result = await Session.RunAsync(cypher, Params.Create(client.ClientId, identityServer4GrantType));
                await RaiseClientChangeEventAsync(client);

                return(IdentityResult.Success);
            }
            catch (ClientException ex)
            {
                return(ex.ToIdentityResult());
            }
        }
예제 #3
0
        public async Task <IdentityResult> CreateGrantTypeAsync(
            Neo4JIdentityServer4GrantType identityServer4GrantType,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.ThrowIfCancellationRequested();
            ThrowIfDisposed();
            identityServer4GrantType.ThrowIfNull(nameof(identityServer4GrantType));
            try
            {
                var cypher = $@"CREATE (r:{IdSrv4GrantType} $p0)";
                await Session.RunAsync(cypher, Params.Create(identityServer4GrantType.ConvertToMap()));

                return(IdentityResult.Success);
            }
            catch (ClientException ex)
            {
                return(ex.ToIdentityResult());
            }
        }
예제 #4
0
        public async Task <Neo4JIdentityServer4GrantType> FindGrantTypeAsync(
            Neo4JIdentityServer4GrantType identityServer4GrantType,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.ThrowIfCancellationRequested();
            ThrowIfDisposed();
            identityServer4GrantType.ThrowIfNull(nameof(identityServer4GrantType));

            var cypher = $@"
                MATCH (r:{IdSrv4GrantType})
                WHERE r.GrantType = $p0
                RETURN r {{ .* }}";

            var result = await Session.RunAsync(cypher, Params.Create(identityServer4GrantType.GrantType));

            var grantTypeRecord =
                await result.SingleOrDefaultAsync(r => r.MapTo <Neo4JIdentityServer4GrantType>("r"));

            return(grantTypeRecord);
        }
예제 #5
0
        public async Task <IdentityResult> DeleteGrantTypeAsync(
            Neo4JIdentityServer4GrantType identityServer4GrantType,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.ThrowIfCancellationRequested();
            ThrowIfDisposed();
            identityServer4GrantType.ThrowIfNull(nameof(identityServer4GrantType));
            try
            {
                var cypher = $@"
                MATCH (r:{IdSrv4GrantType})
                WHERE r.GrantType = $p0
                DETACH DELETE r";

                await Session.RunAsync(cypher, Params.Create(identityServer4GrantType.GrantType));

                return(IdentityResult.Success);
            }
            catch (ClientException ex)
            {
                return(ex.ToIdentityResult());
            }
        }
 /// <summary>
 /// Maps an entity to a model.
 /// </summary>
 /// <param name="entity">The entity.</param>
 /// <returns></returns>
 public static string ToModel(
     this Neo4JIdentityServer4GrantType entity)
 {
     return(Mapper.Map <string>(entity));
 }