How to check custom attributes inside authorization process (policy or middleware)?
Clash Royale CLAN TAG #URR8PPP How to check custom attributes inside authorization process (policy or middleware)? Main goal is to prevent access to the portal when OIDC user has custom claim with type 'BlockedFrom', which added in ClaimsTransformation. I've solved it by middleware in Startup.Configure method. General reason is to keep original request URL without redirection to /Account/AccessDenied page. Startup.Configure app.Use((context, next) => var user = context.User; if (user.IsAuthenticated()) // Do not rewrite path when it marked with custom [AllowBlockedAttribute]! // /Home/Logout, for example. But how? // if (user.HasClaim(x => x.Type == UserClaimTypes.BlockedFrom)) // Rewrite to run specific method of HomeController for blocked users // with detailed message. // context.Request.Path = GenericPaths.Blocked; return next(); ); But have one unexpected result: the Logout method of HomeController is blocked too. User can't logout when ...