auth

package
v0.0.0-...-0387e7d Latest Latest
Warning

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

Go to latest
Published: May 26, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HashTime    = 1
	HashMemory  = 64 * 1024
	HashThreads = 4
	HashKeyLen  = 32
	HashSaltLen = 32
)

Variables

View Source
var AccessTokenTTL = 15 * time.Minute
View Source
var RefreshTokenTTL = 24 * time.Hour * 7

Functions

func AddAccessTokenMiddleware

func AddAccessTokenMiddleware(router chi.Router)

func AddRefreshTokenMiddleware

func AddRefreshTokenMiddleware(router chi.Router)

func Hash

func Hash(plain string) (string, error)

func NewAccessToken

func NewAccessToken(userId int64) (string, time.Time, error)

func NewRefreshToken

func NewRefreshToken(userId int64) (string, time.Time, error)

func VerifyPlainWithHash

func VerifyPlainWithHash(plain string, encodedHash string) error

Types

type Claims

type Claims struct {
	UserId int64     `json:"user_id"`
	Exp    time.Time `json:"exp"`
	Iat    time.Time `json:"iat"`
}

func ParseClaims

func ParseClaims(ctx context.Context) (*Claims, error)

Jump to

Keyboard shortcuts

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