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

Wrong usage of SameSite cookie param in TokenResource #4159

Closed
florian-h05 opened this issue Mar 25, 2024 · 5 comments · Fixed by #4160
Closed

Wrong usage of SameSite cookie param in TokenResource #4159

florian-h05 opened this issue Mar 25, 2024 · 5 comments · Fixed by #4160
Labels
bug An unexpected problem or unintended behavior of the Core

Comments

@florian-h05
Copy link
Contributor

florian-h05 commented Mar 25, 2024

When logging in to Main UI , Firefox is printing this warning to the log:

Cookie “X-OPENHAB-SESSIONID” does not have a proper “SameSite” attribute value.
Soon, cookies without the “SameSite” attribute or with an invalid value will be treated as “Lax”.
This means that the cookie will no longer be sent in third-party contexts.
If your application depends on this cookie being available in such contexts, please add the “SameSite=None“ attribute to it.
To know more about the “SameSite“ attribute, read https://developer.mozilla.org/docs/Web/HTTP/Headers/Set-Cookie/SameSite

Also see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value.

I would like to set SameSite to strict, which is supported by the javax.ws.rs.core.NewCookie (see jakartaee/rest#868) since JakartaEE 3.1, however is the change from the linked PR not available.

How do I found out the version of Jakarta EE in use by core?

@J-N-K May I ask for your help?

@florian-h05 florian-h05 added the bug An unexpected problem or unintended behavior of the Core label Mar 25, 2024
@J-N-K
Copy link
Member

J-N-K commented Mar 25, 2024

Our implementation is provided by org.apache.aries.spec/org.apache.aries.javax.jax.rs-api/1.0.4 which indeed does not contain what you need. Latest PaxWeb now uses jakarta.ws.rs/jakarta.ws.rs-api/2.1.6 which does not contain the extensions as well, however jakarta.ws.rs/jakarta.ws.rs-api/3.1.0 does.

@florian-h05
Copy link
Contributor Author

Hmm okay.

Is there a way to get jakarta.ws.rs/jakarta.ws.rs-api/3.1.0 without causing dependency trouble? (I guess no)

@J-N-K
Copy link
Member

J-N-K commented Mar 25, 2024

No, probably not. Because of the namespace change from javax to jakarta it would be very hard. Do you think we can just create a OhCookie implementation ourself (probably on top of NewCookie) which contains the changes in the linked PR?

@florian-h05
Copy link
Contributor Author

Should be possible.
What about licensing in this case?

florian-h05 added a commit to florian-h05/openhab-core that referenced this issue Mar 25, 2024
…cookie

Fixes openhab#4159.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
@florian-h05
Copy link
Contributor Author

Unfortunately, creating our own cookie implementation doesn't help, because the servlet seems to also need an adjustment. However I found another simple workaround, see #4160.

J-N-K pushed a commit that referenced this issue Mar 27, 2024
…4160)

* [rest] TokenResource: Properly set SameSite attribute for session id cookie

Fixes #4159.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of the Core
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants