client: actually do authentication properly
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user