mirror of
https://forgejo.merr.is/annika/jwtauth.git
synced 2025-12-11 14:53:15 -05:00
Add SetExpiry method to Claims type to set a specific expiry time
This commit is contained in:
parent
4179debd0a
commit
08ef428913
1 changed files with 7 additions and 0 deletions
|
|
@ -233,6 +233,13 @@ func (c Claims) SetIssuedNow() Claims {
|
|||
}
|
||||
|
||||
// Set expiry ("exp") in the claims and return itself so it can be chained
|
||||
func (c Claims) SetExpiry(tm time.Time) Claims {
|
||||
c["exp"] = tm.UTC().Unix()
|
||||
return c
|
||||
}
|
||||
|
||||
// Set expiry ("exp") in the claims to some duration from the present time
|
||||
// and return itself so it can be chained
|
||||
func (c Claims) SetExpiryIn(tm time.Duration) Claims {
|
||||
c["exp"] = ExpireIn(tm)
|
||||
return c
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue