public static void AddTenantUserPolicy(this AuthorizationOptions options, TenantRoleType tenantRoleType)
 {
     options.AddPolicy(tenantRoleType.ToString(), policy => policy.RequireAuthenticatedUser()
                       .AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme)
                       .RequireClaim(Constants.ClaimTypes.GlobalRole, nameof(GlobalRoleType.TenantUser))
                       .RequireClaim(Constants.ClaimTypes.TenantRoles, tenantRoleType.ToString()));
 }
예제 #2
0
        public bool IsInRole(TenantRoleType tenantRoleType)
        {
            var roleTypeAsString = tenantRoleType.ToString();

            return(httpContext.User.Claims.Any(x => x.Type == Constants.ClaimTypes.TenantRoles && x.Value == roleTypeAsString));
        }