-
Notifications
You must be signed in to change notification settings - Fork 3
/
options.go
39 lines (33 loc) · 827 Bytes
/
options.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
package passkey
import "time"
type Option func(*Passkey)
// WithLogger sets the logger for the passkey instance.
func WithLogger(l Logger) Option {
return func(p *Passkey) {
if l != nil {
p.l = l
}
}
}
// WithInsecureCookie sets Cookie.Secure to false. This is useful for development. Do not use in production.
func WithInsecureCookie() Option {
return func(p *Passkey) {
p.cookieSettings.Secure = false
}
}
// WithSessionCookieName sets the name of the session cookie.
func WithSessionCookieName(name string) Option {
return func(p *Passkey) {
if name != "" {
p.cookieSettings.Name = name
}
}
}
// WithCookieMaxAge sets the max age of the session cookie.
func WithCookieMaxAge(maxAge time.Duration) Option {
return func(p *Passkey) {
if maxAge > 0 {
p.cookieSettings.MaxAge = maxAge
}
}
}