I have 4 auth servers which validates tokens for incoming request on my app.
I have below configurations in ConfigureServices of Startup.cs
services.AddAuthentication()
.AddJwtBearer("authServer1", options =>
{
options.Authority = "https://authserver1.com/AuthServices/Auth";
options.Audience = "web.api";
})
.AddJwtBearer("authServer2", options =>
{
options.Authority = "https://authserver2.com/AuthServices/Auth";
options.Audience = "web.api";
})
.AddJwtBearer("authServer3", options =>
{
options.Authority = "https://authserver3.com/AuthServices/Auth";
options.Audience = "web.api";
})
.AddJwtBearer("authServer4", options =>
{
options.Authority = "https://authserver4.com/AuthServices/Auth";
options.Audience = "web.api";
});
services.AddAuthorization(options =>
{
options.DefaultPolicy = new AuthorizationPolicyBuilder()
.RequireAuthenticatedUser()
.AddAuthenticationSchemes("authServer1", "authServer2", "authServer3", "authServer4")
.Build();
});
When I call the API, it works fine.
The problem is suppose any of the auth server goes down and I try to call the API then application gives error saying that particular auth server is not found or any error specific to the situation.
1) How can I skip errors which can occur when any of the auth server goes down?
2) How does the policy work when selecting the respective auth server for validating the incoming request? Does it work like switch case (jumps directly to the respective auth server) or if-else ladder (checks each auth server for request validation until it find the actual one)