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

Update Javadoc on CORS in spring-websocket #26753

Closed
kbuntrock opened this issue Apr 2, 2021 · 1 comment
Closed

Update Javadoc on CORS in spring-websocket #26753

kbuntrock opened this issue Apr 2, 2021 · 1 comment
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: documentation A documentation task
Milestone

Comments

@kbuntrock
Copy link

kbuntrock commented Apr 2, 2021

According to the documentation, the iframe fallback is useful for transports with no native cross-domain communication.
See :

* Transports with no native cross-domain communication (e.g. "eventsource",

But when configuring my app for allowing a specific origin, and when my client request the Iframe, this bloc of code prevent me from getting it :

if (!getAllowedOrigins().isEmpty() && !getAllowedOrigins().contains("*") ||

This bloc of code seems to say I could bypass it by setting "*" in allowOrigins. But it then conflicts with the "Access-Control-Allow-Credentials" set to true, which is forbidden for the "*" regex.
https://docs.spring.io/spring-framework/docs/5.3.2/reference/html/web.html#websocket-fallback-sockjs-overview)

I have the feeling there is a contradiction here. For some transport, I need and iframe when I want to do cross-domain communication. But the very same process of providing an iframe is restricted if I want to access it cross-domain.

Is this code outdated and need an update? Or am I missing a point? If option one, I can work on the PR.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Apr 2, 2021
@rstoyanchev
Copy link
Contributor

In 5.3 we no longer allow allowedOrigins to be "*" in combination with "Allow-Credentials". Instead you can use the allowedOriginPatterns property which also allows more flexible patterns.

I can see that the Javadoc for WebSocketHandlerRegistration#setAllowedOrigins doesn't explicitly mention this the way that CorsConfiguration#setAllowedOrigins does. I'll update that.

@rstoyanchev rstoyanchev self-assigned this Apr 6, 2021
@rstoyanchev rstoyanchev added in: web Issues in web modules (web, webmvc, webflux, websocket) type: documentation A documentation task and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Apr 6, 2021
@rstoyanchev rstoyanchev modified the milestones: 5.3.6, 5.3.7 Apr 6, 2021
@rstoyanchev rstoyanchev changed the title Iframe and cross origin request Update Javadoc on CORS in spring-websocket Apr 13, 2021
Zoran0104 pushed a commit to Zoran0104/spring-framework that referenced this issue Aug 20, 2021
lxbzmy pushed a commit to lxbzmy/spring-framework that referenced this issue Mar 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: documentation A documentation task
Projects
None yet
Development

No branches or pull requests

3 participants