redis

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2023 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 Blocklist

type Blocklist struct {
	MysqlOptions *MysqlOptions
}

Blocklist is a jwt.Blocklist backed by Redis.

func NewBlocklist

func NewBlocklist() *Blocklist

NewBlocklist returns a new redis-based Blocklist. Modify its ClientOptions or ClusterOptions depending the application needs and call its Connect.

Usage:

blocklist := NewBlocklist()
blocklist.ClientOptions.Addr = ...
err := blocklist.Connect()

And register it:

verifier := jwt.NewVerifier(...)
verifier.Blocklist = blocklist

func (*Blocklist) Connect

func (b *Blocklist) Connect() error

Connect prepares the redis client and fires a ping response to it.

func (*Blocklist) Count

func (b *Blocklist) Count() (int64, error)

Count returns the total amount of tokens stored.

func (*Blocklist) Del

func (b *Blocklist) Del(key string) error

Del removes a token from the storage.

func (*Blocklist) Has

func (b *Blocklist) Has(key string) (bool, error)

Has reports whether a specific token exists in the storage.

func (*Blocklist) InvalidateToken

func (b *Blocklist) InvalidateToken(token []byte, c jwt.Claims) error

InvalidateToken invalidates a verified JWT token.

func (*Blocklist) IsConnected

func (b *Blocklist) IsConnected() bool

IsConnected reports whether the Connect function was called.

func (*Blocklist) ValidateToken

func (b *Blocklist) ValidateToken(token []byte, c jwt.Claims, err error) error

ValidateToken checks if the token exists and

type MysqlOptions

type MysqlOptions struct {
	Host     string
	Port     int
	User     string
	Password string
	DataBase string
	GormDB   *gorm.DB
}

Jump to

Keyboard shortcuts

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