1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//! Security primitives used by Krabka brokers, clients, and tooling.
//!
//! The crate owns the protocol-independent pieces of TLS, SASL, SCRAM,
//! OAuth/OIDC, mTLS principal extraction, delegation-token HMACs, Kerberos
//! exchange state, and principal modelling. Network I/O stays in the caller.
//! The async [`IntrospectionClient`] trait represents OAuth introspection, and
//! the broker and client crates supply the concrete transports and wire the
//! resulting validators into listener or connection handshakes.
//!
//! ## SASL/PLAIN verification
//!
//! ```rust
//! use std::collections::HashMap;
//!
//! use krabka_security::{AuthMethod, verify_plain};
//!
//! let mut users = HashMap::new();
//! users.insert("alice".to_string(), "wonderland".to_string());
//!
//! let principal = verify_plain(&users, "alice", b"wonderland").unwrap();
//! assert_eq!(principal.name, "alice");
//! assert_eq!(principal.auth_method, AuthMethod::SaslPlain);
//! ```
//!
//! ## Storing SCRAM credentials
//!
//! ```rust
//! use krabka_security::{SaslMechanism, hash_scram_password};
//!
//! let credential = hash_scram_password(
//! b"correct horse battery staple",
//! SaslMechanism::ScramSha512,
//! 4096,
//! )?;
//! assert_eq!(credential.iterations, 4096);
//! # Ok::<_, krabka_security::ScramError>(())
//! ```
//!
//! ## Cargo features
//!
//! - `gssapi` (off by default): SASL/GSSAPI (Kerberos), the `gssapi` module.
//! It is native-only, and has no effect on `wasm32` targets.
//!
//! `gssapi` stays out of `default` on purpose. The Kerberos stack it pulls in,
//! `krabka-sspi`, depends on `rsa` 0.10, which carries RUSTSEC-2023-0071 (the
//! Marvin timing side channel) and has no patched release. A build without the
//! feature compiles no `rsa` at all. A build with it is still not exposed,
//! because Krabka's GSSAPI path uses only AES keytab keys and never
//! runs an RSA private-key operation; `docs/rustsec-2023-0071.md` in the
//! repository gives the reachability analysis.
//!
//! Without the feature, [`SaslMechanism::Gssapi`] still parses and still names
//! the mechanism in persisted metadata, but [`SaslMechanism::is_available`]
//! returns `false` for it and [`SaslMechanism::require_available`] returns
//! [`AuthError::UnsupportedMechanism`]. A broker maps that to Kafka's
//! `UNSUPPORTED_SASL_MECHANISM` (error code 33) in the `SaslHandshake` response,
//! and a client reports it before it opens a connection.
pub use ;
pub use ;
pub use ;
pub use ListenerProtocol;
pub use SaslMechanism;
pub use extract_principal_from_cert;
pub use ;
pub use verify_plain;
pub use ;
pub use DynamicServerConfig;
pub use ;
pub use ;