diff options
| author | bndw <ben@bdw.to> | 2026-02-14 14:54:30 -0800 |
|---|---|---|
| committer | bndw <ben@bdw.to> | 2026-02-14 14:54:30 -0800 |
| commit | 4dbd96ec697196d43ad41eca4fd43d53da46a081 (patch) | |
| tree | fe3cf316855c4760d48a1a2f3cb4500aa9d3a681 /internal/storage | |
| parent | 9ee32a917b13ffb3f52ddbc3a0c72dd8ec71953c (diff) | |
refactor: use AuthStore interface and remove type assertions
Replace runtime type assertions with compile-time safe AuthStore interface.
Add connState struct for cleaner per-connection state management instead
of mutable pointer parameters. Reduce auth challenge TTL from 10min to 2min.
- Add AuthStore interface with CreateAuthChallenge and ValidateAndConsumeChallenge
- Add connState struct for authenticatedPubkey and authChallenge
- Remove fragile type assertion pattern in requireAuth and handleAuth
- Add nil checks for auth store with clear error messages
- Update Handler to have separate auth field
- Wire auth store in main.go when auth is enabled
Diffstat (limited to 'internal/storage')
| -rw-r--r-- | internal/storage/auth.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/internal/storage/auth.go b/internal/storage/auth.go index 6eefa41..e17ffeb 100644 --- a/internal/storage/auth.go +++ b/internal/storage/auth.go | |||
| @@ -10,7 +10,7 @@ import ( | |||
| 10 | 10 | ||
| 11 | const ( | 11 | const ( |
| 12 | ChallengeLength = 32 // bytes | 12 | ChallengeLength = 32 // bytes |
| 13 | ChallengeTTL = 10 * time.Minute | 13 | ChallengeTTL = 2 * time.Minute |
| 14 | ) | 14 | ) |
| 15 | 15 | ||
| 16 | func generateChallenge() (string, error) { | 16 | func generateChallenge() (string, error) { |
