-
-
Notifications
You must be signed in to change notification settings - Fork 700
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
Consider dropping explicit CSRF protection entirely? #877
Comments
Sounds like regular CSRF protection to me. |
Relevant: #835 |
Does this mean custom routes get to expose endpoints accepting POST requests? I've tried earlier to add some POST endpoints, but requests were being rejected by Datasette due to CSRF |
Have you tried the method described here? https://datasette.readthedocs.io/en/latest/internals.html#csrf-protection - I'm happy to bulk out that section of the documentation if that doesn't help solve your problem. I just closed #835 which should make CSRF protection easier to work with - it won't interfere with requests without cookies or requests with You can try out |
I am calling the API from another origin, so injecting CSRF token into templates wouldn't work. EDIT: I'll try the new version, it sounds promising |
Bearer tokens sound interesting. Where do tokens come from? An auth provider of my choosing? How do they get verified? |
Tokens get verified by plugins. So far there's only one: https://github.com/simonw/datasette-auth-tokens - which has you hard-coding plugins in a configuration file. I have a issue there to add support for database-backed tokens too: simonw/datasette-auth-tokens#1 |
The latest release of https://github.com/simonw/datasette-auth-tokens (0.2) now supports SQL configuration of tokens. |
I'm not going to drop CSRF protection - it's still needed for older browsers - but I have relaxed the circumstances under which it is applied. It only applies to requests that include cookies for example, so API clients that don't send cookies don't need to worry about it. |
https://scotthelme.co.uk/csrf-is-dead/ from Feb 2017 has background here. The
SameSite=lax
cookie property effectively eliminates CSRF in modern browsers. https://caniuse.com/#search=SameSite shows 92.13% global support for it.Datasette already uses
SameSite=lax
when it sets cookies by default:datasette/datasette/utils/asgi.py
Lines 327 to 341 in af350ba
A few options then. I could ditch CSRF protection entirely. I could make it optional - turn it off by default, but let users who care about that remaining 7.87% of global users opt back into it.
One catch: login CSRF: I don't see how
SameSite=lax
protects against that attack.The text was updated successfully, but these errors were encountered: