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

Unable to get this to work with Omniauth v2 #11

Open
TigerWolf opened this issue Aug 26, 2022 · 1 comment
Open

Unable to get this to work with Omniauth v2 #11

TigerWolf opened this issue Aug 26, 2022 · 1 comment

Comments

@TigerWolf
Copy link

TigerWolf commented Aug 26, 2022

It looks like Omniauth v2 is quite a big change and it doesnt appear that this works anymore. https://github.com/omniauth/omniauth/wiki/Upgrading-to-2.0

Im trying using the demo application in config.ru and I keep getting CSRF errors.

Sorry that I dont have anything more detailed on this problem.

OmniAuth::Strategies::OAuth2::CallbackError at /auth/cognito-idp/callback
csrf_detected | CSRF detected

file: failure_endpoint.rb location: raise_out! line: 25

@TigerWolf TigerWolf changed the title Unable to get this towork with Omniauth v2 Unable to get this to work with Omniauth v2 Aug 26, 2022
@developius
Copy link

developius commented Jan 23, 2024

For anyone else bumping into a similar issue, make sure you're initiating the sign-in flow with a post request to the local endpoint. You can't redirect to the cognito hosted URL without going through this flow, as the state parameter won't be appended and you'll get a CSRF error like above.

I was able to get this working with:

omniauth (2.1.2)
omniauth-cognito-idp (0.1.1)
omniauth-rails_csrf_protection (1.0.1)

You'll need something like this:

<%= form_with url: "/auth/cognito_idp", method: :post do %>
  <input type="submit" value="Sign in with SSO" />
<% end %>

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

No branches or pull requests

2 participants