token

package
v0.0.12 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode

func Encode(t *Token) (string, error)

func ExtractPayload

func ExtractPayload(tokenString string) (string, string, error)

Types

type DbDeleteTokenBody

type DbDeleteTokenBody struct {
	Enabled bool `bson:"enabled"`
}

type DbDeleteTokenDocument

type DbDeleteTokenDocument struct {
	Set DbDeleteTokenBody `bson:"$set"`
}

type DbTokenIdFilter

type DbTokenIdFilter struct {
	ID primitive.ObjectID `bson:"_id"`
}

type Token

type Token struct {
	ID      primitive.ObjectID `bson:"_id"`
	UserID  primitive.ObjectID `bson:"userId"`
	Enabled bool               `bson:"enabled"`
}

type TokenRepository

type TokenRepository interface {
	Insert(userID primitive.ObjectID) (*Token, error)
	FindByID(tokenID string) (*Token, error)
	Delete(tokenID primitive.ObjectID) error
}

func NewTokenRepository

func NewTokenRepository(
	log log.LogRusEntry,
	collection db.Collection,
) (TokenRepository, error)

type TokenService

type TokenService interface {
	Create(userID string) (*Token, error)
	Validate(tokenString string) (*Token, error)
	Invalidate(tokenString string) error
	Find(tokenID string) (*Token, error)
}

func NewTokenService

func NewTokenService(
	log log.LogRusEntry,
	cache cache.Cache[Token],
	repository TokenRepository,
) TokenService

Jump to

Keyboard shortcuts

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