mas_config/sections/
oauth.rs1use schemars::JsonSchema;
8use serde::{Deserialize, Serialize};
9
10use crate::ConfigurationSection;
11
12const fn default_true() -> bool {
13 true
14}
15
16const fn default_false() -> bool {
17 false
18}
19
20#[expect(clippy::trivially_copy_pass_by_ref)]
21const fn is_default_true(value: &bool) -> bool {
22 *value == default_true()
23}
24
25#[expect(clippy::trivially_copy_pass_by_ref)]
26const fn is_default_false(value: &bool) -> bool {
27 *value == default_false()
28}
29
30#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)]
32pub struct OAuthConfig {
33 #[serde(default = "default_true", skip_serializing_if = "is_default_true")]
42 pub device_code_grant_enabled: bool,
43
44 #[serde(default = "default_false", skip_serializing_if = "is_default_false")]
53 pub device_code_user_code_auto_fill_enabled: bool,
54}
55
56impl Default for OAuthConfig {
57 fn default() -> Self {
58 Self {
59 device_code_grant_enabled: default_true(),
60 device_code_user_code_auto_fill_enabled: default_false(),
61 }
62 }
63}
64
65impl OAuthConfig {
66 pub(crate) fn is_default(&self) -> bool {
68 is_default_true(&self.device_code_grant_enabled)
69 && is_default_false(&self.device_code_user_code_auto_fill_enabled)
70 }
71}
72
73impl ConfigurationSection for OAuthConfig {
74 const PATH: Option<&'static str> = Some("oauth");
75}