Files
OwnCord/Server/auth/constants.go
T
jevb ecbffddf19 refactor: extract magic numbers to named constants
Create Server/api/constants.go (26 constants) and Server/auth/constants.go
(6 constants) for rate limits, timeouts, size limits, and token generation.
Replace all inline magic numbers with descriptive names across 9 source files.
No behavior changes — same values, just named for contributor readability.
2026-04-01 11:37:36 +02:00

31 lines
1.2 KiB
Go

package auth
import "time"
const (
// ─── Username validation ────────────────────────────────────────────────
// minUsernameLength is the minimum number of runes in a username.
minUsernameLength = 2
// maxUsernameLength is the maximum number of runes in a username.
maxUsernameLength = 32
// ─── Token generation ───────────────────────────────────────────────────
// sessionTokenBytes is the number of random bytes in a session token (256 bits).
sessionTokenBytes = 32
// opaqueTokenBytes is the number of random bytes in an opaque token (256 bits).
opaqueTokenBytes = 32
// totpSecretBytes is the number of random bytes used to generate a TOTP secret.
totpSecretBytes = 20
// ─── TOTP replay prevention ─────────────────────────────────────────────
// usedTOTPCodeTTL is how long a verified TOTP code is remembered to prevent
// replay attacks (covers the current period +/- 1, ~90 seconds).
usedTOTPCodeTTL = 90 * time.Second
)