Authorize api and identity pages

Jay San 1 Reputation point
2021-09-07T12:05:19.077+00:00

I try to authorize by role Identity pages and API controllers and it doesn't work as expected.

I use Identity for security and i want to authorize the identity register page by role i want to authorize api controllers also.
If I use just this code, I can authorize identy pages:

services.AddAuthentication().AddIdentityServerJwt();

But if i use this code:

services.AddAuthentication(options => { options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }) .AddJwtBearer(options => {}.AddIdentityServerJwt()

I can authorize api but I can't authorize identity page. Does anyone has any ideea how can I authorize both?

Azure Active Directory
Azure Active Directory
An Azure enterprise identity service that provides single sign-on and multi-factor authentication.
14,651 questions
Microsoft Authenticator
Microsoft Authenticator
A Microsoft app for iOS and Android devices that enables authentication with two-factor verification, phone sign-in, and code generation.
3,232 questions
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
3,126 questions
{count} votes