pub struct AuthClient { /* private fields */ }Expand description
Authentication client for interacting with Brainwires Studio backend
Unlike the CLI version, this client does NOT auto-save sessions or manage keyring storage. The caller is responsible for persisting the auth response.
Implementations§
Source§impl AuthClient
impl AuthClient
Sourcepub fn new(
backend_url: String,
auth_endpoint: String,
api_key_pattern: &str,
) -> Self
pub fn new( backend_url: String, auth_endpoint: String, api_key_pattern: &str, ) -> Self
Create a new authentication client
§Arguments
backend_url- Base URL (e.g.,https://brainwires.studio)auth_endpoint- Auth endpoint path (e.g., “/api/cli/auth”)api_key_pattern- Regex pattern for API key validation (e.g., r“^bw_(prod|dev|test)_[a-z0-9]{32}$“)
Sourcepub fn from_endpoints(endpoints: &dyn AuthEndpoints) -> Self
pub fn from_endpoints(endpoints: &dyn AuthEndpoints) -> Self
Create from an AuthEndpoints trait implementation
Sourcepub fn validate_api_key_format(&self, api_key: &str) -> Result<()>
pub fn validate_api_key_format(&self, api_key: &str) -> Result<()>
Validate API key format against the configured pattern
Sourcepub async fn authenticate(&self, api_key: &str) -> Result<AuthResponse>
pub async fn authenticate(&self, api_key: &str) -> Result<AuthResponse>
Authenticate with API key
Returns the raw AuthResponse from the backend. The caller is responsible
for creating a session and storing the API key.
Sourcepub fn backend_url(&self) -> &str
pub fn backend_url(&self) -> &str
Get the configured backend URL
Auto Trait Implementations§
impl Freeze for AuthClient
impl !RefUnwindSafe for AuthClient
impl Send for AuthClient
impl Sync for AuthClient
impl Unpin for AuthClient
impl UnsafeUnpin for AuthClient
impl !UnwindSafe for AuthClient
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
Mutably borrows from an owned value. Read more