auth

package
v0.9.9 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// JwtIdentifierPrefix is the prefix of the JWT Identifier key
	JwtIdentifierPrefix = "jwt_id"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultTokenValidator

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

DefaultTokenValidator struct

func NewDefaultTokenValidator

func NewDefaultTokenValidator(redisClient *redis.Client) (*DefaultTokenValidator, error)

NewDefaultTokenValidator creates a new token validator

func (*DefaultTokenValidator) AddToken

func (d *DefaultTokenValidator) AddToken(jwtId string, period time.Duration) error

AddToken adds the JWT Identifier with the given expiration period

func (*DefaultTokenValidator) GetKey

func (d *DefaultTokenValidator) GetKey(jwtId string) string

GetKey gets the JWT Identifier key

func (*DefaultTokenValidator) IsTokenValid

func (d *DefaultTokenValidator) IsTokenValid(jwtId string) (bool, error)

IsTokenValid checks if the token is valid

func (*DefaultTokenValidator) RevokeToken

func (d *DefaultTokenValidator) RevokeToken(jwtId string) error

RevokeToken revokes the JWT Identifier by setting the value to false

type TokenValidator

type TokenValidator interface {
	AddToken(jwtId string, period time.Duration) error
	RevokeToken(jwtId string) error
	IsTokenValid(jwtId string) (bool, error)
}

TokenValidator interface

Jump to

Keyboard shortcuts

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