Skip to content

Add optional rack-protection-based CSRF check. - #963

Closed
pat wants to merge 1 commit into
omniauth:masterfrom
pat:optional-rack-protection
Closed

pat wants to merge 1 commit into
omniauth:masterfrom
pat:optional-rack-protection

Conversation

@pat

@pat pat commented Jul 10, 2019

Copy link
Copy Markdown
Contributor

This is related to #809 and related discussions around CVE-2015-9284. OmniAuth::AuthenticityCheck is available to hook into rack-protection (provided that gem is available), and will reject requests that do not come with a CSRF token that matches what's stored in the session. This is useful only in non-Rails applications (whereas otherwise people are better served using the omniauth-rails_csrf_protection gem).

To enable this approach, you will need to set up the before_request_phase hook:

OmniAuth.config.before_request_phase = OmniAuth::AuthenticityCheck.new

… and then ensure your session's csrf token is passed through in each POST request to /auth/:provider, as per the documentation in rack-protection.

This is related to omniauth#809 and related discussions around CVE-2015-9284. `OmniAuth::AuthenticityCheck` is available to hook into `rack-protection` (provided that gem is available), and will reject requests that do not come with a CSRF token that matches what's stored in the session. This is useful in non-Rails applications (whereas otherwise people are better served using the `omniauth-rails_csrf_protection` gem).

To enable this approach, you will need to set up the `before_request_phase` hook: `OmniAuth.config.before_request_phase = OmniAuth::AuthenticityCheck.new` - and then ensure your session's `csrf` token is passed through in each POST request to `/auth/:provider`, as per the documentation in `rack-protection`: https://github.com/sinatra/sinatra/blob/master/rack-protection/lib/rack/protection/authenticity_token.rb.
@BobbyMcWho

Copy link
Copy Markdown
Member

closed via #1010

@BobbyMcWho BobbyMcWho closed this Dec 10, 2020
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 this pull request may close these issues.

2 participants