auth

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: MIT-0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package auth holds account and credential types and application policy.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashPassword

func HashPassword(ctx context.Context, plaintext string) (string, error)

HashPassword checks the application's policy before calling the password kit.

func NewToken

func NewToken() string

NewToken returns a cookie-safe encoding of 32 random bytes.

func NormalizeEmail

func NormalizeEmail(input string) (string, error)

NormalizeEmail validates a mailbox and keeps its canonical account key.

func ValidatePassword

func ValidatePassword(plaintext string) error

ValidatePassword enforces the same length policy for every password write.

Types

type Role

type Role string

Role controls access to administrative actions.

const (
	RoleAdmin  Role = "admin"
	RoleMember Role = "member"
)

type Session

type Session struct {
	UserID    int64
	CreatedAt time.Time
	LastSeen  time.Time
}

Session holds the times used to judge a stored session against the policy.

type SetupState

type SetupState struct {
	TokenHash TokenHash
	Consumed  bool
}

SetupState records a one-time token; a consumed token cannot be reissued.

type TokenHash

type TokenHash [sha256.Size]byte

TokenHash is the SHA-256 digest persisted instead of a bearer credential.

func HashToken

func HashToken(token string) TokenHash

HashToken hashes the exact credential string without normalizing it.

type User

type User struct {
	ID                 int64
	Name               string
	Email              string
	Role               Role
	PasswordHash       string
	Disabled           bool
	MustChangePassword bool
}

User is a local account and its sign-in state.

Jump to

Keyboard shortcuts

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