-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Kolawole Segun <[email protected]> Co-authored-by: Christian Banse <[email protected]>
- Loading branch information
1 parent
6de17d3
commit d489c99
Showing
6 changed files
with
149 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package jwt | ||
|
||
import "time" | ||
|
||
// validationOption is used to implement functional-style options that modify the behavior of the parser. To add | ||
// new options, just create a function (ideally beginning with With or Without) that returns an anonymous function that | ||
// takes a *validator type as input and manipulates its configuration accordingly. | ||
// | ||
// Note that this struct is (currently) un-exported, its naming is subject to change and will only be exported once | ||
// the API is more stable. | ||
type validationOption func(*validator) | ||
|
||
// validator represents options that can be used for claims validation | ||
// | ||
// Note that this struct is (currently) un-exported, its naming is subject to change and will only be exported once | ||
// the API is more stable. | ||
type validator struct { | ||
leeway time.Duration // Leeway to provide when validating time values | ||
} | ||
|
||
// withLeeway is an option to set the clock skew (leeway) window | ||
// | ||
// Note that this function is (currently) un-exported, its naming is subject to change and will only be exported once | ||
// the API is more stable. | ||
func withLeeway(d time.Duration) validationOption { | ||
return func(v *validator) { | ||
v.leeway = d | ||
} | ||
} |