Exemple #1
0
        public async Task <Scope> GetRollupAsync(
            Neo4jIdentityServer4ApiResource apiResource,
            Neo4jIdentityServer4ApiScope apiScope,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.ThrowIfCancellationRequested();
            ThrowIfDisposed();
            apiResource.ThrowIfNull(nameof(apiResource));
            apiScope.ThrowIfNull(nameof(apiScope));

            var cypher = $@"
                MATCH 
                    (:{IdSrv4ApiResource}{{Name: $p0}})-[:{Neo4jConstants.Relationships.HasScope}]->
                    (:{IdSrv4ClientApiScope}{{Name: $p1}})-[:{Neo4jConstants.Relationships.HasRollup}]->
                    (r:{IdSrv4ApiScopeRollup})
                RETURN r{{ .* }}";

            var result = await Session.RunAsync(cypher,
                                                Params.Create(apiResource.Name, apiScope.Name));

            IdentityServer4.Models.Scope model = null;
            var foundRecord =
                await result.SingleOrDefaultAsync(r => r.MapTo <ApiScopeRollup>("r"));

            if (foundRecord == null)
            {
                model = await RollupAsync(apiResource, apiScope, cancellationToken);
            }
            else
            {
                model = JsonConvert.DeserializeObject <Scope>(foundRecord.ApiScopeJson);
            }
            return(model);
        }
Exemple #2
0
        public static Entities.Scope ToEntity(this Scope scope)
        {
            if (scope == null)
            {
                return(null);
            }

            return(Mapper.Map <Scope, Entities.Scope>(scope));
        }
Exemple #3
0
        public static Scope ToScopeViewModel(this IS4.Scope scope)
        {
            var newScope = new Scope
            {
                Name                    = scope.Name,
                DisplayName             = scope.DisplayName,
                Description             = scope.Description,
                Required                = scope.Required,
                Emphasize               = scope.Emphasize,
                ShowInDiscoveryDocument = scope.ShowInDiscoveryDocument,
                UserClaims              = new List <string>(scope.UserClaims)
            };

            return(newScope);
        }