Skip to content

Commit de78b7b

Browse files
qbartaldas
authored andcommitted
Update CSRF doc with cookie option and example
1 parent d249a43 commit de78b7b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

website/content/middleware/csrf.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ CSRFConfig struct {
5757
// - "header:<name>"
5858
// - "form:<name>"
5959
// - "query:<name>"
60+
// - "cookie:<name>"
6061
TokenLookup string `json:"token_lookup"`
6162

6263
// Context key to store generated CSRF token into context.
@@ -101,3 +102,16 @@ DefaultCSRFConfig = CSRFConfig{
101102
CookieMaxAge: 86400,
102103
}
103104
```
105+
106+
107+
*Example Configuration that reads token from Cookie*
108+
109+
```go
110+
middleware.CSRFWithConfig(middleware.CSRFConfig{
111+
TokenLookup: "cookie:_csrf",
112+
CookiePath: "/",
113+
CookieDomain: "example.com",
114+
CookieSecure: true,
115+
CookieHTTPOnly: true,
116+
CookieSameSite: http.SameSiteStrictMode,
117+
})

0 commit comments

Comments
 (0)