static_authn_plugin/
config.rs1use serde::Deserialize;
4use uuid::Uuid;
5
6use modkit_security::constants::{DEFAULT_SUBJECT_ID, DEFAULT_TENANT_ID};
7
8#[derive(Debug, Clone, Deserialize)]
10#[serde(default, deny_unknown_fields)]
11pub struct StaticAuthNPluginConfig {
12 pub vendor: String,
14
15 pub priority: i16,
17
18 pub mode: AuthNMode,
20
21 pub default_identity: IdentityConfig,
23
24 pub tokens: Vec<TokenMapping>,
26}
27
28impl Default for StaticAuthNPluginConfig {
29 fn default() -> Self {
30 Self {
31 vendor: "hyperspot".to_owned(),
32 priority: 100,
33 mode: AuthNMode::AcceptAll,
34 default_identity: IdentityConfig::default(),
35 tokens: Vec::new(),
36 }
37 }
38}
39
40#[derive(Debug, Clone, Deserialize, Default)]
42#[serde(rename_all = "snake_case")]
43pub enum AuthNMode {
44 #[default]
46 AcceptAll,
47 StaticTokens,
49}
50
51#[derive(Debug, Clone, Deserialize)]
53#[serde(default, deny_unknown_fields)]
54pub struct IdentityConfig {
55 pub subject_id: Uuid,
57
58 pub subject_tenant_id: Uuid,
60
61 pub token_scopes: Vec<String>,
63}
64
65impl Default for IdentityConfig {
66 fn default() -> Self {
67 Self {
68 subject_id: DEFAULT_SUBJECT_ID,
69 subject_tenant_id: DEFAULT_TENANT_ID,
70 token_scopes: vec!["*".to_owned()],
71 }
72 }
73}
74
75#[derive(Debug, Clone, Deserialize)]
77#[serde(deny_unknown_fields)]
78pub struct TokenMapping {
79 pub token: String,
81 pub identity: IdentityConfig,
83}