Documentation
¶
Overview ¶
Package httpauth is the cryptography behind logins in front of apps (http-auth): password hashes, TOTP codes, and signed session cookies and login hand-offs. It keeps no state: a session is valid wherever the cluster's session key is, so any ingress node (an edge included) checks it on its own.
Index ¶
- Constants
- func CheckPassword(hash, password string) bool
- func CheckTOTP(secret, code string, now time.Time) (uint64, bool)
- func Fingerprint(parts ...string) string
- func HashPassword(password string) (string, error)
- func HashToken(token string) string
- func Key(s string) ([]byte, error)
- func NewTOTPSecret() string
- func Sign(key []byte, purpose, host string, v any) (string, error)
- func TOTPCode(secret string, t time.Time) (string, error)
- func TOTPURI(issuer, user, secret string) string
- func Token() string
- func Verify(key []byte, purpose, host, token string, v any) bool
- type Session
Constants ¶
const ( KindUser = "u" KindPassword = "p" )
const MaxPassword = 72
MaxPassword is bcrypt's limit.
Variables ¶
This section is empty.
Functions ¶
func CheckPassword ¶
func CheckTOTP ¶
CheckTOTP accepts the code for the step at now, or the one before or after (clocks drift), and returns the step it matched, so a caller can refuse a code used twice.
func Fingerprint ¶
Fingerprint identifies a credential (a password hash, a TOTP secret) without revealing it: sessions carry it, so changing the credential ends them.
func HashPassword ¶
Types ¶
type Session ¶
type Session struct {
Kind string `json:"k"` // KindUser, KindPassword or KindShare
Name string `json:"n,omitempty"` // the user, or the share's ID
App string `json:"a,omitempty"` // the app it's for (password and share sessions)
Version string `json:"v,omitempty"` // Fingerprint of the credential it was made with
Expires int64 `json:"e"`
}
Session is who a cookie lets in, where, and until when.