git_lfs_api/auth.rs
1use reqwest::RequestBuilder;
2
3/// Authentication to attach to API requests.
4///
5/// Populated by the caller — typically by `creds/` once it lands. Resolving
6/// credentials (git-credential, keychain, etc.) is deliberately not this
7/// crate's job.
8#[derive(Debug, Clone)]
9pub enum Auth {
10 /// No `Authorization` header.
11 None,
12 /// HTTP Basic auth — sent as `Authorization: Basic <base64(user:pass)>`.
13 Basic { username: String, password: String },
14 /// Bearer token — sent as `Authorization: Bearer <token>`.
15 Bearer(String),
16}
17
18impl Auth {
19 pub(crate) fn apply(&self, req: RequestBuilder) -> RequestBuilder {
20 match self {
21 Auth::None => req,
22 Auth::Basic { username, password } => req.basic_auth(username, Some(password)),
23 Auth::Bearer(token) => req.bearer_auth(token),
24 }
25 }
26}