auth

package
v0.3.11 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2025 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFailedToParseBoolValue = "failed to parse bool value: %v"
)
View Source
var (
	// JwtIdentifierPrefix is the prefix of the JWT Identifier key
	JwtIdentifierPrefix = "jwt_id"
)

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