mas_config/sections/
oauth.rs1use schemars::JsonSchema;
7use serde::{Deserialize, Serialize};
8
9use crate::ConfigurationSection;
10
11const fn default_true() -> bool {
12 true
13}
14
15#[allow(clippy::trivially_copy_pass_by_ref)]
16const fn is_default_true(value: &bool) -> bool {
17 *value == default_true()
18}
19
20#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)]
22pub struct OAuthConfig {
23 #[serde(default = "default_true", skip_serializing_if = "is_default_true")]
32 pub device_code_grant_enabled: bool,
33}
34
35impl Default for OAuthConfig {
36 fn default() -> Self {
37 Self {
38 device_code_grant_enabled: default_true(),
39 }
40 }
41}
42
43impl OAuthConfig {
44 pub(crate) fn is_default(&self) -> bool {
46 is_default_true(&self.device_code_grant_enabled)
47 }
48}
49
50impl ConfigurationSection for OAuthConfig {
51 const PATH: Option<&'static str> = Some("oauth");
52}