In my project, I share the same login with two different portals, and users of one portal cannot access the other. To solve this I created claims for user authorization, in my Startup.cs I have the following code snippet:
services.AddAuthorization(options =>
{
options.AddPolicy(Policies.PortalDeComissoesPolicy, policy =>
{
policy.RequireClaim("PortalDeComissoes", "true");
});
});
services.AddAuthentication(o =>
{
o.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
o.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddJwtBearer(options =>
{
options.RequireHttpsMetadata = false;
options.SaveToken = true;
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuerSigningKey = true,
IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII
.GetBytes(Configuration.GetSection("AppSettings:Token").Value)),
ValidateIssuer = false,
ValidateAudience = false
};
});
And the problem is that, when publishing for approval in Azure, all requests are returning "401 Unauthorized", whereas locally on my machine the requests are normal.
I need requests published in the Azure environment to work