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
use oauth2_client::re_exports::{Deserialize_enum_str, Scope, Serialize_enum_str};
pub const TENANT_COMMON: &str = "common";
pub mod authorization_code_grant;
pub mod device_authorization_grant;
pub use authorization_code_grant::MicrosoftProviderForWebApps;
pub use device_authorization_grant::MicrosoftProviderForDevices;
pub mod extensions;
pub use extensions::MicrosoftExtensionsBuilder;
pub fn token_url(tenant: impl AsRef<str>) -> String {
format!(
"https://login.microsoftonline.com/{}/oauth2/v2.0/token",
tenant.as_ref()
)
}
pub fn device_authorization_url(tenant: impl AsRef<str>) -> String {
format!(
"https://login.microsoftonline.com/{}/oauth2/v2.0/devicecode",
tenant.as_ref()
)
}
pub fn authorization_url(tenant: impl AsRef<str>) -> String {
format!(
"https://login.microsoftonline.com/{}/oauth2/v2.0/authorize",
tenant.as_ref()
)
}
#[derive(Deserialize_enum_str, Serialize_enum_str, Debug, Clone, PartialEq)]
pub enum MicrosoftScope {
#[serde(rename = "openid")]
Openid,
#[serde(rename = "email")]
Email,
#[serde(rename = "profile")]
Profile,
#[serde(rename = "offline_access")]
OfflineAccess,
#[serde(rename = "User.Read")]
#[serde(alias = "https://graph.microsoft.com/User.Read")]
UserRead,
#[serde(other)]
Other(String),
}
impl Scope for MicrosoftScope {}