File tree Expand file tree Collapse file tree 3 files changed +16
-5
lines changed Expand file tree Collapse file tree 3 files changed +16
-5
lines changed Original file line number Diff line number Diff line change 9
9
// Claims must just have a Valid method that determines
10
10
// if the token is invalid for any supported reason
11
11
type Claims interface {
12
+ // Valid implements claim validation. The opts are function style options that can
13
+ // be used to fine-tune the validation. The type used for the options is intentionally
14
+ // un-exported, since its API and its naming is subject to change.
12
15
Valid (opts ... validationOption ) error
13
16
}
14
17
Original file line number Diff line number Diff line change @@ -33,6 +33,6 @@ func WithoutClaimsValidation() ParserOption {
33
33
// WithLeeway returns the ParserOption for specifying the leeway window.
34
34
func WithLeeway (d time.Duration ) ParserOption {
35
35
return func (p * Parser ) {
36
- p .validationOptions = append (p .validationOptions , withLeewayValidator (d ))
36
+ p .validationOptions = append (p .validationOptions , withLeeway (d ))
37
37
}
38
38
}
Original file line number Diff line number Diff line change @@ -4,17 +4,25 @@ import "time"
4
4
5
5
// validationOption is used to implement functional-style options that modify the behavior of the parser. To add
6
6
// new options, just create a function (ideally beginning with With or Without) that returns an anonymous function that
7
- // takes a *ValidatorOptions type as input and manipulates its configuration accordingly.
7
+ // takes a *validator type as input and manipulates its configuration accordingly.
8
+ //
9
+ // Note that this struct is (currently) un-exported, its naming is subject to change and will only be exported once
10
+ // the API is more stable.
8
11
type validationOption func (* validator )
9
12
10
13
// validator represents options that can be used for claims validation
14
+ //
15
+ // Note that this struct is (currently) un-exported, its naming is subject to change and will only be exported once
16
+ // the API is more stable.
11
17
type validator struct {
12
18
leeway time.Duration // Leeway to provide when validating time values
13
19
}
14
20
15
-
16
- // withLeewayValidator is an option to set the clock skew (leeway) windows
17
- func withLeewayValidator (d time.Duration ) validationOption {
21
+ // withLeeway is an option to set the clock skew (leeway) window
22
+ //
23
+ // Note that this function is (currently) un-exported, its naming is subject to change and will only be exported once
24
+ // the API is more stable.
25
+ func withLeeway (d time.Duration ) validationOption {
18
26
return func (v * validator ) {
19
27
v .leeway = d
20
28
}
You can’t perform that action at this time.
0 commit comments