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 more