Skip to content

Remove custom CORS logic #9945

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

Merged
merged 4 commits into from
Feb 1, 2023
Merged

Remove custom CORS logic #9945

merged 4 commits into from
Feb 1, 2023

Conversation

stsewd
Copy link
Member

@stsewd stsewd commented Jan 25, 2023

We don't need this logic anymore, we don't allow passing cookies, so just checking the list of allowed URLs is enough.

@stsewd stsewd requested a review from a team as a code owner January 25, 2023 20:22
@stsewd stsewd requested a review from humitos January 25, 2023 20:22
Comment on lines +23 to +24
# We don't need or want to allow cross site requests in proxito.
CORS_URLS_ALLOW_ALL_REGEX = []
Copy link
Member Author

Choose a reason for hiding this comment

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

removing the middleware should be enough, but just in case if we added it here we don't want to inherit the endpoints from the dashboard.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry to have to post a comment in a merged PR. I'm trying to understand what the security hardening was about to write a sentence or two in the newsletter. Which landed me here.

And that had me wondering that I cannot find CORS_URLS_ALLOW_ALL_REGEX in the documentation of django-cors-headers: https://pypi.org/project/django-cors-headers/

But I was looking at the wrong project.

We seem to be using this one: https://pypi.org/project/django-cors-headers/ - which hasn't been updated for 4 years and has 135 stars. django-cors-headers is cruising at over 4800 stars :)

It looks like it's been previously "saved by the bell" so to speak: #4694 - but maybe this is a good "tech debt" roadmap candidate.

oh yeah and that configuration setting is:

Specify a list of URL regex for which to allow all origins

So I guess that in all other cases, we are setting CORS headers to deny. I'll probably be asking how it works and what we changed :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, we are using the forked version, but we should be able to migrate to the new version, see #8713, we just need to be careful making sure the settings from the fork match the settings from the new package.

I'll probably be asking how it works and what we changed :)

Before we were allowing cross site requests allowing credentials to be passed, now we are allowing cross site requests as before, but we don't allow credentials to be passed (cookies).

@stsewd stsewd merged commit c0b4276 into main Feb 1, 2023
@stsewd stsewd deleted the remove-custom-cors-logic branch February 1, 2023 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants