delegation: tune Nbf & Exp options

This commit is contained in:
Michael Muré
2024-10-14 20:13:49 +02:00
parent 9051e5250b
commit 88ed55b252
2 changed files with 33 additions and 19 deletions

View File

@@ -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.
//