你知道任何允许为cookie设置自定义标志的JAVA Cookie实现(比如SameSite = strict)吗?它似乎SameSite=strict有严格限制的标志,可以添加.
如何为在 Wildfly 上运行的 Web 应用程序启用相同站点。已检查standalone.xml但无法在其中找到合适的标签
<servlet-container name="default">
<session-cookie http-only="true" secure="true"/>
<jsp-config/>
</servlet-container>
Run Code Online (Sandbox Code Playgroud) 是否可以在 Spring Boot 中设置Same-Site Cookie标志?
我在 Chrome 中的问题:
与http://google.com/上的跨站点资源关联的 cookie 设置为没有该
SameSite属性。未来版本的 Chrome 将仅在跨站点请求中使用SameSite=None和设置 cookie 时才传送 cookieSecure。您可以在应用程序>存储>Cookies 下的开发人员工具中查看 cookie,并在https://www.chromestatus.com/feature/5088147346030592和 https://www.chromestatus.com/feature/5633521622188032 上查看更多详细信息 。
如何解决这个问题呢?
我无法将 SameSite cookie 值设置为无。
以下是我如何生成 ResponseCookie 对象。
ResponseCookie cookie = ResponseCookie.from("Hb", cookieUserId)
.maxAge(!isEmpty(cookieUserId) ? MAX_COOKIE_DURATION : 0)
.domain("test.com")
.sameSite("None")
.secure(true)
.path("/")
.build();
response.addCookie(cookie)
Run Code Online (Sandbox Code Playgroud)
对端点的卷曲请求
curl -X POST "localhost:8080/v1/user/v" --data "{}" -v -H 'Content-Type: application/json'
Run Code Online (Sandbox Code Playgroud)
回复:
< set-cookie: Hb=00b7be31-fc6d-4891-a07c-46b5ef2b423c; Max-Age=7776000; Expires=Fri, 8 Nov 2019 17:23:52 GMT; Path=/; Domain=test.com; Secure
Run Code Online (Sandbox Code Playgroud)
如您所见,cookie 中缺少 SameSite 属性。
Spring Boot(版本:2.1.3.RELEASE)依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
Run Code Online (Sandbox Code Playgroud) 我在 Cookie 中设置 SameSite 属性时遇到问题。我想设置这个属性,但既没有javax.servlet.http.Cookie也没有java.net.HttpCookie提供处理它的方法。因此,我有一个想法来创建一个响应javax.servlet.Filter以捕获“Set-Cookie”标头并添加“SameSite=Strict”属性。
response.setHeader("Set-Cookie", response.getHeader("Set-Cookie") + "; SameSite=strict");
Run Code Online (Sandbox Code Playgroud)
它工作正常,但是当我在一个响应中有多个“Set-Cookie”标头时出现问题。javax.servlet.http.HttpServletResponse不提供删除或覆盖多个具有相同名称的 heder 的方法(迭代它们并使用setHeader()不起作用,因为它总是设置最后一个)。您知道如何将 SameSite 属性设置为 cookie 或如何覆盖响应过滤器中的标头吗?
提前致谢。
将 jsessionId cookie 设置为 SameSite=Strict 的 spring-boot 配置是什么。
JsessionId需要添加SameSite=Strict或者现有的cookie而不是新的cookie生成。是否支持?
在Spring Security中可以设置Same-site Cookie标志吗?请参阅:https : //tools.ietf.org/html/draft-west-first-party-cookies-07 ,如果没有,请问是否有增加支持的路线图?某些浏览器(例如Chrome)已经支持。TH
cookies ×7
java ×4
security ×3
spring-boot ×3
samesite ×2
csrf ×1
flags ×1
http ×1
jsessionid ×1
spring ×1
web ×1
wildfly-10 ×1