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

OpenGrokProject cookie misusing the sameSite attribute #3164

Closed
vladak opened this issue Jun 8, 2020 · 6 comments
Closed

OpenGrokProject cookie misusing the sameSite attribute #3164

vladak opened this issue Jun 8, 2020 · 6 comments
Assignees
Labels

Comments

@vladak
Copy link
Member

vladak commented Jun 8, 2020

FF 76 claims this when loading the index page with developer tab on:

Cookie “OpenGrokProject” will be soon rejected because it has the “sameSite” attribute set to “none” or an invalid value, without the “secure” attribute. To know more about the “sameSite“ attribute, read https://developer.mozilla.org/docs/Web/HTTP/Cookies

Not sure this is related to my deployment however this is something we might need to investigate.

@tulinkry
Copy link
Contributor

tulinkry commented Jun 8, 2020

This is a new thing introduced lately in the browser's security and enforced by browsers at the moment. It's about limiting the cookies usage in third-party contexts. (It's not connected to your setup)

@vladak
Copy link
Member Author

vladak commented Jun 8, 2020

For the record the cookie is born in list.jsp like this:

Cookie cookie = new Cookie(PageConfig.OPEN_GROK_PROJECT, URLEncoder.encode(cookieValue, "utf-8"));

and the J2EE object allows to set the secure attribute however not sameSite it seems.

@vladak
Copy link
Member Author

vladak commented Jun 8, 2020

This is a new thing introduced lately in the browser's security and enforced by browsers at the moment. It's about limiting the cookies usage in third-party contexts. (It's not connected to your setup)

okay, so something we will need to address.

@vladak vladak added bug and removed question labels Jun 8, 2020
@tulinkry
Copy link
Contributor

tulinkry commented Jun 8, 2020

As this is a new thing, it may require to update the servlet-api (where the Cookie object is). More details is at jakartaee/servlet#175 (wasn't looking all through that, so it may not be resolved yet).

If update is not applicable, we'd need to set the cookie directly, so instead of:

response.addCookie(myCookie)

we need:

response.setHeader("Set-Cookie", "key=value; HttpOnly; SameSite=<sameSiteValue>")

@tulinkry
Copy link
Contributor

tulinkry commented Jun 8, 2020

As I was already tackling this in my company, I had a problem when multiple cookies were being set at a time - if this is experienced - it is possible to use one Set-Cookie directive and join the cookies with ;; separator.

@vladak
Copy link
Member Author

vladak commented Sep 22, 2020

I went through the debate on the EE4J PR and there seems to be a great deal of complexity w.r.t. getting this API in for such small change. Even if the PR was merged in, we would have to do some bunny hops to get to the new Servlet API. jakartaee/servlet#271 (comment) suggests to configure this on the container level (Tomcat) however I'd like to have the control in the web app.

vladak pushed a commit to vladak/OpenGrok that referenced this issue Sep 23, 2020
@vladak vladak self-assigned this Sep 23, 2020
@vladak vladak closed this as completed in df8ef63 Sep 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants