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
69
70
71
72
73
74
75
76
77
78
79
80
81
//! Registered OAuth 2.0 clients for [`super::server::AuthServer`].
/// An OAuth 2.0 grant type a registered client is authorized to use.
/// A registered OAuth 2.0 client.
/// In-memory registry of [`OAuthClient`]s, looked up by `client_id`.
///
/// # Example
///
/// ```rust
/// use rust_web_server::sso::client_store::{ClientStore, OAuthClient, GrantType};
///
/// let clients = ClientStore::new()
/// .add(OAuthClient {
/// client_id: "spa-frontend".into(),
/// client_secret: None,
/// redirect_uris: vec!["https://spa.example.com/callback".into()],
/// grants: vec![GrantType::AuthorizationCode],
/// scopes: vec!["openid".into(), "email".into()],
/// })
/// .add(OAuthClient {
/// client_id: "backend-service".into(),
/// client_secret: Some("s3cr3t".into()),
/// redirect_uris: vec![],
/// grants: vec![GrantType::ClientCredentials],
/// scopes: vec!["api:read".into(), "api:write".into()],
/// });
///
/// assert!(clients.get("spa-frontend").is_some());
/// assert!(clients.get("unknown-client").is_none());
/// ```