-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(refresh): &mut Client instead of Client
Breaking: This changes the existing API ... maybe Borrow can be used to hide the type of client.
- Loading branch information
Showing
5 changed files
with
46 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use common::{Token, AuthenticationType}; | ||
|
||
/// Implements a specialised storage to set and retrieve `Token` instances. | ||
/// The `scope_hash` represents the signature of the scopes for which the given token | ||
/// should be stored or retrieved. | ||
pub trait TokenStorage { | ||
/// If `token` is None, it is invalid or revoked and should be removed from storage. | ||
fn set(&mut self, scope_hash: i64, token: Option<Token>); | ||
/// A `None` result indicates that there is no token for the given scope_hash. | ||
/// It is assumed that a token previously `set` will be retrievable using `get` | ||
fn get(&self, scope_hash: i64) -> Option<Token>; | ||
} | ||
|
||
|
||
/// A generalized authenticator which will keep tokens valid and store them. | ||
/// | ||
/// It is the go-to helper to deal with any kind of supported authentication flow, | ||
/// which will be kept valid and usable. | ||
pub struct Authenticator<S> { | ||
auth_type: AuthenticationType, | ||
storage: S, | ||
// client ref ... | ||
} |