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

using POST request will require lax session handling #139

Open
BooVeMan opened this issue Feb 2, 2021 · 0 comments
Open

using POST request will require lax session handling #139

BooVeMan opened this issue Feb 2, 2021 · 0 comments

Comments

@BooVeMan
Copy link

BooVeMan commented Feb 2, 2021

Using the this strategy in conjunction with omniauth 2.0 will fail wehen using the recommended POST request towards twitter as the session will be lost when returning to the callback (e.g. session["oauth"]will be nil). The only way I found to fix this is to set the same_site policy to :lax. I do this by hooking into the before_request_phase callback:

OmniAuth.config.before_request_phase do |env|
  # twitter using post will require lax session handling
  if env["omniauth.strategy"]&.name == "twitter"
    env["rack.session"].instance_variable_get(:@by).instance_variable_set(:@same_site, :lax)
  end
end

and resetting it in the callback:

    def twitter
      # reset to strict session handling
      session.instance_variable_get(:@by).instance_variable_set(:@same_site, :strict)
      ... handle callback ...
    end

this seems very brittle and hackish, any other solution?

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

No branches or pull requests

1 participant