-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
Ignore trailing slash in CorsConfiguration origin patterns #26892
Comments
We already ignore any trailing slash in The port number cannot be ignored by default as it is part of what defines a cross-domain request. We can enhance the pattern syntax, maybe a comma separated list of ports or a wildcard:
|
Yeah, that actually makes sense. |
Related to spring-projects/spring-framework#26892 The WebSocket tests with `allowedOrigins` fail now because CORS processor in Spring Framework removes a trailing slash from the request where possible one in the config is left as is. * Remove the trailing slash from the CORS config to match the current SF behavior
Specifying multiple patterns (so doing just dddcc5e as part of this issue) or improving the pattern syntax as well as you proposed @rstoyanchev sounds both ok to me, so up to you if we add this capability or not. |
This commit ensures that if an Origin is returned as it was provided, possibly with a trailing slash. See gh-26892
I've created #26926 to separate that as enhancement. We're too close to the 5.3.7 release to add that and it would be useful to collect more feedback. |
Recent commit dddcc5e ensured a trailing "/" in the Origin header has no effect. This commit does the same for a trailing "/" in configured patterns. See spring-projectsgh-26892
This commit ensures that if an Origin is returned as it was provided, possibly with a trailing slash. See spring-projectsgh-26892
Affects: v5.3.6
It's connected to #24763 - CorsConfiguration based on pattern matching.
While feature itself works really well, I found few corner cases where it's difficult to configure such patterns because of limitations that current pattern syntax provides.
https://*.company.domain
should match bothhttps://test.company.domain
andhttps://test.company.domain/
. One workaround would be to add two different patterns, one with trailing slash and one without.https://*.company.domain*
could matchhttps://test.company.domain:80
as well ashttps://test.company.domain.some.other.domain
which is not what intended. Workaround here can be also creating two origins patterns:https://*.company.domain
andhttps://*.company.domain:*
.http
andhttps
in a single pattern.While there are workarounds as mentioned before, I think this should be supported out of the box (at least 1 & 2). What's more if you want to support 1 & 2 right now you would effectively either would need to create 4 different patterns or if you know how this is working inside spring you would end up with following pattern in your configuration:
https://*.company.domain\\E\(:\\d+)?/?\\Q
. Which is probably not the best approach either.I see two possible solutions:
The text was updated successfully, but these errors were encountered: