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 /cmd/relay/main.go | |
| 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 'cmd/relay/main.go')
| -rw-r--r-- | cmd/relay/main.go | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/cmd/relay/main.go b/cmd/relay/main.go index 6974f65..e4afec8 100644 --- a/cmd/relay/main.go +++ b/cmd/relay/main.go | |||
| @@ -116,6 +116,7 @@ func main() { | |||
| 116 | } | 116 | } |
| 117 | 117 | ||
| 118 | if cfg.Auth.Read.Enabled || cfg.Auth.Write.Enabled { | 118 | if cfg.Auth.Read.Enabled || cfg.Auth.Write.Enabled { |
| 119 | wsHandler.SetAuth(store) | ||
| 119 | wsHandler.SetAuthConfig(&wshandler.AuthConfig{ | 120 | wsHandler.SetAuthConfig(&wshandler.AuthConfig{ |
| 120 | ReadEnabled: cfg.Auth.Read.Enabled, | 121 | ReadEnabled: cfg.Auth.Read.Enabled, |
| 121 | WriteEnabled: cfg.Auth.Write.Enabled, | 122 | WriteEnabled: cfg.Auth.Write.Enabled, |
