pub struct BasicAuthProvider { /* private fields */ }Expand description
Basic authentication provider implementing RFC 7617.
Provides simple username/password authentication with optional HTTPS enforcement to prevent credential leakage over insecure connections.
§Example
use aria2_core::auth::basic_auth::BasicAuthProvider;
let provider = BasicAuthProvider::new(
"alice".to_string(),
"secret-password".to_string(),
true, // Enforce HTTPS
);Implementations§
Source§impl BasicAuthProvider
impl BasicAuthProvider
Sourcepub fn new(username: String, password: String, https_only: bool) -> Self
pub fn new(username: String, password: String, https_only: bool) -> Self
Creates a new Basic authentication provider.
§Arguments
username- The username for authenticationpassword- The password for authenticationhttps_only- If true, rejects non-HTTPS URLs for security
§Security Note
Setting https_only to true is strongly recommended to prevent
credential interception. Basic auth credentials are trivially decoded
from Base64, making HTTPS essential for security.
Sourcepub fn is_https_only(&self) -> bool
pub fn is_https_only(&self) -> bool
Returns whether this provider enforces HTTPS-only mode.
Builds an Authorization header value with URL validation.
This is the recommended method as it validates the URL scheme before
generating credentials when https_only is enabled.
§Arguments
challenge- The authentication challenge (realm info)url- The request URL (used for scheme validation)
§Returns
Complete Authorization header value or error if:
- URL scheme is not HTTPS and
https_onlyis enabled - Base64 encoding fails (unlikely but possible)
§Errors
Returns Aria2Error::Parse if the URL cannot be parsed
Returns Aria2Error::DownloadFailed if HTTPS is required but not used
Trait Implementations§
Source§impl AuthProvider for BasicAuthProvider
impl AuthProvider for BasicAuthProvider
Source§fn scheme(&self) -> AuthScheme
fn scheme(&self) -> AuthScheme
Source§impl Clone for BasicAuthProvider
impl Clone for BasicAuthProvider
Source§fn clone(&self) -> BasicAuthProvider
fn clone(&self) -> BasicAuthProvider
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for BasicAuthProvider
impl RefUnwindSafe for BasicAuthProvider
impl Send for BasicAuthProvider
impl Sync for BasicAuthProvider
impl Unpin for BasicAuthProvider
impl UnsafeUnpin for BasicAuthProvider
impl UnwindSafe for BasicAuthProvider
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> 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>
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