Riapplica la fase 5 di aKode (86e7c72e) sulla base ripulita:
- crate codex-* -> akode-*, codex-rs -> akode-rs, codex-cli -> akode-cli, binario e ausiliari akode;
- ~/.codex -> ~/.akode, CODEX_HOME -> AKODE_HOME, variabili CODEX_* -> AKODE_*, .codex/ -> .akode/ di progetto;
nessun fallback a ~/.codex o a CODEX_*;
- testi per l'utente "Codex" -> "aKode"; testi verso il modello e istruzioni di sistema invariati;
- snapshot insta rinominati (non ancora rigenerati).
I conflitti con la base ripulita sono stati risolti riapplicando la rinomina ai file senza le
funzioni di imeAI (script di mappa dei token per file).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
37 lines
935 B
Rust
37 lines
935 B
Rust
use akode_api::AuthProvider;
|
|
use http::HeaderMap;
|
|
use http::HeaderValue;
|
|
|
|
/// Bearer-token auth provider for OpenAI-compatible model-provider requests.
|
|
#[derive(Clone, Default)]
|
|
pub struct BearerAuthProvider {
|
|
pub token: Option<String>,
|
|
}
|
|
|
|
impl BearerAuthProvider {
|
|
pub fn new(token: String) -> Self {
|
|
Self { token: Some(token) }
|
|
}
|
|
|
|
pub fn for_test(token: Option<&str>) -> Self {
|
|
Self {
|
|
token: token.map(str::to_string),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl AuthProvider for BearerAuthProvider {
|
|
fn add_auth_headers(&self, headers: &mut HeaderMap) -> Result<(), akode_api::AuthError> {
|
|
if let Some(token) = self.token.as_ref()
|
|
&& let Ok(header) = HeaderValue::from_str(&format!("Bearer {token}"))
|
|
{
|
|
let _ = headers.insert(http::header::AUTHORIZATION, header);
|
|
}
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
#[path = "bearer_auth_provider_tests.rs"]
|
|
mod tests;
|