feat: implement AUTH requirepass (F-02)#34
Merged
Conversation
Add Redis-style connection authentication gated by an optional requirepass password. Every command except AUTH is rejected with -NOAUTH until a successful AUTH is seen on the connection. - engine: add auth_password state with set_requirepass/requirepass/ authenticate, shared via Arc<RwLock> so a runtime CONFIG SET is visible to already-accepted connections - protocol: add Command::Auth and the AUTH parser arm (arity 1) - network: gate non-AUTH commands in handle_client with a per-connection authed flag that survives packet boundaries; auth_reply emits +OK / -WRONGPASS / -ERR - config: expose requirepass in CONFIG GET * and support CONFIG SET requirepass at runtime - cli/config: add --requirepass flag and requirepass directive - tests: wire-level AUTH gating, WRONGPASS, CONFIG round-trip, plus parser and CLI unit tests Implements the security baseline from product-strategy F-02.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds Redis-style connection authentication gated by an optional
requirepasspassword (product-strategy F-02 security baseline).auth_password: Arc<RwLock<Option<Vec<u8>>>>withset_requirepass/requirepass/authenticate; shared so a runtimeCONFIG SET requirepassis visible to already-accepted connections.Command::Authvariant +AUTHparser arm (arity 1).handle_clientgates every non-AUTH command with a per-connectionauthedflag declared once before the read loop (survives packet boundaries and pipelining).auth_replyemits+OK/-WRONGPASS/-ERR. Unauthenticated commands get-NOAUTH.requirepassexposed inCONFIG GET *and settable at runtime viaCONFIG SET requirepass.--requirepassflag andrequirepassconfig-file directive (CLI overrides file).CONFIG SET requirepass, CONFIG GET round-trip, plus parser and CLI unit tests.Test plan
cargo fmt --check✅cargo clippy --all-targets -- -D warnings✅cargo test --all-targets✅ (all green, including new AUTH wire tests)Notes
Gates on the same quality gates as F-01. After merge, bump
Cargo.tomlto 0.5.1 and tagv0.5.1.