systemprompt_security/authz/
error.rs1use systemprompt_models::domain_error;
4use thiserror::Error;
5
6domain_error! {
7 pub enum AuthzError {
8 common: [repository, validation],
9
10 #[error("invalid rule_type: {0}")]
11 InvalidRuleType(String),
12
13 #[error("invalid access value: {0}")]
14 InvalidAccess(String),
15
16 #[error("authz hook transport: {0}")]
17 Hook(#[from] reqwest::Error),
18
19 #[error("authz bootstrap: {0}")]
20 Bootstrap(#[from] AuthzBootstrapError),
21 }
22}
23
24impl From<sqlx::Error> for AuthzError {
25 fn from(err: sqlx::Error) -> Self {
26 Self::Repository(systemprompt_database::RepositoryError::from(err))
27 }
28}
29
30pub type AuthzResult<T> = Result<T, AuthzError>;
31
32#[derive(Debug, Clone, Copy, Error)]
33pub enum AuthzBootstrapError {
34 #[error(
35 "governance.authz.hook.mode = webhook but `url` is missing or blank — refusing to start"
36 )]
37 MissingWebhookUrl,
38
39 #[error(
40 "governance.authz.hook.mode = unrestricted requires `acknowledgement` field equal to the \
41 literal: {expected:?}"
42 )]
43 MissingUnrestrictedAcknowledgement { expected: &'static str },
44}