private async Task <List <Claim> > BuildFeatureClaimsAsync(string userId, CalcAllowedPermissions rtoP) { var claims = new List <Claim> { new Claim(PermissionConstants.PackedPermissionClaimType, await rtoP.CalcPermissionsForUserAsync(userId)), new Claim(PermissionConstants.LastPermissionsUpdatedClaimType, DateTime.UtcNow.Ticks.ToString()) }; return(claims); }
protected override async Task <ClaimsIdentity> GenerateClaimsAsync(IdentityUser user) { var identity = await base.GenerateClaimsAsync(user); var userId = identity.Claims.SingleOrDefault(x => x.Type == ClaimTypes.NameIdentifier)?.Value; var rtoPCalcer = new CalcAllowedPermissions(_extraAuthDbContext); identity.AddClaim(new Claim(PermissionConstants.PackedPermissionClaimType, await rtoPCalcer.CalcPermissionsForUserAsync(userId))); var dataKeyCalcer = new CalcDataKey(_extraAuthDbContext); identity.AddClaim(new Claim(DataAuthConstants.HierarchicalKeyClaimName, dataKeyCalcer.CalcDataKeyForUser(userId))); return(identity); }
public AuthCookieValidate(CalcAllowedPermissions rtoPCalcer, CalcDataKey dataKeyCalcer, ISimpleTimeCache cache) { _rtoPCalcer = rtoPCalcer; _dataKeyCalcer = dataKeyCalcer; _cache = cache; }