jwt

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2025 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrExpiredToken

type ErrExpiredToken struct{}

func (ErrExpiredToken) Error

func (e ErrExpiredToken) Error() string

type ErrInvalidToken

type ErrInvalidToken struct{}

func (ErrInvalidToken) Error

func (e ErrInvalidToken) Error() string

type Jwt

type Jwt[T any] struct{}

Jwt implements JWTManager to verify session tokens

func New

func New[T any]() *Jwt[T]

New returns a new Jwt instance, and since session tokens are to validate users the working type is models.User

func (*Jwt[T]) Decode

func (s *Jwt[T]) Decode(token string, subject actions.Subject) (actions.JwtClaims[T], error)

Decode decodes the given token using the set JWT secret

func (*Jwt[T]) Sign

func (s *Jwt[T]) Sign(data T, subject actions.Subject, expTime time.Duration) (string, error)

Sign returns a JWT string(which will be the session token) based on the set JWT secret, using HS256 algorithm, and the given validity and an occurring error

func (*Jwt[T]) Validate

func (s *Jwt[T]) Validate(token string, subject actions.Subject) error

Validate checks the validity of the JWT string, and returns an occurring error

Jump to

Keyboard shortcuts

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