aboutsummaryrefslogtreecommitdiffstats
path: root/src/config/cli/oauth/mod.rs
blob: 4bf1c34d8494f31e6df25fe114d5f3f404f4fa19 (plain)
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
use clap::Parser;
#[cfg(feature = "oauth-discord")]
use secrecy::SecretString;
use serde::Deserialize;
#[cfg(feature = "oauth")]
use url::Url;

#[derive(Debug, Clone, Parser, Deserialize, Default)]
pub struct OAuth {
    #[cfg(feature = "oauth-discord")]
    #[command(flatten)]
    discord: DiscordOauth,
    #[arg(long, env = "OAUTH_REDIRECT_URL")]
    oauth_redirect_url: Option<Url>,
}

#[cfg(feature = "oauth-discord")]
#[derive(Debug, Clone, Parser, Deserialize, Default)]
pub struct DiscordOauth {
    #[arg(long, env = "OAUTH_DISCORD_CLIENT_ID")]
    discord_client_id: Option<String>,
    #[arg(long, env = "OAUTH_DISCORD_CLIENT_SECRET")]
    discord_client_secret: Option<SecretString>,
    #[arg(
        long,
        env = "OAUTH_DISCORD_TOKEN_URL",
        default_value = "https://discord.com/api/oauth2/token"
    )]
    discord_token_url: Option<Url>,
    #[arg(
        long,
        env = "OAUTH_DISCORD_AUTH_URL",
        default_value = "https://discord.com/api/oauth2/authorize?response_type=code"
    )]
    discord_auth_url: Option<Url>,
}