auth

package
v0.5.82 Latest Latest
Warning

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

Go to latest
Published: May 16, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateSecretKey

func GenerateSecretKey() (string, error)

GenerateSecretKey создаёт новый случайный ключ и возвращает его в hex

func GenerateToken

func GenerateToken[T ~uint64 | ~string](secretKeyHex string, userID T) (string, error)

GenerateToken создаёт PASETO-токен с 24-часовым сроком жизни. secretKeyHex – 32-байтовый ключ в hex-формате.

func ValidateToken

func ValidateToken(secretKeyHex string, tokenString string) (string, error)

ValidateToken проверяет токен и возвращает user_id (строку).

Types

type User

type User struct {
	ID           uint64
	Username     string
	PasswordHash string
}

type UserStore

type UserStore interface {
	GetByID(id string) (*User, error)
}

Jump to

Keyboard shortcuts

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