# Struts2 的 CSP 在 session 使用預設名 nonce Struts2 升級 6.2.0 後,多了 Content Security Policy (CSP) 功能, DefaultCspSettings 中的 associatenonceWithSession() 會在 session 中使用 **nonce** 作為預設名稱。 以下是 DefaultCspSettings 內 associatenonceWithSession() 的內容 ```=java! private void associateNonceWithSession(HttpServletRequest request) { String nonceValue = Base64.getUrlEncoder().encodeToString(getRandomBytes()); request.getSession().setAttribute("nonce", nonceValue); } ``` 因此若為Struts2 6.2.0 以後的版本,須避免在 session 使用 nonce 作為其他用途,或是值遭覆蓋。 如 google 第三方登入同樣以 nonce 作為 session 的預設名,使用上須避免遭覆蓋。
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up