Browse Source

Merge pull request #14023 from abpframework/abp.auth.policies

Remove `abp.auth.policies`.
pull/14318/head
Halil İbrahim Kalkan 4 years ago
committed by GitHub
parent
commit
c46e83fdd6
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      docs/en/UI/AspNetCore/JavaScript-API/Auth.md
  2. 3
      framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationAuthConfigurationDto.cs
  3. 7
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs
  4. 4
      npm/packs/core/src/abp.js

1
docs/en/UI/AspNetCore/JavaScript-API/Auth.md

@ -20,5 +20,4 @@ if (abp.auth.isGranted('DeleteUsers')) {
* ` abp.auth.isAnyGranted(...)`: Gets one or more permission/policy names and returns `true` if at least one of them has granted. * ` abp.auth.isAnyGranted(...)`: Gets one or more permission/policy names and returns `true` if at least one of them has granted.
* `abp.auth.areAllGranted(...)`: Gets one or more permission/policy names and returns `true` if all of them of them have granted. * `abp.auth.areAllGranted(...)`: Gets one or more permission/policy names and returns `true` if all of them of them have granted.
* `abp.auth.policies`: This is an object where its keys are the permission/policy names. You can find all permission/policy names here.
* `abp.auth.grantedPolicies`: This is an object where its keys are the permission/policy names. You can find the granted permission/policy names here. * `abp.auth.grantedPolicies`: This is an object where its keys are the permission/policy names. You can find the granted permission/policy names here.

3
framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationAuthConfigurationDto.cs

@ -6,13 +6,10 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations;
[Serializable] [Serializable]
public class ApplicationAuthConfigurationDto public class ApplicationAuthConfigurationDto
{ {
public Dictionary<string, bool> Policies { get; set; }
public Dictionary<string, bool> GrantedPolicies { get; set; } public Dictionary<string, bool> GrantedPolicies { get; set; }
public ApplicationAuthConfigurationDto() public ApplicationAuthConfigurationDto()
{ {
Policies = new Dictionary<string, bool>();
GrantedPolicies = new Dictionary<string, bool>(); GrantedPolicies = new Dictionary<string, bool>();
} }
} }

7
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs

@ -185,8 +185,6 @@ public class AbpApplicationConfigurationAppService : ApplicationService, IAbpApp
foreach (var policyName in otherPolicyNames) foreach (var policyName in otherPolicyNames)
{ {
authConfig.Policies[policyName] = true;
if (await _authorizationService.IsGrantedAsync(policyName)) if (await _authorizationService.IsGrantedAsync(policyName))
{ {
authConfig.GrantedPolicies[policyName] = true; authConfig.GrantedPolicies[policyName] = true;
@ -196,7 +194,6 @@ public class AbpApplicationConfigurationAppService : ApplicationService, IAbpApp
var result = await _permissionChecker.IsGrantedAsync(abpPolicyNames.ToArray()); var result = await _permissionChecker.IsGrantedAsync(abpPolicyNames.ToArray());
foreach (var (key, value) in result.Result) foreach (var (key, value) in result.Result)
{ {
authConfig.Policies[key] = true;
if (value == PermissionGrantResult.Granted) if (value == PermissionGrantResult.Granted)
{ {
authConfig.GrantedPolicies[key] = true; authConfig.GrantedPolicies[key] = true;
@ -228,10 +225,10 @@ public class AbpApplicationConfigurationAppService : ApplicationService, IAbpApp
foreach (var resourceName in resourceNames) foreach (var resourceName in resourceNames)
{ {
var dictionary = new Dictionary<string, string>(); var dictionary = new Dictionary<string, string>();
var localizer = await StringLocalizerFactory var localizer = await StringLocalizerFactory
.CreateByResourceNameOrNullAsync(resourceName); .CreateByResourceNameOrNullAsync(resourceName);
if (localizer != null) if (localizer != null)
{ {
foreach (var localizedString in await localizer.GetAllStringsAsync()) foreach (var localizedString in await localizer.GetAllStringsAsync())

4
npm/packs/core/src/abp.js

@ -204,12 +204,10 @@ var abp = abp || {};
abp.auth = abp.auth || {}; abp.auth = abp.auth || {};
abp.auth.policies = abp.auth.policies || {};
abp.auth.grantedPolicies = abp.auth.grantedPolicies || {}; abp.auth.grantedPolicies = abp.auth.grantedPolicies || {};
abp.auth.isGranted = function (policyName) { abp.auth.isGranted = function (policyName) {
return abp.auth.policies[policyName] != undefined && abp.auth.grantedPolicies[policyName] != undefined; return abp.auth.grantedPolicies[policyName] != undefined;
}; };
abp.auth.isAnyGranted = function () { abp.auth.isAnyGranted = function () {

Loading…
Cancel
Save