Skip to content

SASL/SCRAM authentication end-to-end (SCRAM-SHA-1/256/512) - #8

Merged
rigazilla merged 1 commit into
mainfrom
feat/scram-auth
Sep 25, 2026
Merged

rigazilla merged 1 commit into
mainfrom
feat/scram-auth

Conversation

@rigazilla

Copy link
Copy Markdown
Member

Summary

Wires the client to authenticate against a secured Infinispan server. Until now SCRAM crypto existed but was dead code — no code path ever authenticated. This adds end-to-end SASL authentication for the whole SCRAM family (SCRAM-SHA-1 / SCRAM-SHA-256 / SCRAM-SHA-512).

RemoteCache::setAuthentication(username, password, realm="default", serverName="infinispan", mechanism="SCRAM-SHA-256") — a flat setter matching the existing setClientIntelligence / setProtocolVersion idiom — enables a SASL handshake that runs on every connection the client opens (the seed connection and every topology-discovered cluster member), inside MultiplexedConnection::connect(), after TCP connect and before the read-loop thread starts.

What's included

  • Generalized SCRAM across the digest family (SHA-1/256/512) over OpenSSL EVP; PBKDF2/HMAC/H output lengths derived from EVP_MD_size. SHA-256 stays the default; existing SCRAMTest still passes.
  • SaslAuthenticator drives the two-turn SCRAM exchange over a testable SaslTransport seam (ConnectionSaslTransport in production). The client completes on its own side after verifying the server signature — no confirmation round, and it ignores the server completed flag (mirrors Java AuthHandler; sending an extra round triggers Elytron ELY05037).
  • Non-SCRAM mechanisms throw a typed HotRodClientException at connect().
  • New public headers: Authentication.h, AuthCodec.h, SaslAuthenticator.h.
  • Docs: new AsciiDoc user guide (documentation/index.adoc + topics/) with a fully written security.adoc; auth snippet in the quickstart README; docs/STATUS.md, docs/DECISIONS.md, and README.md refreshed.

Testing

  • Unit: +19 (AuthCodecTest body round-trips + parameterized SaslAuthenticatorTest over SCRAM-SHA-1/256/512 driven by a fake OpenSSL server, plus mech-not-offered / unsupported-mech / bad-server-signature failure paths). Full suite 223/223 green, strict build (-Wall -Wextra -Werror -pedantic).
  • Integration: +5 (AuthIntegrationTest: SCRAM-SHA-1/256/512 put/get round-trips, wrong-password throws at connect, no-credentials-against-secured-server fails) — verified live against a Dockerized auth-enabled Infinispan 16.

Protocol provenance

Cross-checked against the two authoritative sources per AGENTS.md: the Java client (AuthHandler / AuthOperation) for behavior and the Kaitai schema hotrod40.ksy for byte layout. Rationale and the load-bearing "two client turns, client completes on its own side" finding are recorded in docs/DECISIONS.md.

🤖 Generated with Claude Code

Wire the client to authenticate against a secured Infinispan server.
`RemoteCache::setAuthentication(user, pass, realm, serverName, mechanism)`
(flat setter, default SCRAM-SHA-256) enables a SASL handshake that runs on
every connection the client opens — the seed connection and every
topology-discovered member — inside MultiplexedConnection::connect(), after
TCP connect and before the read-loop thread starts.

- Generalize SCRAM across the digest family (SHA-1/256/512) over OpenSSL EVP;
  PBKDF2/HMAC/H lengths derived from EVP_MD_size. SHA-256 stays the default.
- New SaslAuthenticator driving the two-turn SCRAM exchange over a testable
  SaslTransport seam (ConnectionSaslTransport in production). The client
  completes on its own side after verifying the server signature — no
  confirmation round, ignores the server `completed` flag (mirrors Java
  AuthHandler; avoids Elytron ELY05037). Non-SCRAM mechanisms throw a typed
  HotRodClientException at connect().
- New public headers: Authentication.h, AuthCodec.h, SaslAuthenticator.h.
- Tests: +19 unit (AuthCodec + parameterized SaslAuthenticator over a fake
  OpenSSL server, incl. failure paths) and +5 integration (AuthIntegrationTest:
  SCRAM-SHA-1/256/512 put/get, wrong-password, no-credentials) — green live
  against a Dockerized auth-enabled Infinispan 16.
- Docs: new AsciiDoc user guide (documentation/index.adoc + topics/), with a
  fully written security.adoc; quickstart README auth snippet; STATUS.md,
  DECISIONS.md, README refreshed.

Cross-checked against the authoritative sources: Java client (AuthHandler /
AuthOperation) for behavior and Kaitai hotrod40.ksy for byte layout.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@rigazilla
rigazilla merged commit 8e6203e into main Sep 25, 2026
3 checks passed
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