auth

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package auth holds shared authentication primitives used by both the API and the Web UI — currently the password policy (issue #48). Keeping it in its own package gives every password-setting code path (operator create, self-registration, future password-reset) a single import surface to validate against.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Policy

type Policy struct {
	MinLength      int
	RequireClasses int  // 1..4 of {lower, upper, digit, symbol}
	BlockCommon    bool // reject embedded common-passwords list
	BlockUsername  bool // reject equality / substring of username
}

Policy is the configurable password policy. Zero-value Policy ⇒ no constraints; production callers should construct via Default() and override individual knobs from the server config / settings table.

func Default

func Default() Policy

Default returns the out-of-the-box policy from the issue.

func (Policy) HumanHint

func (p Policy) HumanHint() string

HumanHint returns a human-readable description of the password policy. Used to provide inline guidance on password form pages.

func (Policy) Validate

func (p Policy) Validate(password, usernameLower string) error

Validate reports the first rule that fails for password under policy. Returns nil when every rule passes. usernameLower is the lowercase form of the operator's username; pass "" when no username context exists (e.g. one-off bootstrap password). The returned error message names the specific rule so the UI can show actionable feedback.

Jump to

Keyboard shortcuts

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