Skip to content

Add support for per form csrf tokens - #1653

Merged
namusyaka merged 2 commits into
sinatra:masterfrom
jkowens:per-form-tokens
Feb 14, 2021
Merged

namusyaka merged 2 commits into
sinatra:masterfrom
jkowens:per-form-tokens

Conversation

@jkowens

@jkowens jkowens commented Oct 9, 2020

Copy link
Copy Markdown
Member

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

jkowens commented Jan 5, 2021

Copy link
Copy Markdown
Member Author

@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

jkowens commented Jan 7, 2021

Copy link
Copy Markdown
Member Author

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

@jkowens
jkowens requested a review from namusyaka January 18, 2021 05:11
@namusyaka

Copy link
Copy Markdown
Member

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

@namusyaka namusyaka left a comment

Copy link
Copy Markdown
Member

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

rkh commented Feb 13, 2021

Copy link
Copy Markdown
Member

Code looks good to me. :shipit:

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

Copy link
Copy Markdown

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

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

@mobilutz

mobilutz commented Jul 2, 2021

Copy link
Copy Markdown

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