I have a web API application developed with .Net Core 5 where I have implemented the authorization using OIDC 2, therefore using a JWT bearer token.
Now I need to put this application behind a corporate API Gateway which acts like a proxy, that requires additional authorization. The requests therefore should have two authorization tokens, one for the API Gateway and another one for the application itself.
The Gateway administrator has told me to modify my code in order to process a request like the following:
curl -X GET "https://api-gateway.some-domain.org/my-application/some-endpoint"
-H "accept: application/json"
-H "MyApp-Authorization: Bearer JGVFISOODISJ..."
-H "Authorization: Bearer FVJIDOSJFMDSIO..."
I have understood from the administrator response that I should modify how it is configured the authentication in my application, in the startup file maybe.
Currently I've configured in the following way:
public void ConfigureServices(IServiceCollection services)
{
//...
//Add ASP.NET Core Identity Services
services.AddIdentity<IdentityUser, IdentityRole>()
.AddEntityFrameworkStores<RPToolDBContext>()
.AddSignInManager<SignInManager<IdentityUser>>();
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(appSettings.Secret));
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(opt =>
{
opt.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuerSigningKey = true,
IssuerSigningKey = key,
ValidateAudience = false,
ValidateIssuer = false,
ValidateLifetime = true,
ClockSkew = TimeSpan.Zero
};
})
.AddAzureAdBearer(options => Configuration.Bind("AzureAd", options));
//...
}
What do I need to change in order to modify the attribute name?
Obviously, I think I need to change also the code in the front-end, which is developed in REACT using the MSAL library, in order to work with the new header...