protected virtual async Task <ApplicationAuthConfigurationDto> GetAuthConfigAsync() { Logger.LogDebug("Executing AbpApplicationConfigurationAppService.GetAuthConfigAsync()"); var authConfig = new ApplicationAuthConfigurationDto(); var policyNames = await _abpAuthorizationPolicyProvider.GetPoliciesNamesAsync().ConfigureAwait(false); Logger.LogDebug($"GetPoliciesNamesAsync returns {policyNames.Count} items."); foreach (var policyName in policyNames) { authConfig.Policies[policyName] = true; Logger.LogDebug($"_authorizationService.IsGrantedAsync? {policyName}"); if (await _authorizationService.IsGrantedAsync(policyName).ConfigureAwait(false)) { authConfig.GrantedPolicies[policyName] = true; } } Logger.LogDebug("Executed AbpApplicationConfigurationAppService.GetAuthConfigAsync()"); return(authConfig); }
protected virtual async Task <ApplicationAuthConfigurationDto> GetAuthConfig() { var authConfig = new ApplicationAuthConfigurationDto(); foreach (var policyName in await _abpAuthorizationPolicyProvider.GetPoliciesNamesAsync()) { authConfig.Policies[policyName] = true; if (await _authorizationService.IsGrantedAsync(policyName)) { authConfig.GrantedPolicies[policyName] = true; } } return(authConfig); }
protected virtual async Task <ApplicationAuthConfigurationDto> GetAuthConfigAsync() { var authConfig = new ApplicationAuthConfigurationDto(); var policyNames = await _abpAuthorizationPolicyProvider.GetPoliciesNamesAsync(); var abpPolicyNames = new List <string>(); var otherPolicyNames = new List <string>(); foreach (var policyName in policyNames) { if (await _defaultAuthorizationPolicyProvider.GetPolicyAsync(policyName) == null && _permissionDefinitionManager.GetOrNull(policyName) != null) { abpPolicyNames.Add(policyName); } else { otherPolicyNames.Add(policyName); } } foreach (var policyName in otherPolicyNames) { authConfig.Policies[policyName] = true; if (await _authorizationService.IsGrantedAsync(policyName)) { authConfig.GrantedPolicies[policyName] = true; } } var result = await _permissionChecker.IsGrantedAsync(abpPolicyNames.ToArray()); foreach (var(key, value) in result.Result) { authConfig.Policies[key] = true; if (value == PermissionGrantResult.Granted) { authConfig.GrantedPolicies[key] = true; } } return(authConfig); }