daemon: Token store
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user