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?

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.
6,119 questions
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,393 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
20,569 questions
{count} votes