/
options.go
73 lines (58 loc) · 1.43 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package authlib
import (
"time"
"go.aporeto.io/a3s/pkgs/permissions"
)
type config struct {
validity time.Duration
opaque map[string]string
audience []string
restrictions permissions.Restrictions
cloak []string
refresh bool
}
func newConfig() config {
return config{
validity: 1 * time.Hour,
}
}
// An Option is the type of various options
// You can add the issue requests.
type Option func(*config)
// OptValidity sets the validity to request for the token.
func OptValidity(validity time.Duration) Option {
return func(opts *config) {
opts.validity = validity
}
}
// OptCloak sets the claims cloaking option for the token.
func OptCloak(cloaking ...string) Option {
return func(opts *config) {
opts.cloak = cloaking
}
}
// OptOpaque passes opaque data that will be
// included in the JWT.
func OptOpaque(opaque map[string]string) Option {
return func(opts *config) {
opts.opaque = opaque
}
}
// OptAudience passes the requested audience for the token.
func OptAudience(audience ...string) Option {
return func(opts *config) {
opts.audience = audience
}
}
// OptRestrictions sets the request restrictions for the token.
func OptRestrictions(restrictions permissions.Restrictions) Option {
return func(opts *config) {
opts.restrictions = restrictions
}
}
// OptRefresh asks for a refresh token.
func OptRefresh(refresh bool) Option {
return func(opts *config) {
opts.refresh = refresh
}
}