Private
Public Access
1
0

daemon: Token store

This commit is contained in:
2025-04-27 14:01:19 -07:00
parent 84f782cc03
commit 49f8b81b9c
8 changed files with 51 additions and 26 deletions

View File

@@ -26,22 +26,24 @@ pub trait APIInterface {
async fn authenticate(&mut self, credentials: Credentials) -> Result<JwtToken, Self::Error>;
}
pub trait TokenManagement {
#[async_trait]
pub trait TokenStore {
async fn get_token(&mut self) -> Option<JwtToken>;
async fn set_token(&mut self, token: JwtToken);
}
pub struct InMemoryTokenManagement {
pub struct InMemoryTokenStore {
token: Option<JwtToken>,
}
impl InMemoryTokenManagement {
impl InMemoryTokenStore {
pub fn new() -> Self {
Self { token: None }
}
}
impl TokenManagement for InMemoryTokenManagement {
#[async_trait]
impl TokenStore for InMemoryTokenStore {
async fn get_token(&mut self) -> Option<JwtToken> {
self.token.clone()
}