Skip to content

Commit

Permalink
[FIX] added set expiry to operators and accounts
Browse files Browse the repository at this point in the history
FIX #6
  • Loading branch information
aricart committed Nov 7, 2023
1 parent dd6ea9d commit 97c3827
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
9 changes: 9 additions & 0 deletions accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ func (a *AccountData) update() error {
return a.issue(key)
}

func (a *AccountData) SetExpiry(exp int64) error {
a.Claim.Expires = exp
return a.update()
}

func (a *AccountData) Expiry() int64 {
return a.Claim.Expires
}

func (a *AccountData) Users() Users {
return &UsersImpl{accountData: a}
}
Expand Down
14 changes: 11 additions & 3 deletions operator.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package authb

import (
"encoding/json"
"errors"
"github.com/nats-io/jwt/v2"
"github.com/nats-io/nkeys"
"github.com/nats-io/nsc/v2/cmd"

"encoding/json"
"errors"
)

func (o *OperatorData) String() string {
Expand Down Expand Up @@ -44,6 +43,15 @@ func (o *OperatorData) SetOperatorServiceURL(url ...string) error {
return o.update()
}

func (o *OperatorData) SetExpiry(exp int64) error {
o.Claim.Expires = exp
return o.update()
}

func (o *OperatorData) Expiry() int64 {
return o.Claim.Expires
}

func (o *OperatorData) OperatorServiceURLs() []string {
return o.Claim.OperatorServiceURLs
}
Expand Down
12 changes: 12 additions & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ type Operator interface {
SetSystemAccount(account Account) error
// MemResolver generates a mem resolver server configuration
MemResolver() ([]byte, error)
// SetExpiry sets the expiry for the operator in Unix Time Seconds.
// 0 never expires.
SetExpiry(exp int64) error
// Expiry returns the expiry for the operator in Unix Time Seconds.
// 0 never expires
Expiry() int64
}

// Accounts is an interface for managing accounts
Expand Down Expand Up @@ -157,6 +163,12 @@ type Account interface {
Exports() Exports
// Limits returns an interface for managing account limits
Limits() AccountLimits
// SetExpiry sets the expiry for the account in Unix Time Seconds.
// 0 never expires.
SetExpiry(exp int64) error
// Expiry returns the expiry for the account in Unix Time Seconds.
// 0 never expires
Expiry() int64
}

// Users is an interface for managing users
Expand Down

0 comments on commit 97c3827

Please sign in to comment.