mirror of
https://github.com/OMGeeky/yup-oauth2.git
synced 2026-01-01 09:00:04 +01:00
Change the name of TokenGetterBuilder to AuthFlow.
I believe AuthFlow more succinctly describes the purpose of the type to users reading documentation.
This commit is contained in:
@@ -64,7 +64,7 @@ where
|
||||
}
|
||||
|
||||
/// An internal trait implemented by flows to be used by an authenticator.
|
||||
pub trait TokenGetterBuilder<C> {
|
||||
pub trait AuthFlow<C> {
|
||||
type TokenGetter: GetToken;
|
||||
|
||||
fn build_token_getter(self, client: hyper::Client<C>) -> Self::TokenGetter;
|
||||
@@ -74,7 +74,7 @@ pub trait TokenGetterBuilder<C> {
|
||||
/// will refresh tokens as they expire as well as optionally persist tokens to
|
||||
/// disk.
|
||||
pub struct Authenticator<
|
||||
T: TokenGetterBuilder<C::Connector>,
|
||||
T: AuthFlow<C::Connector>,
|
||||
S: TokenStorage,
|
||||
AD: AuthenticatorDelegate,
|
||||
C: HyperClientBuilder,
|
||||
@@ -87,7 +87,7 @@ pub struct Authenticator<
|
||||
|
||||
impl<T> Authenticator<T, MemoryStorage, DefaultAuthenticatorDelegate, DefaultHyperClient>
|
||||
where
|
||||
T: TokenGetterBuilder<<DefaultHyperClient as HyperClientBuilder>::Connector>,
|
||||
T: AuthFlow<<DefaultHyperClient as HyperClientBuilder>::Connector>,
|
||||
{
|
||||
/// Create a new authenticator with the provided flow. By default a new
|
||||
/// hyper::Client will be created the default authenticator delegate will be
|
||||
@@ -115,7 +115,7 @@ where
|
||||
|
||||
impl<T, S, AD, C> Authenticator<T, S, AD, C>
|
||||
where
|
||||
T: TokenGetterBuilder<C::Connector>,
|
||||
T: AuthFlow<C::Connector>,
|
||||
S: TokenStorage,
|
||||
AD: AuthenticatorDelegate,
|
||||
C: HyperClientBuilder,
|
||||
@@ -127,7 +127,7 @@ where
|
||||
) -> Authenticator<T, S, AD, hyper::Client<NewC>>
|
||||
where
|
||||
NewC: hyper::client::connect::Connect,
|
||||
T: TokenGetterBuilder<NewC>,
|
||||
T: AuthFlow<NewC>,
|
||||
{
|
||||
Authenticator {
|
||||
client: hyper_client,
|
||||
|
||||
@@ -73,7 +73,7 @@ impl<FD> DeviceFlow<FD> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<FD, C> crate::authenticator::TokenGetterBuilder<C> for DeviceFlow<FD>
|
||||
impl<FD, C> crate::authenticator::AuthFlow<C> for DeviceFlow<FD>
|
||||
where
|
||||
FD: FlowDelegate + Send + 'static,
|
||||
C: hyper::client::connect::Connect + 'static,
|
||||
@@ -407,7 +407,7 @@ mod tests {
|
||||
use tokio;
|
||||
|
||||
use super::*;
|
||||
use crate::authenticator::TokenGetterBuilder;
|
||||
use crate::authenticator::AuthFlow;
|
||||
use crate::helper::parse_application_secret;
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -124,6 +124,40 @@ impl InstalledFlow<DefaultFlowDelegate> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<FD> InstalledFlow<FD>
|
||||
where
|
||||
FD: FlowDelegate,
|
||||
{
|
||||
/// Use the provided FlowDelegate.
|
||||
pub fn delegate<NewFD: FlowDelegate>(self, delegate: NewFD) -> InstalledFlow<NewFD> {
|
||||
InstalledFlow {
|
||||
method: self.method,
|
||||
flow_delegate: delegate,
|
||||
appsecret: self.appsecret,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<FD, C> crate::authenticator::AuthFlow<C> for InstalledFlow<FD>
|
||||
where
|
||||
FD: FlowDelegate + Send + 'static,
|
||||
C: hyper::client::connect::Connect + 'static,
|
||||
{
|
||||
type TokenGetter = InstalledFlowImpl<FD, C>;
|
||||
|
||||
fn build_token_getter(self, client: hyper::Client<C>) -> Self::TokenGetter {
|
||||
InstalledFlowImpl {
|
||||
method: self.method,
|
||||
fd: self.flow_delegate,
|
||||
appsecret: self.appsecret,
|
||||
client,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'c, FD: 'static + FlowDelegate + Clone + Send, C: 'c + hyper::client::connect::Connect>
|
||||
InstalledFlowImpl<FD, C>
|
||||
{
|
||||
/// Handles the token request flow; it consists of the following steps:
|
||||
/// . Obtain a authorization code with user cooperation or internal redirect.
|
||||
/// . Obtain a token and refresh token using that code.
|
||||
@@ -543,7 +577,7 @@ mod tests {
|
||||
use tokio;
|
||||
|
||||
use super::*;
|
||||
use crate::authenticator::TokenGetterBuilder;
|
||||
use crate::authenticator::AuthFlow;
|
||||
use crate::authenticator_delegate::FlowDelegate;
|
||||
use crate::helper::*;
|
||||
use crate::types::StringError;
|
||||
|
||||
@@ -93,7 +93,7 @@ mod service_account;
|
||||
mod storage;
|
||||
mod types;
|
||||
|
||||
pub use crate::authenticator::Authenticator;
|
||||
pub use crate::authenticator::{AuthFlow, Authenticator};
|
||||
pub use crate::authenticator_delegate::{
|
||||
AuthenticatorDelegate, DefaultAuthenticatorDelegate, DefaultFlowDelegate, FlowDelegate,
|
||||
PollInformation,
|
||||
|
||||
Reference in New Issue
Block a user