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

🐛 Change CORS layer construction to allow wildcard #538

Merged
merged 1 commit into from
Dec 26, 2024

Conversation

JMicheli
Copy link
Collaborator

This pull request addresses the problem raised in #537, which causes Stump to fail to start when a wildcard ("*") is used in the allowed origins configuration variable.

The cause is that Axum doesn't like wildcards being added via the AllowOrigin::list() function and wants you to use AllowOrigin::any() instead. I slightly reorganized the server's get_cors_layer() function to detect when a "*" is present in the list of allowed origins and exit early with an AllowOrigin::any() configuration.

I'm making the assumption is that there is no case where the allowed origin list would include a wildcard and then other origins but the user would expect behavior other than any origin being allowed. I think that's right.

Copy link

codecov bot commented Dec 26, 2024

Codecov Report

Attention: Patch coverage is 0% with 35 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
apps/server/src/config/cors.rs 0.00% 35 Missing ⚠️
Files with missing lines Coverage Δ
apps/server/src/config/cors.rs 0.00% <0.00%> (ø)

... and 4 files with indirect coverage changes

Copy link
Collaborator

@aaronleopold aaronleopold left a comment

Choose a reason for hiding this comment

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

This looks great, thank you!!

I'm making the assumption is that there is no case where the allowed origin list would include a wildcard and then other origins but the user would expect behavior other than any origin being allowed. I think that's right.

Yeah I think this is the correct assumption, it doesn't make sense to say "I want any origin, but also this specific one" since it would be covered by the wildcard

@JMicheli JMicheli merged commit 9459fb7 into develop Dec 26, 2024
9 checks passed
@JMicheli JMicheli deleted the jm/cors-wildcard branch December 26, 2024 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants