Private
Public Access
1
0

client: actually do authentication properly

This commit is contained in:
2025-05-01 01:02:36 -07:00
parent 59cfc8008b
commit fd4c43d585
7 changed files with 105 additions and 74 deletions

View File

@@ -33,29 +33,38 @@ pub trait APIInterface {
}
#[async_trait]
pub trait TokenStore {
pub trait AuthenticationStore {
async fn get_credentials(&mut self) -> Option<Credentials>;
async fn get_token(&mut self) -> Option<JwtToken>;
async fn set_token(&mut self, token: JwtToken);
}
pub struct InMemoryTokenStore {
pub struct InMemoryAuthenticationStore {
credentials: Option<Credentials>,
token: Option<JwtToken>,
}
impl Default for InMemoryTokenStore {
impl Default for InMemoryAuthenticationStore {
fn default() -> Self {
Self::new()
Self::new(None)
}
}
impl InMemoryTokenStore {
pub fn new() -> Self {
Self { token: None }
impl InMemoryAuthenticationStore {
pub fn new(credentials: Option<Credentials>) -> Self {
Self {
credentials,
token: None,
}
}
}
#[async_trait]
impl TokenStore for InMemoryTokenStore {
impl AuthenticationStore for InMemoryAuthenticationStore {
async fn get_credentials(&mut self) -> Option<Credentials> {
self.credentials.clone()
}
async fn get_token(&mut self) -> Option<JwtToken> {
self.token.clone()
}