pub enum AuthProvider {
BasicAuth(String, String),
JwtToken(String),
None,
}Expand description
Authentication credentials for KalamDB server.
Supports JWT tokens and login credentials.
Password credentials are exchanged through /v1/api/auth/login before they
can be used for authenticated requests.
§Examples
use kalam_client::AuthProvider;
// Login credentials (exchanged for JWTs automatically)
let auth = AuthProvider::basic_auth("user".to_string(), "password".to_string());
// JWT token authentication
let auth = AuthProvider::jwt_token("eyJhbGc...".to_string());
// No authentication (localhost bypass mode)
let auth = AuthProvider::none();Variants§
BasicAuth(String, String)
HTTP Basic Auth (user, password)
JwtToken(String)
JWT token authentication
None
No authentication (localhost bypass)
Implementations§
Source§impl AuthProvider
impl AuthProvider
Sourcepub fn basic_auth(user: String, password: String) -> AuthProvider
pub fn basic_auth(user: String, password: String) -> AuthProvider
Create login credentials for POST /v1/api/auth/login.
Sourcepub fn system_user_auth(password: String) -> AuthProvider
pub fn system_user_auth(password: String) -> AuthProvider
Create system user authentication (convenience for CLI and internal tools)
Uses the default system user “root” with provided password.
Sourcepub fn jwt_token(token: String) -> AuthProvider
pub fn jwt_token(token: String) -> AuthProvider
Create JWT token authentication
Sourcepub fn none() -> AuthProvider
pub fn none() -> AuthProvider
No authentication (for localhost bypass mode)
Sourcepub fn apply_to_request(
&self,
request: RequestBuilder,
) -> Result<RequestBuilder, KalamLinkError>
pub fn apply_to_request( &self, request: RequestBuilder, ) -> Result<RequestBuilder, KalamLinkError>
Attach authentication headers to an HTTP request builder.
Password credentials must be exchanged on /v1/api/auth/login before
they can be used for authenticated requests. This method therefore only
supports bearer tokens and anonymous requests.
Sourcepub fn is_authenticated(&self) -> bool
pub fn is_authenticated(&self) -> bool
Check if authentication is configured
Trait Implementations§
Source§impl Clone for AuthProvider
impl Clone for AuthProvider
Source§fn clone(&self) -> AuthProvider
fn clone(&self) -> AuthProvider
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more