pub struct AuthService { /* private fields */ }Expand description
Authentication service
Implementations§
Source§impl AuthService
impl AuthService
pub fn new(auth_type: AuthType) -> Self
Sourcepub async fn generate_token(
&self,
agent_id: String,
capabilities: AgentCapability,
expires_in: Option<Duration>,
) -> Result<AuthToken, UbiquityError>
pub async fn generate_token( &self, agent_id: String, capabilities: AgentCapability, expires_in: Option<Duration>, ) -> Result<AuthToken, UbiquityError>
Generate a new authentication token
Sourcepub async fn validate_token(
&self,
token_str: &str,
) -> Result<AuthToken, UbiquityError>
pub async fn validate_token( &self, token_str: &str, ) -> Result<AuthToken, UbiquityError>
Validate a token
Sourcepub async fn register_api_key(
&self,
api_key: String,
agent_id: String,
) -> Result<(), UbiquityError>
pub async fn register_api_key( &self, api_key: String, agent_id: String, ) -> Result<(), UbiquityError>
Register an API key
Sourcepub async fn validate_api_key(
&self,
api_key: &str,
) -> Result<String, UbiquityError>
pub async fn validate_api_key( &self, api_key: &str, ) -> Result<String, UbiquityError>
Validate an API key
Sourcepub async fn authenticate(
&self,
credentials: &str,
) -> Result<String, UbiquityError>
pub async fn authenticate( &self, credentials: &str, ) -> Result<String, UbiquityError>
Authenticate based on configured method
Sourcepub async fn check_capability(
&self,
token_str: &str,
check: impl FnOnce(&AgentCapability) -> bool,
) -> Result<bool, UbiquityError>
pub async fn check_capability( &self, token_str: &str, check: impl FnOnce(&AgentCapability) -> bool, ) -> Result<bool, UbiquityError>
Check if an agent has a specific capability
Sourcepub async fn revoke_token(&self, token_str: &str) -> Result<(), UbiquityError>
pub async fn revoke_token(&self, token_str: &str) -> Result<(), UbiquityError>
Revoke a token
Sourcepub async fn cleanup_expired_tokens(&self)
pub async fn cleanup_expired_tokens(&self)
Clean up expired tokens
Auto Trait Implementations§
impl !RefUnwindSafe for AuthService
impl !UnwindSafe for AuthService
impl Freeze for AuthService
impl Send for AuthService
impl Sync for AuthService
impl Unpin for AuthService
impl UnsafeUnpin for AuthService
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