public async Task <IdentityResult> AddPostLogoutRedirectUriToClientAsync(Neo4jIdentityServer4Client client,
                                                                                 Neo4jIdentityServer4ClientPostLogoutRedirectUri postLogoutRedirectUri,
                                                                                 CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.ThrowIfCancellationRequested();
            ThrowIfDisposed();
            client.ThrowIfNull(nameof(client));
            postLogoutRedirectUri.ThrowIfNull(nameof(postLogoutRedirectUri));
            try
            {
                var cypher = $@"
                MATCH (client:{IdSrv4Client} {{ClientId: $p0}})
                MERGE (postLogoutRedirectUri:{IdSrv4ClientPostLogoutRedirectUri} {
                        "$p1".AsMapForNoNull<Neo4jIdentityServer4ClientPostLogoutRedirectUri>(postLogoutRedirectUri)
                    })
                MERGE (client)-[:{Neo4jConstants.Relationships.HasPostLogoutRedirectUri}]->(postLogoutRedirectUri)";

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

                return(IdentityResult.Success);
            }
            catch (ClientException ex)
            {
                return(ex.ToIdentityResult());
            }
        }
        public async Task <IdentityResult> DeletePostLogoutRedirectUriAsync(Neo4jIdentityServer4Client client,
                                                                            Neo4jIdentityServer4ClientPostLogoutRedirectUri postLogoutRedirectUri,
                                                                            CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.ThrowIfCancellationRequested();
            ThrowIfDisposed();
            client.ThrowIfNull(nameof(client));
            postLogoutRedirectUri.ThrowIfNull(nameof(postLogoutRedirectUri));
            try
            {
                var cypher = $@"
                MATCH (client:{IdSrv4Client})-[:{
                        Neo4jConstants.Relationships.HasPostLogoutRedirectUri
                    }]->(postLogoutRedirectUri:{IdSrv4ClientPostLogoutRedirectUri})
                WHERE client.ClientId = $p0 AND postLogoutRedirectUri.PostLogoutRedirectUri = $p1  
                DETACH DELETE postLogoutRedirectUri";

                await Session.RunAsync(cypher,
                                       Params.Create(
                                           client.ClientId,
                                           postLogoutRedirectUri.PostLogoutRedirectUri
                                           ));
                await RaiseClientChangeEventAsync(client);

                return(IdentityResult.Success);
            }
            catch (ClientException ex)
            {
                return(ex.ToIdentityResult());
            }
        }
        public async Task <Neo4jIdentityServer4ClientPostLogoutRedirectUri> FindPostLogoutRedirectUriAsync(
            Neo4jIdentityServer4Client client,
            Neo4jIdentityServer4ClientPostLogoutRedirectUri postLogoutRedirectUri,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.ThrowIfCancellationRequested();
            ThrowIfDisposed();
            client.ThrowIfNull(nameof(client));
            postLogoutRedirectUri.ThrowIfNull(nameof(postLogoutRedirectUri));
            var cypher = $@"
                MATCH (client:{IdSrv4Client})-[:{
                    Neo4jConstants.Relationships.HasPostLogoutRedirectUri
                }]->(postLogoutRedirectUri:{IdSrv4ClientPostLogoutRedirectUri})
                WHERE client.ClientId = $p0 AND postLogoutRedirectUri.PostLogoutRedirectUri = $p1  
                RETURN postLogoutRedirectUri{{ .* }}";

            var result = await Session.RunAsync(cypher,
                                                Params.Create(
                                                    client.ClientId,
                                                    postLogoutRedirectUri.PostLogoutRedirectUri

                                                    ));

            var foundRecord =
                await result.SingleOrDefaultAsync(r =>
                                                  r.MapTo <Neo4jIdentityServer4ClientPostLogoutRedirectUri>("postLogoutRedirectUri"));

            return(foundRecord);
        }
Esempio n. 4
0
 /// <summary>
 /// Maps an entity to a model.
 /// </summary>
 /// <param name="entity">The entity.</param>
 /// <returns></returns>
 public static string ToModel(
     this Neo4jIdentityServer4ClientPostLogoutRedirectUri entity)
 {
     return(Mapper.Map <string>(entity));
 }