TokenValidator infers valid issuer from request instead of supporting a set of valid issuers #447
-
Use caseMy identity server instance has a configured IssuerUri in the IdentityServerOptions: authority
Relevant code partsWhen implementing an IExtensionGrantValidator you'll need to validate the incoming token. The default TokenValidator will create TokenValidationParameters on the fly. var parameters = new TokenValidationParameters
{
ValidIssuer = await _issuerNameService.GetCurrentAsync(),
IssuerSigningKeys = validationKeys.Select(k => k.Key),
ValidateLifetime = validateLifetime,
ClockSkew = _options.JwtValidationClockSkew
};As valid issuer is a single value determined through DefaultIssuerNameService. ConclusionWith this default behaviour no access token obtained through mtls or any third party cold be exchanged, without replacing implementation of these mentionend services. Or is there something i am not considering? I suggest that IdentityServerOptions would have a TokenValidationParameters property like the options when registration authentication schemes. This would give control over, which tokens are accepted to be exchanged. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
Short answer: you'll most likely need to implement some custom logic indeed to set the correct |
Beta Was this translation helpful? Give feedback.
-
|
I do wonder where the difference in issuer comes from between the value in the access token and the current issuer name, especially if you've configured the issuer statically using the I've also checked the following scenario's: Configuring an MTLS subdomainIf you set Configuring a fully qualified MTLS domainIf you set
|
Beta Was this translation helpful? Give feedback.
-
|
Thank you very much @wcabus for wondering 👍 . I wanted to prove your statement wrong: And it made me realize that in my case IssuerUri is not set in the options as expected. By setting it, i have a working use case. Without setting it the problem would still stand. I suggested adding validation param options to IdentityServerOptions because also IssuerUri specified there is taken as ValidIssuer. So why not have a set of valid issuers there or a complete validation param object. I don't think each token exchange request must really have unique validation option, even though possible of course. |
Beta Was this translation helpful? Give feedback.
I do wonder where the difference in issuer comes from between the value in the access token and the current issuer name, especially if you've configured the issuer statically using the
IssuerUriproperty: theDefaultIssuerNameServicewill immediately return if theIssuerUrihas been configured, regardless of MTLS being used.I've also checked the following scenario's:
Configuring an MTLS subdomain
If you set
options.MutualTls.DomainName = "mtls";, then the issued access token will contain the original host as theissclaim value (e.g."iss": "https://auth.example.org"(without the mtls subdomain), or will be set to the value ofoptions.IssuerUriif it was statically configured.Configurin…