mirror of
https://forgejo.merr.is/annika/jwtauth.git
synced 2025-12-13 12:55:45 -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
|
// 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 {
|
func (c Claims) SetExpiryIn(tm time.Duration) Claims {
|
||||||
c["exp"] = ExpireIn(tm)
|
c["exp"] = ExpireIn(tm)
|
||||||
return c
|
return c
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue