Skip to main content

systemprompt_security/authz/types/
rule.rs

1//! Access-control rule and entity row types.
2//!
3//! Copyright (c) systemprompt.io — Business Source License 1.1.
4//! See <https://systemprompt.io> for licensing details.
5
6use serde::{Deserialize, Serialize};
7use systemprompt_identifiers::RuleId;
8
9use super::kinds::{Access, EntityKind, RuleType};
10
11#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, sqlx::FromRow)]
12pub struct AccessRule {
13    pub id: RuleId,
14    pub rule_type: RuleType,
15    pub rule_value: String,
16    pub access: Access,
17    #[serde(default, skip_serializing_if = "Option::is_none")]
18    pub justification: Option<String>,
19}
20
21/// One row from `access_control_entities`.
22///
23/// The `source` provenance string identifies which loader pass first
24/// registered the entity: `"profile:<name>"`, `"roles.yaml"`, or
25/// `"bootstrap:*"` for rows promoted from older schemas by a migration.
26///
27/// A `None` lookup result means the entity is unknown to access control and
28/// the resolver returns [`super::decision::DenyReason::UnknownEntity`] rather
29/// than the generic `NotAssigned`.
30#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
31pub struct EntityRow {
32    pub kind: EntityKind,
33    pub id: String,
34    pub default_included: bool,
35    pub source: String,
36}