question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Validating JWT tokens and supporting multiple issuers

See original GitHub issue

moved from: https://github.com/AzureAD/azure-activedirectory-library-for-dotnet/issues/1619

Is your feature request related to a problem? Please describe.

I’m using OpenID Connect (Microsoft.IdentityModel.Protocols.OpenIdConnect 5.4.0 nuget) in my C# web API, and I’d like to support and validate JWT tokens issued by multiple identity providers (MSA, LinkedIn, GitHub, Google, etc.), and I appreciate the fact that Microsoft.IdentityModel.Tokens.TokenValidationParameters supports multiple issuers (via ValidIssuers).

On the other hand Microsoft.IdentityModel.Protocols.ConfigurationManager<OpenIdConnectConfiguration> ctor requires and allows only one metadataAddress (.../.well-known/openid-configuration URL) so I assume it’s possible to download public keys only from one provider, is that correct?

Would it be possible to remove the required metadataAddress param, and use the trusted issuer URL to construct that URL instead? In fact that’s what I’m currently doing for MSA, using the trusted issuer (e.g. https://login.microsoftonline.com/<GUID>/v2.0) and appending /.well-known/openid-configuration. In other words, the library allows multiple trusted issuers, but only one metadata address.

Describe the solution you’d like

Could you provide guidance about supporting multiple identity providers, e.g. sample code or tutorial showing how that works?

Describe alternatives you’ve considered

I considered creating multiple instances of the OpenID Connect manager, one per provider.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
brentschmaltzcommented, Jun 15, 2020

This should be handled by the ASP.Net handler under development.

1reaction
brentschmaltzcommented, May 6, 2020

@MedAnd we developed a model that supports multiple inbound security policies including multiple IDP’s (google, aad, aws, …), authentication schemes (bearer, pop, …), token types (saml1, saml2, jwt, cbor, …).

When a request arrives, processing obtains a policy that can process a specific authentication scheme. It may be the case multiple policies exist (bearer, where both google and aad are trusted).

The contents of the authentication header are examined, hydrated and validated as far possible using the first policy. Since it is possible that multiple policies are in play, intermediate results are maintained when continuing with the next policy. No cpu cycles are wasted, an exception is thrown only if the message cannot be validated by any policy.

Configuration is cached per IDP’s.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Supporting multiple valid issuers in identity server with JWT ...
The options don't have a property for valid issuers. If we only use JWT tokens in authenticating users an alternative is to use...
Read more >
Validate against multiple issuers · Issue #246 · auth0/java-jwt
With the custom validator the issuer claim would still fail if multiple issuers aren't supported, these look like two separate concepts.
Read more >
How to support different JWTs in your Spring Boot application
A practical guide with code examples on how to support multiple JWTs signed by different issuers (in most cases authorization servers).
Read more >
c# - Use multiple JWT Bearer Authentication
LogDebug($"Skipping jwt token validation because token issuer was {token.Issuer} but the authority issuer is: {authorityIssuer}"); return ...
Read more >
How To Validate a JWT Token
JWT tokens are digitally signed (the signature part) using the payload content ... We should validate that the issuer is a valid URL...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found