utils

package
v0.0.0-...-9d97ec1 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var KEY = os.Getenv("TOKEN_SECRET_KEY")

Functions

func CompareHash

func CompareHash(savedPassword, reqPassword string) error

func ExtractIdempotencyKey

func ExtractIdempotencyKey(ctx context.Context) string

func ExtractLogger

func ExtractLogger(ctx context.Context) log.Logger

func Hash

func Hash(pass string) (string, error)

func NewToken

func NewToken(t TokenType, data TokenData) (string, error)

func ParseDuration

func ParseDuration(duration string, multiplier time.Duration) time.Duration

func ParseToken

func ParseToken(token string) (jwt.MapClaims, error)

Types

type ContextKey

type ContextKey string
const (
	LoggerKey      ContextKey = "loggerKey"
	IdempotencyKey ContextKey = "idemKey"
)

type TokenData

type TokenData struct {
	ID   string
	Role string
}

type TokenType

type TokenType string
const (
	ACCESS  TokenType = "access"
	REFRESH TokenType = "refresh"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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