jwt

package
v0.0.0-...-78d802f Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

type Service struct {
	Cache store.CacheStore
	// contains filtered or unexported fields
}

func New

func New(cache store.CacheStore, signingKey, refreshKey string) (*Service, error)

func (*Service) Create

func (s *Service) Create(userID uuid.UUID) (*store.TokenDetails, error)

Create will create a new JWT token with the user_id as a claim it will then cache to redis

func (*Service) Expire

func (s *Service) Expire(token *store.AccessToken) error

Expire invalidates a token and removes it from the cache

func (*Service) Extract

func (s *Service) Extract(tokenStr string) (*store.AccessToken, error)

Extract takes a token string and returns an AccessToken including the UUID for the token and the user id

func (*Service) Validate

func (s *Service) Validate(tokenStr string) error

Validate will take a token in string form and ensure it is valid and not expired

Jump to

Keyboard shortcuts

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