//! AuthService port — combined authentication operations. //! //! Defines a high-level authentication trait that composes password //! verification and token generation into a single use-case boundary. //! Implementations delegate to the injected `PasswordService` and //! `TokenService` adapters. use anyhow::Result; use std::future::Future; /// High-level authentication service combining password verification /// and token issuance (login flow). /// /// # Flow /// /// 1. **`authenticate`** — verify a subject's password against a stored hash. /// 2. **`issue_tokens`** — generate an access + refresh token pair for a subject. /// /// Implementations are generic over `PasswordService` and `TokenService` /// port traits. pub trait AuthService: Send + Sync { /// Authenticate a user by verifying a password against a stored hash. /// /// Returns `true` if the password matches, `false` otherwise. fn authenticate( &self, password: &str, hash: &str, ) -> impl Future> + Send; /// Issue a new access + refresh token pair for the given subject. /// /// Returns `(access_token, refresh_token)`. fn issue_tokens(&self, sub: &str) -> Result<(String, String)>; }