tokens

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractCustomClaims

func ExtractCustomClaims(token string) (string, error)

ExtractCustomClaims extracts the custom claim from an access token.

Types

type TAccessToken

type TAccessToken struct {
	// Token is the compact JWT string.
	Token string
	// Expiration is the lifetime used when the token was issued.
	Expiration time.Duration
	// ExpiresAt is the instant after which the token is expired.
	ExpiresAt time.Time
}

TAccessToken is a signed JWT together with its lifetime.

func NewAccessToken

func NewAccessToken(user string, expiration *time.Duration, customClaims string) (TAccessToken, error)

NewAccessToken creates a signed JWT access token.

type TRefreshToken

type TRefreshToken struct {
	// Token is the opaque refresh-token string.
	Token string
	// Expiration is the lifetime used when the token was issued.
	Expiration time.Duration
	// ExpiresAt is the instant after which the token is expired.
	ExpiresAt time.Time
}

TRefreshToken is an opaque refresh token together with its lifetime.

func NewRefreshToken

func NewRefreshToken(expiration *time.Duration) (TRefreshToken, error)

NewRefreshToken creates a random refresh token.

type TTokens

type TTokens struct {
	AccessToken  TAccessToken  `json:"access_token"`
	RefreshToken TRefreshToken `json:"refresh_token"`
}

func (TTokens) Expired added in v0.2.0

func (t TTokens) Expired() bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL