Пример #1
0
        private async Task <IActionResult> GetConsents(CancellationToken cancellationToken)
        {
            var authenticatedUser = await SetUser().ConfigureAwait(false);

            var consents = await _consentRepository
                           .GetConsentsForGivenUser(authenticatedUser.GetSubject() !, cancellationToken)
                           .ConfigureAwait(false);

            var result = new List <ConsentViewModel>();

            var scopes = (await _scopeRepository.SearchByNames(
                              cancellationToken,
                              consents.SelectMany(x => x.GrantedScopes).Distinct().ToArray())
                          .ConfigureAwait(false)).ToDictionary(x => x.Name, x => x);

            result.AddRange(
                from consent in consents
                let scopeNames = consent.GrantedScopes
                                 let claims = consent.Claims
                                              select new ConsentViewModel
            {
                Id = consent.Id,
                ClientDisplayName        = consent.ClientName,
                AllowedScopeDescriptions = scopeNames?.Any() != true
                        ? new List <string>()
                        : scopeNames.Select(g => scopes[g].Description).ToList(),
                AllowedIndividualClaims = claims ?? Array.Empty <string>(),
                //LogoUri = client?.LogoUri?.AbsoluteUri,
                PolicyUri = consent.PolicyUri?.AbsoluteUri,
                TosUri    = consent.TosUri?.AbsoluteUri
            });

            return(Ok(result));
        }
Пример #2
0
        private async Task <string[]> GetScopes(string concatenateListOfScopes, CancellationToken cancellationToken)
        {
            var scopeNames = concatenateListOfScopes.ParseScopes();
            var scopes     = await _scopeRepository.SearchByNames(cancellationToken, scopeNames).ConfigureAwait(false);

            return(scopes.Select(x => x.Name).ToArray());
        }
Пример #3
0
        private async Task <IEnumerable <Scope> > GetScopes(
            string concatenateListOfScopes,
            CancellationToken cancellationToken)
        {
            var scopeNames = concatenateListOfScopes.Split(' ');

            return(await _scopeRepository.SearchByNames(cancellationToken, scopeNames).ConfigureAwait(false));
        }