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

Add support for per form csrf tokens #1653

Merged
merged 2 commits into from Feb 14, 2021
Merged

Conversation

jkowens
Copy link
Member

@jkowens jkowens commented Oct 9, 2020

Resolves #1616. Makes CSRF tokens more secure (see: rails/rails#22275).

To generate a per form authenticity token, pass the path and optionally the form method (method defaults to post):

Rack::Protection::AuthenticityToken.token(session, path: '/foo')

Model the implementation after Rails to provide cross compatibility.
@jkowens
Copy link
Member Author

jkowens commented Jan 5, 2021

@namusyaka any chance we could release this soon if it looks good? I found this will be really useful for a Rails project where I depend on omniauth (which will be using rack-protection in the 2.0 release).

See: omniauth/omniauth#1017

@jkowens
Copy link
Member Author

jkowens commented Jan 7, 2021

@namusyaka thanks for the review. I made updates based on your comments 👍

@namusyaka
Copy link
Member

Sorry I'll take a look at this next month.. 🙇

Copy link
Member

@namusyaka namusyaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving for the code.

@jkowens I'm sorry for the late reply.
@rkh Could you also take a look at this?

@namusyaka namusyaka requested a review from rkh February 12, 2021 19:32
@rkh
Copy link
Member

rkh commented Feb 13, 2021

Code looks good to me. :shipit:

@namusyaka namusyaka merged commit ed2add3 into sinatra:master Feb 14, 2021
@mobilutz
Copy link

Thanks @jkowens for working on this.
And thanks @namusyaka for merging this 😉

Looking forward to the new rack-protection version ...

@mobilutz
Copy link

mobilutz commented Jul 2, 2021

Does anyone know, if there will be a release before v3.0.0 with this change?

I know that v3.0.0 is being worked on, but maybe we can have a 2.2.0 release in the meantime?

Thanks

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

Successfully merging this pull request may close these issues.

Rack::Protection together with Rails >=5.2.4.3 & >= 6.0.3.1 - CSRF check is broken
4 participants