Documentation
¶
Overview ¶
Package auth hashes and verifies web passwords with argon2id (D8: passwords are for the web only; git over SSH uses keys and git over HTTPS uses tokens).
Index ¶
- Variables
- func Hash(password string, p Params) (string, error)
- func NeedsRehash(encoded string, p Params) bool
- func NewRecoveryCode() (string, error)
- func NewTOTPSecret() (string, error)
- func NormalizeRecovery(s string) string
- func TOTPCode(secret string, step int64) (string, error)
- func TOTPStep(t time.Time) int64
- func TOTPURI(issuer, account, secret string) string
- func Verify(password, encoded string) error
- func VerifyTOTP(secret, code string, now time.Time, skew int, lastStep int64) (int64, bool)
- type Params
Constants ¶
This section is empty.
Variables ¶
var ErrMismatch = errors.New("password mismatch")
ErrMismatch is returned by Verify when the password is wrong.
Functions ¶
func Hash ¶
Hash returns a PHC-formatted string: $argon2id$v=19$m=..,t=..,p=..$salt$hash. The parameters travel with the hash so cost can be raised later without a migration.
func NeedsRehash ¶
NeedsRehash reports whether a stored hash uses weaker parameters than p.
func NewRecoveryCode ¶
NewRecoveryCode returns one recovery code: 10 base32 characters in two groups ("abcde-fghij"), 50 random bits.
func NewTOTPSecret ¶
NewTOTPSecret returns a fresh secret as base32.
func NormalizeRecovery ¶
NormalizeRecovery makes a typed recovery code comparable: lower case, no spaces or dashes.
func VerifyTOTP ¶
VerifyTOTP checks a code against the steps around now (±skew) and returns the step it matched. A step at or before lastStep is refused, so a code that already signed someone in cannot be replayed.