Documentation
¶
Index ¶
- Variables
- func DefaultKeyFunc(key Key, deprecatedKeys map[string]Key) jwt.Keyfunc
- func NewKeysFromFilenames(publicKeyPemFilename, privateKeyPemFilename string, ...) (Key, []Key, error)
- func NewRegisteredClaims(opts ...RegisteredClaimsOption) jwt.RegisteredClaims
- func NewRegisteredClaimsWithLifetime(lifetime time.Duration, opts ...RegisteredClaimsOption) jwt.RegisteredClaims
- func NewStandardClaims() jwt.RegisteredClaimsdeprecated
- func NewStandardClaimsWithLifetime(lifetime time.Duration) jwt.RegisteredClaimsdeprecated
- type JWT
- type Key
- type Option
- type RegisteredClaimsOption
Constants ¶
This section is empty.
Variables ¶
var MaxTimeDifferenceBetweenNodes = 30 * time.Second
MaxTimeDifferenceBetweenNodes represents an offset that should be taken into account when creating e.g. jwt tokens with the `notBefore` flag.
Functions ¶
func NewKeysFromFilenames ¶
func NewKeysFromFilenames(publicKeyPemFilename, privateKeyPemFilename string, deprecatedPublicKeyPemFilenames []string) (Key, []Key, error)
NewKeysFromFilenames helper
func NewRegisteredClaims ¶ added in v0.23.0
func NewRegisteredClaims(opts ...RegisteredClaimsOption) jwt.RegisteredClaims
NewRegisteredClaims returns a new jwt.RegisteredClaims with the IssuedAt and NotBefore fields set to the current time plus the given offset. The offset can be used to account for time differences between nodes in a distributed system. If no offset option is provided, MaxTimeDifferenceBetweenNodes is used as the default.
func NewRegisteredClaimsWithLifetime ¶ added in v0.23.0
func NewRegisteredClaimsWithLifetime(lifetime time.Duration, opts ...RegisteredClaimsOption) jwt.RegisteredClaims
NewRegisteredClaimsWithLifetime returns a new jwt.RegisteredClaims with the IssuedAt and NotBefore fields set to the current time plus the given optional offset and the ExpiresAt field set to the current time plus the given lifetime.
func NewStandardClaims
deprecated
func NewStandardClaims() jwt.RegisteredClaims
Deprecated: NewStandardClaims use NewRegisteredClaims instead.
func NewStandardClaimsWithLifetime
deprecated
func NewStandardClaimsWithLifetime(lifetime time.Duration) jwt.RegisteredClaims
Deprecated: NewStandardClaimsWithLifetime use NewRegisteredClaimsWithLifetime instead.
Types ¶
type JWT ¶
type JWT struct {
// key for signing
Key Key
// KeyFunc provider
KeyFunc jwt.Keyfunc
// DeprecatedKeys e.g. due to rotation
DeprecatedKeys map[string]Key
}
type Key ¶
type Key struct {
// ID (required) represents the key identifier e.g. the md5 representation of the public key
ID string
// Public (required) rsa key
Public *rsa.PublicKey
// Private (optional) rsa key
Private *rsa.PrivateKey
}
func NewDeprecatedKeysFromFilenames ¶
NewDeprecatedKeysFromFilenames returns new Keys from the given file names
func NewKeyFromFilenames ¶
NewKeyFromFilenames returns a new Key from the given file names
type RegisteredClaimsOption ¶ added in v0.23.0
type RegisteredClaimsOption func(*registeredClaimsOptions)
RegisteredClaimsOption configures how RegisteredClaims are created.
func WithOffset ¶ added in v0.23.0
func WithOffset(offset time.Duration) RegisteredClaimsOption
WithOffset sets the offset to account for time differences between nodes.