private async Task <Dictionary <string, AuthorizationPolicy> > GetDynamicAuthorizationPoliciesFromPlatformPermissions() { var cacheKey = CacheKey.With(GetType(), "GetDynamicAuthorizationPoliciesFromPlatformPermissions"); var result = await _memoryCache.GetOrCreateExclusiveAsync(cacheKey, async (cacheEntry) => { cacheEntry.AddExpirationToken(SecurityCacheRegion.CreateChangeToken()); var resultLookup = new Dictionary <string, AuthorizationPolicy>(); foreach (var permission in await _platformSecurityApi.GetAllRegisteredPermissionsAsync()) { resultLookup[permission.Id] = new AuthorizationPolicyBuilder().AddRequirements(new PermissionAuthorizationRequirement { Permission = permission.Id }).Build(); } //Register storefront permissions foreach (var permission in SecurityConstants.Permissions.AllPermissions) { resultLookup[permission] = new AuthorizationPolicyBuilder().AddRequirements(new PermissionAuthorizationRequirement { Permission = permission }).Build(); } return(resultLookup); }); return(result); }