I have 2 Auth0 accounts which generating the jwt token when client login from either of the account. I already know how to authenticate the token in my Web API for 1 domain and it is working fine. I want to know how to authenticate for 2 Auth0 domains. Right now it is authenticating all the users on tldev111.auth0.com domain and i want to authenticate users on tldev123.auth0.com domain too
Startup.cs–
public void Configuration(IAppBuilder app)
{
var domain = $"https://{ConfigurationManager.AppSettings["Auth0Domain"]}/";
var apiIdentifier = ConfigurationManager.AppSettings["Auth0ApiIdentifier"];
var keyResolver = new OpenIdConnectSigningKeyResolver(domain);
app.UseJwtBearerAuthentication(
new JwtBearerAuthenticationOptions
{
AuthenticationMode = AuthenticationMode.Active,
TokenValidationParameters = new TokenValidationParameters()
{
ValidAudience = apiIdentifier,
ValidIssuer = domain,
IssuerSigningKeyResolver = (token, securityToken, kid, parameters) => keyResolver.GetSigningKey(kid)
}
});
// Configure Web API
WebApiConfig.Configure(app);
}
WebApiConfig -
public static void Configure(IAppBuilder app)
{
HttpConfiguration config = new HttpConfiguration();
// Web API routes
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional });
app.UseWebApi(config);
}
web.config app settings–
<appSettings>
<add key="Auth0Domain" value="tldev111.auth0.com" />
<add key="Auth0ApiIdentifier" value="https://aaa/SRTAPI/api" />