Skip to content

Commit bd7fd56

Browse files
authored
docs: note CSRF ContextKey removal (#3706)
1 parent 5c403cd commit bd7fd56

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

docs/whats_new.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,6 +1115,8 @@ We've added support for `zstd` compression on top of `gzip`, `deflate`, and `bro
11151115

11161116
The `Expiration` field in the CSRF middleware configuration has been renamed to `IdleTimeout` to better describe its functionality. Additionally, the default value has been reduced from 1 hour to 30 minutes.
11171117

1118+
The `ContextKey` field has been removed. Tokens and handlers are now stored using unexported keys; retrieve them with `csrf.TokenFromContext(c)` or `csrf.HandlerFromContext(c)`.
1119+
11181120
### EncryptCookie
11191121

11201122
Added support for specifying key length when using `encryptcookie.GenerateKey(length)`. Keys must be base64-encoded and may be 16, 24, or 32 bytes when decoded, supporting AES-128, AES-192, and AES-256 (default).
@@ -2107,6 +2109,13 @@ app.Use(csrf.New(csrf.Config{
21072109
}))
21082110
```
21092111

2112+
- **ContextKey Removal**: The `ContextKey` field has been removed from the CSRF middleware configuration. Access the token and handler using helper functions instead:
2113+
2114+
```go
2115+
token := csrf.TokenFromContext(c)
2116+
handler := csrf.HandlerFromContext(c)
2117+
```
2118+
21102119
- **Session Key Removal**: The `SessionKey` field has been removed from the CSRF middleware configuration. The session key is now an unexported constant within the middleware to avoid potential key collisions in the session store.
21112120

21122121
- **KeyLookup Field Removal**: The `KeyLookup` field has been removed from the CSRF middleware configuration. This field was deprecated and is no longer needed as the middleware now uses a more secure approach for token management.

0 commit comments

Comments
 (0)