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

Fix/update the content of HttpOnly Page #1038

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

YourBroCode
Copy link
Contributor

update the content of HttpOnly Page according to the JEE 9 regarding cookie check.

Copy link
Contributor

@kingthorin kingthorin left a comment

Choose a reason for hiding this comment

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

All the hyphen to asterisk changes can be reverted, along with the empty line insertion, and the removal of line feed at the end of the file.

Since Java Enterprise Edition 6 (JEE 6), which adopted Java Servlet 3.0
technology, it's programmatically easy to set the HttpOnly flag on a
cookie.
for more information , plwase check [Java EE to Jakarta EE Transition](https://jakarta.ee/about/faq/#what-is-the-java-ee-to-jakarta-ee-transition).
Copy link
Contributor

Choose a reason for hiding this comment

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

please

cookie.setHttpOnly(true); // Mark the cookie as HttpOnly
response.addCookie(cookie);
```
Moreover, since Jakarta EE 9, it's also declaratively easy to set the `HttpOnly` flag for session cookies by applying the following configuration in the deployment descriptor `WEB-INF/web.xml`:
Copy link
Contributor

Choose a reason for hiding this comment

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

The example seems the same as the v6 example, so saying since v9 is misleading

response.setHeader("SET-COOKIE", "JSESSIONID=" + sessionid + "; HttpOnly");

import jakarta.servlet.http.Cookie;
Cookie cookie = new Cookie("sessionId", "abc123");
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't seem like a practical example for a security community

Copy link
Contributor

Choose a reason for hiding this comment

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

Additionally the code seems exactly the same as above so why bother?? Why not make the other "since 8" and skip the 9 example?

In fact, the `setHttpOnly` and `isHttpOnly` methods are available in the [`jakarta.servlet.http.Cookie`](https://jakarta.ee/specifications/servlet/5.0/apidocs/jakarta/servlet/http/Cookie.html) interface, as well as for session cookies (`JSESSIONID`) using [`jakarta.servlet.SessionCookieConfig`](https://jakarta.ee/specifications/servlet/5.0/apidocs/jakarta/servlet/SessionCookieConfig.html):

```java
Cookie cookie = new Cookie("sessionId", "abc123");
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't seem like a practical example for a security community

@kingthorin
Copy link
Contributor

@YourBroCode do you plan to finish this?

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