-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopts.go
41 lines (35 loc) · 1.01 KB
/
opts.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package csrf
type Option func(*csrfConfig)
/**
Configure the token name to use when setting the Set-Cookie header.
Defaults to CSRF-Token
*/
func CookieName(name string) Option {
return func(c *csrfConfig) {
c.CookieOpts.CookieName = name
}
}
// Configure the CSRF-Token cookie max age. Defaults to 12 hours
func MaxAge(age int) Option {
return func(c *csrfConfig) {
c.CookieOpts.MaxAge = age
}
}
// Configure if the cookie should only be set over TLS connections. Defaults to true
func Secure(secure bool) Option {
return func(c *csrfConfig) {
c.CookieOpts.Secure = secure
}
}
// Configure the header name to be set by the client application, for which the value should match the cookie sent by the server. Defaults to X-CSRF-Token.
func HeaderName(headerName string) Option {
return func(c *csrfConfig) {
c.HeaderName = headerName
}
}
// CSRF check should be skipped only for these client-agents.
func SkipUserAgents(skip ...string) Option {
return func(c *csrfConfig) {
c.SkipUserAgents = skip
}
}