Expand description
Handshake state machine + auth method dispatch.
Hello / HelloAck payloads are JSON for the initial cut. CBOR
migration tracked as a follow-up — JSON keeps the v2 wire
debuggable from a hex dump and reuses the engine’s existing
crate::serde_json codec without a new dep.
Auth methods supported in v2.1:
bearer— token in AuthResponse, validated against AuthStoreanonymous— only when AuthStore is disabled; no challenge
Structs§
- Hello
- Decode the JSON-shaped Hello payload sent by a v2 client.
Enums§
- Auth
Outcome - Outcome of
validate_auth_response.
Constants§
- SUPPORTED_
METHODS - Methods we know how to handle today.
Functions§
- base64_
std - base64_
std_ decode - build_
auth_ fail - build_
auth_ ok - Build the AuthOk payload the server sends after a successful auth.
- build_
hello_ ack - Build the HelloAck the server sends back.
chosen_authis the strongest method both sides support;chosen_versionismin(client_max, server_max). - build_
scram_ auth_ ok - Build the AuthOk payload for a successful SCRAM completion. Carries the server signature so the client can verify the server also knew the verifier.
- build_
scram_ server_ first - Build the SCRAM server-first-message. Sent in
AuthRequest. Format:r=<client_nonce><server_nonce>,s=<salt_b64>,i=<iter>. - new_
server_ nonce - Generate a 24-byte server nonce, base64-encoded. Cryptographic
randomness sourced from the engine’s existing
random_byteshelper so SCRAM doesn’t introduce a new RNG path. - parse_
jwt - Parse a compact-serialized JWT into a
DecodedJwt. RFC 7519 shape:<base64url(header)>.<base64url(payload)>.<base64url(signature)>. The validator does the heavy lifting (signature, claims, expiry); this function just splits + decodes. - parse_
scram_ client_ final - Parse SCRAM client-final-message.
Format:
c=<channel_binding_b64>,r=<combined_nonce>,p=<proof_b64>. - parse_
scram_ client_ first - Parse a SCRAM client-first-message.
Format:
n,,n=<user>,r=<client_nonce>(no channel binding, no authzid). Returns(username, client_nonce, bare_message). - pick_
auth_ method - Server’s policy for picking an auth method given the client’s
preferences. Strongest-first ordering — but when the server
has no auth backend configured (
server_anon_ok = true),anonymouswins overbearerbecause bearer validation would fail anyway. v2.1 supports bearer + anonymous; future versions prepend scram-sha-256, mtls, oauth-jwt to the priority list. - validate_
auth_ response - Validate the AuthResponse payload for the chosen method.
- validate_
oauth_ jwt - Validate a JWT through the supplied
OAuthValidator. Returns(username, role)on success, or a refusal reason. - validate_
oauth_ jwt_ full - Tenant-aware variant of
validate_oauth_jwt. Returns(tenant, username, role)so the caller can mint a session pinned to the tenant carried by the configuredtenant_claim.