You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-08-09 04:22:45 +03:00
Clean up the default policy config data
This commit is contained in:
@@ -114,13 +114,9 @@ pub async fn policy_factory_from_config(
|
|||||||
password: config.password_entrypoint.clone(),
|
password: config.password_entrypoint.clone(),
|
||||||
};
|
};
|
||||||
|
|
||||||
PolicyFactory::load(
|
PolicyFactory::load(policy_file, config.data.clone(), entrypoints)
|
||||||
policy_file,
|
.await
|
||||||
config.data.clone().unwrap_or_default(),
|
.context("failed to load the policy")
|
||||||
entrypoints,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.context("failed to load the policy")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn templates_from_config(
|
pub async fn templates_from_config(
|
||||||
|
@@ -56,6 +56,10 @@ fn default_email_endpoint() -> String {
|
|||||||
"email/violation".to_owned()
|
"email/violation".to_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn default_data() -> serde_json::Value {
|
||||||
|
serde_json::json!({})
|
||||||
|
}
|
||||||
|
|
||||||
/// Application secrets
|
/// Application secrets
|
||||||
#[serde_as]
|
#[serde_as]
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
|
||||||
@@ -86,8 +90,8 @@ pub struct PolicyConfig {
|
|||||||
pub email_entrypoint: String,
|
pub email_entrypoint: String,
|
||||||
|
|
||||||
/// Arbitrary data to pass to the policy
|
/// Arbitrary data to pass to the policy
|
||||||
#[serde(default)]
|
#[serde(default = "default_data")]
|
||||||
pub data: Option<serde_json::Value>,
|
pub data: serde_json::Value,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for PolicyConfig {
|
impl Default for PolicyConfig {
|
||||||
@@ -99,7 +103,7 @@ impl Default for PolicyConfig {
|
|||||||
authorization_grant_entrypoint: default_authorization_grant_endpoint(),
|
authorization_grant_entrypoint: default_authorization_grant_endpoint(),
|
||||||
password_entrypoint: default_password_endpoint(),
|
password_entrypoint: default_password_endpoint(),
|
||||||
email_entrypoint: default_email_endpoint(),
|
email_entrypoint: default_email_endpoint(),
|
||||||
data: None,
|
data: default_data(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -188,7 +188,7 @@
|
|||||||
"authorization_grant_entrypoint": "authorization_grant/violation",
|
"authorization_grant_entrypoint": "authorization_grant/violation",
|
||||||
"password_entrypoint": "password/violation",
|
"password_entrypoint": "password/violation",
|
||||||
"email_entrypoint": "email/violation",
|
"email_entrypoint": "email/violation",
|
||||||
"data": null
|
"data": {}
|
||||||
},
|
},
|
||||||
"allOf": [
|
"allOf": [
|
||||||
{
|
{
|
||||||
@@ -1647,7 +1647,7 @@
|
|||||||
},
|
},
|
||||||
"data": {
|
"data": {
|
||||||
"description": "Arbitrary data to pass to the policy",
|
"description": "Arbitrary data to pass to the policy",
|
||||||
"default": null
|
"default": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user