1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
use dyn_clone::{clone_trait_object, DynClone};
use crate::re_exports::{ClientId, ClientSecret, Map, Scope, Url, Value};
pub trait Provider: DynClone {
type Scope: Scope;
fn client_id(&self) -> Option<&ClientId>;
fn client_secret(&self) -> Option<&ClientSecret>;
fn token_endpoint_url(&self) -> &Url;
fn extra(&self) -> Option<Map<String, Value>> {
None
}
}
clone_trait_object!(<SCOPE> Provider<Scope = SCOPE> where SCOPE: Scope + Clone);
#[derive(Debug, Clone)]
pub struct ProviderStringScopeWrapper<P>
where
P: Provider,
{
inner: P,
}
impl<P> ProviderStringScopeWrapper<P>
where
P: Provider,
{
pub fn new(provider: P) -> Self {
Self { inner: provider }
}
}
impl<P> Provider for ProviderStringScopeWrapper<P>
where
P: Provider + Clone,
{
type Scope = String;
fn client_id(&self) -> Option<&ClientId> {
self.inner.client_id()
}
fn client_secret(&self) -> Option<&ClientSecret> {
self.inner.client_secret()
}
fn token_endpoint_url(&self) -> &Url {
self.inner.token_endpoint_url()
}
fn extra(&self) -> Option<Map<String, Value>> {
self.inner.extra()
}
}