Description
It would be good if this package correctly and safely picked the issuer and discovery values for Azure AD. There are nuances about the tentantID and policyName that I'm not super familiar with, and these continue to be reported as issues:
- Allow Query Params in Issuer URL #233
- Auth provider creation does not allow for a URL query string #290
- Azure's OpenID Connect metadata document has a dynamic issuer #245
- Azure custom signing keys #215
- Consider a flag in the config to disable provider/issuer checking #204
- Document Azure "{tenantid}" discovery quirks #212
- The URL to discover and Issue need not be same #159
- Azure AD v1: Unable to verify JWT signature: no matching keys #133
- Azure AD v2.0 fails issuer check when creating provider #121
- Support scenario: AzureAD has "none" signature in ID token returned #350
- Microsoft Entra ID support for appid url parameter #415
Based off of what I've seen, these can be grouped as:
- Azure takes and returns a dynamic "issuer" value in its metadata. Sometimes it has a placeholder "{tenantid}" value, sometimes it doesn't.
- Azure requires a URL query parameter as part of discovery ("?p={policyName}").
- I've also heard that the returned ID token "iss" can sometimes be global and other times tenant specific.
Upstream issues with Azure:
- https://github.com/MicrosoftDocs/azure-docs/issues/38427
- https://github.com/MicrosoftDocs/azure-docs/issues/113944
Current workarounds implemented in go-oidc are the ability to create custom Provider and RemoteKeySet objects without using discovery:
- https://pkg.go.dev/github.com/coreos/go-oidc/v3/oidc#ProviderConfig
- https://pkg.go.dev/github.com/coreos/go-oidc/v3/oidc#NewRemoteKeySet
Open questions are:
- What is the correct issuer value to expect in an ID Token issued by Azure AD? Are these dependent on tenant or policy?
- What is the correct discovery URL to use for Azure AD? Are these dependent on tenant or policy?
- What are the URL parameters consumed by Azure AD? What are the correct values for these?
I've been hesitant to provide concrete advice, since choosing the wrong issuer can be an easy way to end up with a vulnerable application. Maybe it's time to figure this out?
The relevant spec links:
The issuer value returned MUST be identical to the Issuer URL that was directly used to retrieve the configuration information.
https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfigurationValidation
The returned Issuer location MUST be a URI RFC 3986 [RFC3986] with a scheme component that MUST be https, a host component, and optionally, port and path components and no query or fragment components
https://openid.net/specs/openid-connect-discovery-1_0.html#IssuerDiscovery
OpenID Providers supporting Discovery MUST make a JSON document available at the path formed by concatenating the string /.well-known/openid-configuration to the Issuer.
https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfig