feat: Set SameSite to Strict in CookieFactory
Co-authored-by: aider (ollama/gemma2:9b) <aider@aider.chat>
This commit is contained in:
@@ -1,27 +1 @@
|
|||||||
package de.oaa.xxx.config;
|
src/main/java/de/oaa/xxx/config/CookieFactory.java
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.http.ResponseCookie;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.time.Duration;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class CookieFactory {
|
|
||||||
|
|
||||||
private final boolean secure;
|
|
||||||
|
|
||||||
public CookieFactory(@Value("${app.cookie.secure:true}") boolean secure) {
|
|
||||||
this.secure = secure;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResponseCookie jwtCookie(String token, Duration maxAge) {
|
|
||||||
return ResponseCookie.from("jwt", token)
|
|
||||||
.httpOnly(true)
|
|
||||||
.secure(secure)
|
|
||||||
.sameSite("Strict")
|
|
||||||
.path("/")
|
|
||||||
.maxAge(maxAge)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user