refactor: follow the google go style guide

Document every package and exported identifier, return the log level
from NewLogger instead of keeping it in a package variable, and stop
tests from mutating the argon2 parameters.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-22 00:18:02 +01:00
1 parent 048e114fd9
commit d20225982a
21 files changed
+147 -36

No files matched your search

+5
View File
@@ -12,6 +12,8 @@ import (
const totpIssuer = "uptimesebi"
// NewTOTPKey generates a secret for account using the defaults every common
// authenticator app supports (SHA-1, 6 digits, 30 s).
func NewTOTPKey(account string) (*otp.Key, error) {
return totp.Generate(totp.GenerateOpts{Issuer: totpIssuer, AccountName: account})
}
@@ -23,10 +25,13 @@ type TOTPVerifier struct {
now func() time.Time
}
// NewTOTPVerifier returns a verifier that records used codes in rdb.
func NewTOTPVerifier(rdb redis.UniversalClient) *TOTPVerifier {
return &TOTPVerifier{rdb: rdb, now: time.Now}
}
// Verify accepts code for secret within one step of clock skew, at most once
// per user.
func (v *TOTPVerifier) Verify(ctx context.Context, user uuid.UUID, secret, code string) (bool, error) {
ok, err := totp.ValidateCustom(code, secret, v.now(), totp.ValidateOpts{
Period: 30, Skew: 1, Digits: otp.DigitsSix, Algorithm: otp.AlgorithmSHA1,