Hi,
I have been trying to implement the “New Policy Based Authorization” from:
here.
I can’t get the whole process to work for me. Here’s my scenario:
React SPA application is created and retrieves the token from the authorization server, with the custom created claims in the access token. The API is .net core 2.2, and here are some code snippets from the startup.cs:
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = OktaDefaults.ApiAuthenticationScheme;
options.DefaultChallengeScheme = OktaDefaults.ApiAuthenticationScheme;
options.DefaultSignInScheme = OktaDefaults.ApiAuthenticationScheme;
})
.AddOktaWebApi(new OktaWebApiOptions()
{
OktaDomain = "https://company.oktapreview.com",
AuthorizationServerId = "authserveridgoeshere",
});
services.AddAuthorization(options =>
{
options.AddPolicy("RequireAdminAccess", policy => policy.RequireRole("AppAdmin"));
});
And the controller is pretect with:
[Authorize(Policy = “RequireAdminAccess”)]
[Route(“api/[controller]”)]
[ApiController]
public class ValuesController : ControllerBase
I created a scope and an access policy to include a rule with the new scope. But I am missing the part where I retrieve that scope and apply it in the policy role that should be created.
Thank you in advance.