1#[cfg(feature = "kerberos-api")]
4mod kerberos;
5#[cfg(all(unix, feature = "kerberos-gssapi"))]
6mod kerberos_gssapi;
7#[cfg(feature = "kerberos-sspi")]
8mod kerberos_sspi;
9#[cfg(feature = "kerberos-api")]
10mod kerberos_spn;
11mod ntlm;
12mod ntlm_rpc;
13mod ntlm_rpc_bind;
14mod spnego;
15
16use smolder_proto::smb::smb2::NegotiateResponse;
17use thiserror::Error;
18
19#[cfg(feature = "kerberos-api")]
20#[cfg_attr(
21 docsrs,
22 doc(cfg(any(feature = "kerberos", feature = "kerberos-gssapi")))
23)]
24pub use kerberos::{
25 KerberosAuthenticator, KerberosBackendKind, KerberosCredentialSourceKind,
26 KerberosCredentials,
27};
28#[cfg(feature = "kerberos-api")]
29#[cfg_attr(
30 docsrs,
31 doc(cfg(any(feature = "kerberos", feature = "kerberos-gssapi")))
32)]
33pub use kerberos_spn::KerberosTarget;
34pub use ntlm::{NtlmAuthenticator, NtlmCredentials};
35pub use ntlm_rpc::{NtlmRpcPacketIntegrity, NtlmSessionSecurity};
36pub(crate) use ntlm_rpc_bind::NtlmRpcBindHandshake;
37
38#[cfg(all(
39 feature = "kerberos-api",
40 not(feature = "kerberos-sspi"),
41 not(all(unix, feature = "kerberos-gssapi"))
42))]
43compile_error!(
44 "kerberos-api requires either kerberos-sspi or kerberos-gssapi on Unix"
45);
46
47#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
49pub enum SpnegoMechanism {
50 Ntlm,
52 KerberosV5,
54}
55
56#[derive(Debug, Error)]
58pub enum AuthError {
59 #[error("invalid authentication token: {0}")]
61 InvalidToken(&'static str),
62 #[error("invalid authentication state: {0}")]
64 InvalidState(&'static str),
65 #[error("authentication backend error: {0}")]
67 Backend(String),
68}
69
70pub trait AuthProvider {
72 fn initial_token(&mut self, negotiate: &NegotiateResponse) -> Result<Vec<u8>, AuthError>;
74
75 fn next_token(&mut self, incoming: &[u8]) -> Result<Vec<u8>, AuthError>;
77
78 fn finish(&mut self, _incoming: &[u8]) -> Result<(), AuthError> {
80 Ok(())
81 }
82
83 fn session_key(&self) -> Option<&[u8]> {
85 None
86 }
87}