Documentation
¶
Overview ¶
Package liteauth is the single source of truth for Tollecode Lite's local 2FA. It backs BOTH the desktop app (via the stdio command bus) and web mode (via /ws/cmd): because the same sidecar process and the same on-disk store (~/.tollecode/lite-auth.json) serve both, a user registers their authenticator once and can unlock either surface with the same 6-digit code.
The scheme is standard TOTP (RFC 6238): SHA1, 6 digits, 30-second period — compatible with Google Authenticator, 1Password, Authy, etc. Everything here is stdlib (crypto/hmac, crypto/sha1, encoding/base32, crypto/rand).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BeginLogin ¶
BeginLogin reports whether an account exists for email (case-insensitive).
func Register ¶
Register starts registration: it mints a fresh TOTP secret + backup codes for a not-yet-verified pending account and returns the otpauth URI (for the QR) and the plaintext backup codes (shown once). Registration only completes when VerifyRegistration succeeds with a valid code.
func Reset ¶
Reset deletes the entire local auth store (see StorePath): the registered account, its TOTP secret, backup codes, and every live session. The next login starts fresh from registration. removed reports whether a file was actually deleted — false means there was nothing to reset (safe, not an error).
Types ¶
type PublicUser ¶
PublicUser is the account shape returned to the frontend (never the secret).
func LocalUser ¶
func LocalUser() *PublicUser
LocalUser returns the registered account (without secrets), or nil.
func ValidateSession ¶
func ValidateSession(token string) (bool, *PublicUser)
ValidateSession reports whether token maps to a live (unexpired) session.
func VerifyLogin ¶
func VerifyLogin(email, code string) (token, expiresAt string, user PublicUser, err error)
VerifyLogin checks a TOTP code (or an unused backup code) for the registered account and, on success, returns a session. A consumed backup code is removed.
func VerifyRegistration ¶
func VerifyRegistration(userID int, code string) (token, expiresAt string, user PublicUser, err error)
VerifyRegistration checks the first code against the pending account; on success it promotes pending → active and returns a session.