pub struct AuthHandler { /* private fields */ }Expand description
Handles client-facing authentication interception
Implementations§
Source§impl AuthHandler
impl AuthHandler
Sourcepub fn new(
username: Option<String>,
password: Option<String>,
) -> Result<Self, ValidationError>
pub fn new( username: Option<String>, password: Option<String>, ) -> Result<Self, ValidationError>
Create a new auth handler with optional credentials
§Authentication behavior:
None, None→ Auth disabled (allows all connections)Some(user), Some(pass)→ Auth enabled with validationSome(user), NoneorNone, Some(pass)→ Auth disabled (both must be provided)
§Errors
Returns Err if either username or password is explicitly provided but empty/whitespace.
This prevents misconfiguration where empty credentials would silently disable auth,
which is a critical security vulnerability.
§Security
If you explicitly set credentials in config and they’re empty, the proxy will refuse to start rather than silently running with no authentication.
Sourcepub fn with_users(
user_list: Vec<(String, String)>,
) -> Result<Self, ValidationError>
pub fn with_users( user_list: Vec<(String, String)>, ) -> Result<Self, ValidationError>
Create a new auth handler with multiple users
§Errors
Returns Err if any username or password is empty/whitespace.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if authentication is enabled
Sourcepub fn validate_credentials(&self, username: &str, password: &str) -> bool
pub fn validate_credentials(&self, username: &str, password: &str) -> bool
Validate client credentials
If auth is disabled (no users configured), returns true for all credentials
Sourcepub async fn handle_auth_command<W>(
&self,
auth_action: AuthAction<'_>,
writer: &mut W,
stored_username: Option<&str>,
) -> Result<(usize, bool)>where
W: AsyncWriteExt + Unpin,
pub async fn handle_auth_command<W>(
&self,
auth_action: AuthAction<'_>,
writer: &mut W,
stored_username: Option<&str>,
) -> Result<(usize, bool)>where
W: AsyncWriteExt + Unpin,
Handle an auth command - writes response to client and returns (bytes_written, auth_success)
This is the ONE place where auth interception happens.
§Errors
Returns any I/O error from writing the NNTP auth response to the client.
Sourcepub const fn user_response(&self) -> &'static [u8] ⓘ
pub const fn user_response(&self) -> &'static [u8] ⓘ
Get the AUTHINFO USER response
Sourcepub const fn pass_response(&self) -> &'static [u8] ⓘ
pub const fn pass_response(&self) -> &'static [u8] ⓘ
Get the AUTHINFO PASS response
Trait Implementations§
Source§impl Debug for AuthHandler
impl Debug for AuthHandler
Source§impl Default for AuthHandler
impl Default for AuthHandler
Source§fn default() -> AuthHandler
fn default() -> AuthHandler
Auto Trait Implementations§
impl Freeze for AuthHandler
impl RefUnwindSafe for AuthHandler
impl Send for AuthHandler
impl Sync for AuthHandler
impl Unpin for AuthHandler
impl UnsafeUnpin for AuthHandler
impl UnwindSafe for AuthHandler
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
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> ⓘ
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> ⓘ
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