Documentation
¶
Index ¶
- type Blocklist
- func (b *Blocklist) Connect() error
- func (b *Blocklist) Count() (int64, error)
- func (b *Blocklist) Del(key string) error
- func (b *Blocklist) Has(key string) (bool, error)
- func (b *Blocklist) InvalidateToken(token []byte, c jwt.Claims) error
- func (b *Blocklist) IsConnected() bool
- func (b *Blocklist) ValidateToken(token []byte, c jwt.Claims, err error) error
- type Client
- type ClusterOptions
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Blocklist ¶
type Blocklist struct {
// GetKey is a function which can be used how to extract
// the unique identifier for a token.
// Required. By default the token key is extracted through the claims.ID ("jti").
GetKey func(token []byte, claims jwt.Claims) string
// Prefix the token key into the redis database.
// Note that if you can also select a different database
// through ClientOptions (or ClusterOptions).
// Defaults to empty string (no prefix).
Prefix string
// Customize any go-redis fields manually
// before Connect.
ClientOptions Options
ClusterOptions ClusterOptions
// contains filtered or unexported fields
}
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) InvalidateToken ¶
InvalidateToken invalidates a verified JWT token.
func (*Blocklist) IsConnected ¶
IsConnected reports whether the Connect function was called.
type ClusterOptions ¶
type ClusterOptions = redis.ClusterOptions
ClusterOptions is just a type alias for the go-redis Cluster Client Options.
Click to show internal directories.
Click to hide internal directories.