WebSocket hub with channel-based pub/sub
Find a file
Snider 9e48f0b60d feat(auth): Phase 2 — token-based authentication on WebSocket upgrade
Add Authenticator interface with AuthenticatorFunc adapter and built-in
APIKeyAuthenticator for Bearer token validation. Hub.Handler() now gates
connections when an Authenticator is configured on HubConfig, responding
HTTP 401 for failed auth. Client.UserID and Client.Claims are populated
on successful upgrade. OnAuthFailure callback enables logging/metrics.

Nil authenticator preserves full backward compatibility — all existing
tests pass unchanged. 18 new tests (unit + integration) cover valid/
invalid/missing/malformed headers, func adapter, multi-client auth,
message delivery post-auth, and the OnAuthFailure callback.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 08:12:45 +00:00
auth.go feat(auth): Phase 2 — token-based authentication on WebSocket upgrade 2026-02-20 08:12:45 +00:00
auth_test.go feat(auth): Phase 2 — token-based authentication on WebSocket upgrade 2026-02-20 08:12:45 +00:00
CLAUDE.md feat(auth): Phase 2 — token-based authentication on WebSocket upgrade 2026-02-20 08:12:45 +00:00
errors.go feat(auth): Phase 2 — token-based authentication on WebSocket upgrade 2026-02-20 08:12:45 +00:00
FINDINGS.md feat(ws): phase 0 coverage (98.5%) + phase 1 connection resilience 2026-02-20 01:17:56 +00:00
go.mod feat: extract go-ws from core/go pkg/ws 2026-02-19 16:08:52 +00:00
go.sum feat: extract go-ws from core/go pkg/ws 2026-02-19 16:08:52 +00:00
TODO.md feat(auth): Phase 2 — token-based authentication on WebSocket upgrade 2026-02-20 08:12:45 +00:00
ws.go feat(auth): Phase 2 — token-based authentication on WebSocket upgrade 2026-02-20 08:12:45 +00:00
ws_bench_test.go test: expand Phase 0 coverage — 16 new tests, 9 benchmarks, SPDX headers 2026-02-20 05:14:11 +00:00
ws_test.go test: expand Phase 0 coverage — 16 new tests, 9 benchmarks, SPDX headers 2026-02-20 05:14:11 +00:00