pub struct MtlsValidator { /* private fields */ }Expand description
mTLS validator that extracts identity from client certificates.
Implementations§
Source§impl MtlsValidator
impl MtlsValidator
Sourcepub fn new(config: MtlsConfig) -> Self
pub fn new(config: MtlsConfig) -> Self
Create a new mTLS validator.
Sourcepub fn extract_identity_from_cn(
&self,
cn: &str,
) -> Result<CertificateIdentity, AuthError>
pub fn extract_identity_from_cn( &self, cn: &str, ) -> Result<CertificateIdentity, AuthError>
Extract identity from a certificate CN.
§Security contract
The cn parameter MUST come from the TLS layer (e.g., parsed
from the peer certificate by the TLS terminator). Passing
user-controlled strings directly (e.g., from an HTTP header)
bypasses all certificate verification and is a critical security
violation.
When MtlsConfig::allowed_cns is set, only CN values present
in the allowlist are accepted.
Sourcepub fn extract_identity_from_san_dns(
&self,
dns_name: &str,
) -> Result<CertificateIdentity, AuthError>
pub fn extract_identity_from_san_dns( &self, dns_name: &str, ) -> Result<CertificateIdentity, AuthError>
Extract identity from a SAN DNS name.
§Security contract
The dns_name parameter MUST come from the TLS layer.
Sourcepub fn extract_identity_from_san_email(
&self,
email: &str,
) -> Result<CertificateIdentity, AuthError>
pub fn extract_identity_from_san_email( &self, email: &str, ) -> Result<CertificateIdentity, AuthError>
Extract identity from a SAN email.
§Security contract
The email parameter MUST come from the TLS layer.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if mTLS is enabled.
Trait Implementations§
Source§impl Clone for MtlsValidator
impl Clone for MtlsValidator
Source§fn clone(&self) -> MtlsValidator
fn clone(&self) -> MtlsValidator
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for MtlsValidator
impl RefUnwindSafe for MtlsValidator
impl Send for MtlsValidator
impl Sync for MtlsValidator
impl Unpin for MtlsValidator
impl UnsafeUnpin for MtlsValidator
impl UnwindSafe for MtlsValidator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more