Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with Microsoft Entra integration #95

Open
Plactom opened this issue Apr 25, 2024 · 1 comment · May be fixed by #98
Open

Issues with Microsoft Entra integration #95

Plactom opened this issue Apr 25, 2024 · 1 comment · May be fixed by #98

Comments

@Plactom
Copy link

Plactom commented Apr 25, 2024

Hi!

According to this part of Microsoft Entra documentation, the .well-known document is an variable URL that we need to set the {tenant} as one of the following options:

image

I'm using 'common' option and the problem is that in the document (https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration), the "Issuer" key has a {tenantid} in the url.
image

and when i call the discover method like this: discovery = OpenIDConnect::Discovery::Provider::Config.discover!('https://login.microsoftonline.com/common/v2.0') 2 errors occur:

  • Issuer mismatch
  • Issuer is not a valid URL

The first one i solved it with OpenIDConnect.validate_discovery_issuer = false, the second i cannot solve because is a validation that i can't skip.

validates(*uri_attributes.values.flatten, url: true, allow_nil: true)

I commented the line above to continue the authentication flow and check if these were the only problems and the discover! method ran without any other problems, but the id_token.verify! fails and gives a 'Invalid ID token: Issuer does not match' error, because the id_token returned by Microsoft has a iss: 'https://login.microsoftonline.com/9040d.../v2.0' and the discovery.issuer is 'https://login.microsoftonline.com/{tenantid}/v2.0 '

There is something that we can do to resolve the compatibility with Microsoft Entra?

Thanks!

PS: The problem does not occur with specific Microsoft Entra tenant, the problem occurs when i use the 'common' option.

@bufferoverflow
Copy link

bufferoverflow commented Jul 7, 2024

The issuer check must be made optional or pass the issuer received from the token.

bufferoverflow added a commit to bufferoverflow/openid_connect that referenced this issue Jul 7, 2024
This is especially useful when using Microsoft Entra ID common
endpoint, as the issuer could be from another tenant.

When using this parameter it is recommended to set the audience as this
stays the same even if the issuer is from another tenant.

Related omniauth/omniauth_openid_connect#166
Closes nov#95
bufferoverflow added a commit to bufferoverflow/openid_connect that referenced this issue Jul 7, 2024
This is especially useful when using Microsoft Entra ID common
endpoint, as the issuer could be from another tenant.

When using this parameter it is recommended to set the audience as this
stays the same even if the issuer is from another tenant.

Related omniauth/omniauth_openid_connect#166

Closes nov#95
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants