jwtkit

package
v0.2.41 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Claims added in v0.2.40

type Claims = jwt.RegisteredClaims

Claims represents claims for JWT. See: https://tools.ietf.org/html/rfc7519#section-4.1

type Token

type Token struct {
	Claims
	Meta map[string]any `json:"meta,omitempty"`
	// contains filtered or unexported fields
}

Token represents claims for JWT with additional metadata.

func (*Token) Metadata

func (t *Token) Metadata() map[string]any

Metadata returns the metadata of the token.

func (*Token) Raw

func (t *Token) Raw() *jwt.Token

Raw returns the raw token.

type TokenManager

type TokenManager interface {
	// Sign takes a Token and signs it.
	Sign(token *Token) (string, error)

	// Verify takes a token string and verifies it.
	Verify(token string) error

	// ParseVerify takes a token string and parses and verifies it.
	ParseVerify(token string) (*Token, error)
}

TokenManager is an interface that holds the logic of token management.

type TokenManagerJWT

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

TokenManagerJWT is an implementation of TokenManager based on JWT.

func NewTokenManager

func NewTokenManager(signer jwt.Signer, verifier jwt.Verifier) *TokenManagerJWT

NewTokenManager creates a new implementation of TokenManager based on JWT. It uses the given signer and verifier to sign and verify the token.

func (*TokenManagerJWT) ParseVerify

func (m *TokenManagerJWT) ParseVerify(token string) (*Token, error)

func (*TokenManagerJWT) Sign

func (m *TokenManagerJWT) Sign(token *Token) (string, error)

func (*TokenManagerJWT) Verify

func (m *TokenManagerJWT) Verify(token string) error

Jump to

Keyboard shortcuts

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