jwt

package
v0.1.3-rc1 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthorizationHeaderName = "Authorization"
	BearerTokenPrefix       = "Bearer "
)
View Source
const (
	NullifierClaimName           = "sub"
	ExpirationTimestampClaimName = "exp"
	TokenTypeClaimName           = "type"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthClaim

type AuthClaim struct {
	Nullifier string
	Type      TokenType
}

AuthClaim is a helper structure to organize all claims in one entity

type JWTConfig

type JWTConfig struct {
	SecretKey             string        `fig:"secret_key,required"`
	AccessExpirationTime  time.Duration `fig:"access_expiration_time,required"`
	RefreshExpirationTime time.Duration `fig:"refresh_expiration_time,required"`
}

type JWTIssuer

type JWTIssuer struct {
	// contains filtered or unexported fields
}

func (*JWTIssuer) IssueJWT

func (i *JWTIssuer) IssueJWT(claim *AuthClaim) (token string, exp time.Time, err error)

func (*JWTIssuer) ValidateJWT

func (i *JWTIssuer) ValidateJWT(str string) (claim *AuthClaim, err error)

type Jwter

type Jwter interface {
	JWT() *JWTIssuer
}

func NewJwter

func NewJwter(getter kv.Getter) Jwter

type RawJWT

type RawJWT struct {
	// contains filtered or unexported fields
}

RawJWT represents helper structure to provide setter and getter methods to work with JWT claims

func (*RawJWT) Nullifier

func (r *RawJWT) Nullifier() (res string, ok bool)

func (*RawJWT) SetExpirationTimestamp

func (r *RawJWT) SetExpirationTimestamp(expiration time.Time) *RawJWT

func (*RawJWT) SetNullifier

func (r *RawJWT) SetNullifier(nullifier string) *RawJWT

func (*RawJWT) SetTokenAccess

func (r *RawJWT) SetTokenAccess() *RawJWT

func (*RawJWT) SetTokenRefresh

func (r *RawJWT) SetTokenRefresh() *RawJWT

func (*RawJWT) TokenType

func (r *RawJWT) TokenType() (typ TokenType, ok bool)

type TokenType

type TokenType string
var (
	AccessTokenType  TokenType = "access"
	RefreshTokenType TokenType = "refresh"
)

func (TokenType) String

func (t TokenType) String() string

Jump to

Keyboard shortcuts

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