public async Task <IActionResult> GetApiScopes([FromQuery] ListOptions options) { var query = _configurationDbContext.ApiScopes.Include(x => x.Properties).AsNoTracking(); if (!string.IsNullOrEmpty(options.Search)) { var searchTerm = options.Search.ToLower(); query = query.Where(x => x.Name.ToLower().Contains(searchTerm) || x.Description.ToLower().Contains(searchTerm)); } var scopes = await query.Select(apiScope => new ApiScopeInfo { Id = apiScope.Id, Name = apiScope.Name, Description = apiScope.Description, DisplayName = apiScope.DisplayName, Emphasize = apiScope.Emphasize, UserClaims = apiScope.UserClaims.Select(apiScopeClaim => apiScopeClaim.Type), ShowInDiscoveryDocument = apiScope.ShowInDiscoveryDocument, Translations = TranslationDictionary <ApiScopeTranslation> .FromJson(apiScope.Properties.Any(x => x.Key == IdentityServerApi.ObjectTranslationKey) ? apiScope.Properties.Single(x => x.Key == IdentityServerApi.ObjectTranslationKey).Value : string.Empty ) }) .ToResultSetAsync(options); return(Ok(scopes)); }
public async Task <IActionResult> GetApiResource([FromRoute] int resourceId) { var apiResource = await _configurationDbContext.ApiResources .AsNoTracking() .Include(x => x.Properties) .Include(x => x.Scopes) .Select(x => new ApiResourceInfo { Id = x.Id, Name = x.Name, DisplayName = x.DisplayName, Description = x.Description, Enabled = x.Enabled, NonEditable = x.NonEditable, AllowedClaims = x.UserClaims.Select(x => x.Type), Scopes = x.Scopes.Any() ? x.Scopes.Join( _configurationDbContext.ApiScopes.Include(y => y.Properties), apiResourceScope => apiResourceScope.Scope, apiScope => apiScope.Name, (apiResourceScope, apiScope) => new { ApiResourceScope = apiResourceScope, ApiScope = apiScope } ) .Select(result => new ApiScopeInfo { Id = result.ApiResourceScope.Id, Name = result.ApiScope.Name, Description = result.ApiScope.Description, DisplayName = result.ApiScope.DisplayName, Emphasize = result.ApiScope.Emphasize, UserClaims = result.ApiScope.UserClaims.Select(apiScopeClaim => apiScopeClaim.Type), ShowInDiscoveryDocument = result.ApiScope.ShowInDiscoveryDocument, Translations = TranslationDictionary <ApiScopeTranslation> .FromJson(result.ApiScope.Properties.Any(x => x.Key == IdentityServerApi.ObjectTranslationKey) ? result.ApiScope.Properties.Single(x => x.Key == IdentityServerApi.ObjectTranslationKey).Value : string.Empty ) }) : default,