From 08ef428913b6a89c5be329c97a781c606ad14038 Mon Sep 17 00:00:00 2001 From: Peter Kieltyka Date: Thu, 21 Jan 2016 15:49:07 -0500 Subject: [PATCH] Add SetExpiry method to Claims type to set a specific expiry time --- jwtauth.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/jwtauth.go b/jwtauth.go index ba37b14..1c4e268 100644 --- a/jwtauth.go +++ b/jwtauth.go @@ -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