delegation: tune Nbf & Exp options
This commit is contained in:
@@ -24,8 +24,8 @@ func WithExpiration(exp time.Time) Option {
|
||||
}
|
||||
}
|
||||
|
||||
// WithExpirationAfter set's the Token's optional "expiration" field to Now() plus the given duration.
|
||||
func WithExpirationAfter(exp time.Duration) Option {
|
||||
// WithExpirationIn set's the Token's optional "expiration" field to Now() plus the given duration.
|
||||
func WithExpirationIn(exp time.Duration) Option {
|
||||
return func(t *Token) error {
|
||||
expTime := time.Now().Add(exp)
|
||||
t.expiration = &expTime
|
||||
@@ -57,6 +57,16 @@ func WithNotBefore(nbf time.Time) Option {
|
||||
}
|
||||
}
|
||||
|
||||
// WithNotBeforeIn set's the Token's optional "notBefore" field to the value
|
||||
// of the provided time.Time.
|
||||
func WithNotBeforeIn(nbf time.Duration) Option {
|
||||
return func(t *Token) error {
|
||||
nbfTime := time.Now().Add(nbf)
|
||||
t.notBefore = &nbfTime
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// WithSubject sets the Tokens's optional "subject" field to the value of
|
||||
// provided did.DID.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user