-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
Ability to customize error messages #28
Labels
enhancement
New feature or request
Comments
This came up because Datasette serves confusing messages and I'd like to be able to change those to include links to the relevant documentation: https://docs.datasette.io/en/stable/internals.html#csrf-protection |
simonw
added a commit
that referenced
this issue
Aug 15, 2024
Fixes #28 Add ability to customize error messages in CSRF protection middleware. * Add `ErrorMessageID` enum to `asgi_csrf.py` for error message IDs. * Modify `send_csrf_failed` function to accept an error message ID and a custom error message function. * Update `asgi_csrf_decorator` function to accept a custom error message function. * Update all calls to `send_csrf_failed` to pass the appropriate error message ID and custom error message function. * Add tests in `test_asgi_csrf.py` to verify the custom error message functionality. * Update `README.md` to document the new custom error message functionality and provide examples. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/simonw/asgi-csrf/issues/28?shareId=XXXX-XXXX-XXXX-XXXX).
simonw
added a commit
that referenced
this issue
Aug 15, 2024
Merged
simonw
added a commit
that referenced
this issue
Aug 15, 2024
simonw
added a commit
to simonw/datasette
that referenced
this issue
Aug 15, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The error messages this produces aren't exactly user-friendly:
asgi-csrf/asgi_csrf.py
Lines 146 to 150 in f1a7e28
asgi-csrf/asgi_csrf.py
Lines 168 to 188 in f1a7e28
The text was updated successfully, but these errors were encountered: