validate

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package validate holds the input checks and password hashing shared by the CSuit apps: email and username format, password strength rules, and a bcrypt wrapper that limits how many hashes run at once.

Index

Constants

This section is empty.

Variables

View Source
var BcryptCost = 12

BcryptCost is the work factor for new hashes. Tests may lower it.

Functions

func BurnPasswordCheck added in v1.2.1

func BurnPasswordCheck(password string)

BurnPasswordCheck spends the same time as a real password check. Call it when the account does not exist so login timing does not reveal which emails are registered.

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

CheckPasswordHash compares a plain password with a bcrypt hash, queued the same way as HashPassword.

func HashPassword

func HashPassword(password string) (string, error)

HashPassword returns a bcrypt hash. At most two hashes run at once; further callers queue instead of starving the machine.

func IsSpecialChar

func IsSpecialChar(r rune) bool

func IsValidEmail

func IsValidEmail(email string) bool

func IsValidUsername

func IsValidUsername(username string) bool

IsValidUsername allows letters, numbers, underscores and hyphens.

func PasswordStrengthErrors

func PasswordStrengthErrors(password string) []string

PasswordStrengthErrors returns the i18n keys of the unmet requirements.

func PasswordsMatch

func PasswordsMatch(p1, p2 string) bool

Types

This section is empty.

Jump to

Keyboard shortcuts

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