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

CSRF origin checking failure #131

Closed
bellisk opened this issue Apr 19, 2024 · 2 comments
Closed

CSRF origin checking failure #131

bellisk opened this issue Apr 19, 2024 · 2 comments

Comments

@bellisk
Copy link
Contributor

bellisk commented Apr 19, 2024

Describe the bug
I've deployed my own Ourchive instance following the steps described here, including setting up SSL using certbot and an nginx reverse proxy. POST requests to the site (e.g. creating a new user or new work) were not successful. In the logs was this error (url replaced with http://example.org):

api.custom_exception_handler WARNING 2024-04-19 17:23:13,764 custom_exception_handler 14661 139981757988928 CSRF Failed: Origin checking failed - http://example.org does not match any trusted origins.

The cause seems to be that my site url was not in the CSRF_TRUSTED_ORIGINS constant. After I edited ourchive/ourchive_app/ourchive_app/settings.py like so, the issue was solved.

CSRF_TRUSTED_ORIGINS = [
    "http://127.0.0.1:8000",
    "http://example.org",
    "https://example.org",
]

To Reproduce

  1. Deploy Ourchive to VPS hosting and set up nginx and SSL as described in https://docs.getourchive.io/admin-getting-started/
  2. Try to create a new user or a new work as a logged-in user
  3. Creation will fail, CSRF origin checking failure will be logged

Expected behavior
Creating a new user, new work, etc. should succeed.

Hosting
Digital Ocean droplet running Ubuntu 22.04.

@c-e-p
Copy link
Collaborator

c-e-p commented Apr 22, 2024

This is going to be a documentation/defaults update, will be added to next release.

@c-e-p c-e-p added the bug Something isn't working label Apr 22, 2024
@c-e-p c-e-p added the reviewed label May 9, 2024
@c-e-p c-e-p added the v0.6.0 label Jun 11, 2024
@c-e-p
Copy link
Collaborator

c-e-p commented Jul 7, 2024

So weirdly we "shouldn't" need this in the sense that our own production setup does not need this. I strongly suspect the issue is Nginx config related. One of our 1.0 requirements is people not touching nginx config at all (or touching it less than they do now, relative to Ourchive settings), so I'm going to be tagging this one for 1.0 review. In the meantime, I've added this use case to our troubleshooting in the admin docs.

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

No branches or pull requests

2 participants