krabka-security
TLS, SASL, SCRAM, OAuth, Kerberos, and certificate utilities for Krabka.
Part of Krabka, a Rust implementation of Apache Kafka-compatible infrastructure and clients.
Overview
krabka-security collects the reusable security primitives that Krabka brokers,
clients, operators, and tests share. It builds rustls configs, implements SASL
mechanism helpers, and runs SCRAM exchanges. It also validates OAuth bearer
tokens, extracts Kafka principals from certificates, and issues local
test/cluster certificates.
The crate supplies security building blocks. It does not open network sockets and it does not own OAuth/JWKS refresh loops. Callers integrate these primitives with their own transport and runtime.
Capabilities
- SASL mechanism names and auth method types for PLAIN, SCRAM-SHA-256, SCRAM-SHA-512, OAUTHBEARER, and GSSAPI.
- PLAIN verification helpers.
- SCRAM credential hashing and client/server exchange state machines.
- OAuth bearer initial-response parsing, unsecured JWS validation, signed JWS validation through JWKS, and introspection traits.
- TLS client/server config builders and dynamic server config reload support.
- mTLS principal extraction from X.509 subject distinguished names.
- Cluster and client CA generation plus broker/user certificate issuance.
- Delegation-token HMAC helpers and redacted secret wrappers.
- Kerberos/GSSAPI trait surfaces, keytab parsing, and provider scaffolding.
Kafka Security Scope
SASL mechanism wire names match Kafka mechanism strings. SCRAM follows RFC 5802 and includes KIP-554-style broker credential derivation. OAuth bearer parsing matches the RFC 7628/KIP-255 client initial response shape. mTLS principal extraction follows Kafka's default subject-DN principal style.
GSSAPI support is a de-risking surface. Review it before you use it in production.
Install
For workspace development, use the path dependency from this repository.
Usage
Build the client-first message for a SCRAM-SHA-256 exchange:
use ;
let exchange = new;
let = exchange.client_first?;
println!;
# Ok::
Documentation
License
Apache-2.0. Derivative work of Apache Kafka; see NOTICE.