-
Notifications
You must be signed in to change notification settings - Fork 188
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
OmniAuth::Strategies::OpenIDConnect::CallbackError, csrf_detected | Invalid 'state' parameter #160
Comments
What SameSite-config do you have? We ran into errors like this after upgrading to Samesite=lax.
So if Microsoft Azure AD supports other response_modes I would suggest removing |
Are you using the gem omniauth-rails_csrf_protection, or have you included something like this? It's needed when using omniauth v2. I remember getting some csrf related errors and adding the gem, plus the |
I believe there are two existing problems: 1. Regarding the loss of state. 2. The issuer is invalid. I have been using the following JSON identity provider configuration: ``` { "name": "https://vufind.reshare-dev.indexdata.com/north/cdl/auth", "scope": [ "https://reshare.palni-palci-staging.notch8.cloud/concern/cdls/74ebfc53-ee7c-4dc9-9dd7-693e4d840745", "openid" ], "issuer": "https://vufind.reshare-dev.indexdata.com/north/cdl/auth", "uid_field": "username", "send_nonce": true, "require_state": false, "response_mode": "form_post", "response_type": "id_token", "client_options": { "host": "vufind.reshare-dev.indexdata.com", "port": "443", "scheme": "https", "secret": "REDACTED", "identifier": "REDACTED", "redirect_uri": "https://reshare.commons-archive.org/users/auth/openid_connect/1/callback", "authorization_endpoint": "/north/cdl/auth" } } ``` Note, for this set of tests, I toggled the original `send_nonce: false` to `send_nonce: true`. I have since restored the setting. **Regarding the Loss of State:** We never hit the callback method in the OmniauthCallbacksController. We continue to encounter the `invalid_state` error in the callback phase. I am stuck on this. I have looked to omniauth/omniauth_openid_connect#160 to fiddle with things, but haven't found any success. **Regarding the Issuer Is Invalid:** Being stuck on the loss of state, I chose to skip those validations to see what next failed. And found something interesting, namely that the issuer is invalid. Which has me wondering if there's something else going on that the "issuer" is dropping/mishandling information. ``` irb(main):001:0> ::OpenIDConnect::Discovery::Provider::Config.discover!("https://vufind.reshare-dev.indexdata.com/north/cdl/auth") Traceback (most recent call last): 1: from (irb):1 OpenIDConnect::Discovery::DiscoveryFailed (Internal Server Error) irb(main):002:0> ::OpenIDConnect::Discovery::Provider::Config.discover!("https://vufind.reshare-dev.indexdata.com/") Traceback (most recent call last): 2: from (irb):1 1: from (irb):2:in `rescue in irb_binding' OpenIDConnect::Discovery::DiscoveryFailed (Not Found) ```
I had the same issue in development, but it was my fault and super easy to fix: I was using "http://127.0.0.1:3000/..." when accessing my app but the callback had to point to a domain, so I had to use "http://localhost:3000/..." for it. This of course doesn't work, because the cookie that contains the state gets lost when the domain is switched by the redirect happening in the callback. Simply always using "http://localhost:3000/..." fixed the issue for me. |
Hi,
I am trying to configure omniauth_openid_connect to work with Devise and Microsoft Azure AD. I have the following config for devise
When attempting to authenticate, I see the following errors in my rails log
Adding
skip_forgery_protection
to myOmniauthCallbacksController
results in just the csrf errorCan anyone offer me any guidance?
Thanks,
Neil
The text was updated successfully, but these errors were encountered: