I have web api which uses jwt bearer authentication. The implementation (openiddict) which creates the jwt uses the the current url as issuer.
services
.AddOpenIddict()
.UseJsonWebTokens();
I configured the jwt authentication handler to use a valid issuer.
services
.AddAuthentication()
.AddJwtBearer(options =>
{
options.Authority = "http://test/";
...
});
When I reach the site under http://test/
I get an access token with the issuer set to http://test/
. As the Authority
matches the issuer the requests will be authenticated.
When I reach the site under http://125.124.35.21/
I get an access token with the issuer set to http://125.124.35.21/
. As the Authority
doesn't match the issuer the request won't be authenticated.
I want in both cases to be able to authenticate the request.
Now I saw that according to the jwt rfc the iss
claim is optional.
My question is if I can set ValidateIssuer
to false for this purpose, if I open a security hole when I do that and if there is an more recommended alternative?
services
.AddAuthentication()
.AddJwtBearer(options =>
{
options.Authority = "http://test/";
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer = false,
...
}
});
Which configuration is used to resolve the .well-known/openid-configuration
?The Authority
? Hopefully not the issuer because that would mean that everybody can issue a token and use it with my api.