Skip to content

feat: add redis-compatible auth and protected mode - #57

Merged
kacy merged 4 commits into
mainfrom
feat/auth-and-protected-mode
Feb 8, 2026
Merged

feat: add redis-compatible auth and protected mode#57
kacy merged 4 commits into
mainfrom
feat/auth-and-protected-mode

Conversation

@kacy

@kacy kacy commented Feb 8, 2026

Copy link
Copy Markdown
Owner

summary

  • adds --requirepass CLI flag for redis-compatible AUTH before running commands
  • supports both AUTH password (legacy) and AUTH username password (redis 6+) forms
  • adds protected mode: rejects non-loopback connections when no password is set on public binds
  • adds QUIT command for graceful connection close
  • per-connection auth state in both sharded and concurrent handlers

what was tested

  • protocol parsing tests for AUTH (legacy, username+password, wrong arity) and QUIT
  • all 701 tests pass, cargo clippy --all-targets clean
  • manual verification plan in PR description below

design considerations

  • auth state is per-connection (let mut authenticated), not global — no locking on the hot path
  • when unauthenticated, frames are processed serially so AUTH takes effect mid-pipeline
  • once authenticated, the existing join_all parallel dispatch is used unchanged
  • only AUTH, PING, ECHO, QUIT are allowed before authentication (matching Redis)
  • protected mode check happens at accept time, before spawning a handler task
  • shared auth helpers live in connection_common.rs to avoid duplication between handlers
  • only the "default" username is accepted (no full ACL system yet)
  • re-auth on already-authenticated connections works correctly

kacy added 4 commits February 8, 2026 09:49
adds Auth and Quit variants to the Command enum with full
parsing support. AUTH accepts both legacy (password only) and
redis 6+ (username password) forms. includes unit tests for
correct parsing and arity validation.
adds --requirepass CLI flag to require AUTH before running commands.
adds protected mode: rejects non-loopback connections when no
password is set and the server is bound to a public address. the
DENIED error is written directly to the socket before closing.
adds per-connection authentication state to both sharded and
concurrent handlers. unauthenticated connections can only run
AUTH, PING, ECHO, and QUIT — all other commands return NOAUTH.
shared auth helpers (is_auth_frame, is_allowed_before_auth,
try_auth) live in connection_common.rs. re-auth on already
authenticated connections is supported.
@kacy
kacy merged commit 15167b6 into main Feb 8, 2026
4 of 5 checks passed
@kacy
kacy deleted the feat/auth-and-protected-mode branch February 8, 2026 14:59
kacy added a commit that referenced this pull request Feb 11, 2026
* feat: add AUTH and QUIT command parsing

adds Auth and Quit variants to the Command enum with full
parsing support. AUTH accepts both legacy (password only) and
redis 6+ (username password) forms. includes unit tests for
correct parsing and arity validation.

* feat: add requirepass config and protected mode

adds --requirepass CLI flag to require AUTH before running commands.
adds protected mode: rejects non-loopback connections when no
password is set and the server is bound to a public address. the
DENIED error is written directly to the socket before closing.

* feat: add auth gate to connection handlers

adds per-connection authentication state to both sharded and
concurrent handlers. unauthenticated connections can only run
AUTH, PING, ECHO, and QUIT — all other commands return NOAUTH.
shared auth helpers (is_auth_frame, is_allowed_before_auth,
try_auth) live in connection_common.rs. re-auth on already
authenticated connections is supported.

* docs: update README with auth and protected mode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant