uqa_sql/catalog/
security.rs1use std::collections::BTreeMap;
8pub mod acl_command;
9pub mod columns;
10pub mod dependencies;
11mod role_bindings;
12pub mod schema;
13pub mod schema_binding;
14pub use schema_binding::BoundSchemaSecurity;
15pub mod table;
16pub mod table_binding;
17pub use table_binding::BoundTableSecurity;
18pub use uqa_core::catalog_acl::{AclGrantee, TableAclEntry, TablePrivileges};
19
20#[derive(Debug, Clone, PartialEq, Eq)]
22pub struct TableSecurity {
23 pub role_owner: String,
24 pub acl: Option<Vec<TableAclEntry>>,
25 pub column_acls: BTreeMap<String, Vec<TableAclEntry>>,
26}
27
28impl TableSecurity {
29 pub fn from_legacy(row: uqa_core::catalog_acl::LegacyRelationSecurity) -> Self {
30 Self {
31 role_owner: row.role_owner,
32 acl: row.acl,
33 column_acls: row.column_acls,
34 }
35 }
36
37 pub fn owner(role_owner: impl Into<String>) -> Self {
38 Self {
39 role_owner: role_owner.into(),
40 acl: None,
41 column_acls: BTreeMap::new(),
42 }
43 }
44}
45
46#[derive(Debug, Clone, PartialEq, Eq)]
47pub struct SchemaSecurity {
48 pub role_owner: String,
49 pub acl: Option<Vec<uqa_core::catalog_schema::SchemaAclEntry>>,
50}
51
52impl SchemaSecurity {
53 pub fn from_row(row: uqa_core::catalog_schema::SchemaRow) -> (String, Self) {
54 (
55 row.name,
56 Self {
57 role_owner: row.role_owner,
58 acl: row.acl,
59 },
60 )
61 }
62
63 pub fn row(&self, name: impl Into<String>) -> uqa_core::catalog_schema::SchemaRow {
64 uqa_core::catalog_schema::SchemaRow {
65 name: name.into(),
66 role_owner: self.role_owner.clone(),
67 acl: self.acl.clone(),
68 }
69 }
70
71 pub fn legacy(name: &str) -> Self {
72 let (_, security) = Self::from_row(uqa_core::catalog_schema::SchemaRow::legacy(name));
73 security
74 }
75}
76
77pub mod schema_inquiry;
78
79pub mod database;
80pub mod database_inquiry;
81
82pub mod sequence;
83pub mod sequence_binding;
84pub use sequence_binding::BoundSequenceSecurity;
85pub mod sequence_grants;
86pub mod sequence_inquiry;
87
88#[derive(Debug, Clone, PartialEq, Eq)]
89pub struct SequenceSecurity {
90 pub role_owner: String,
91 pub acl: Option<Vec<uqa_core::catalog_sequence::SequenceAclEntry>>,
92}
93
94pub mod table_inquiry;
95
96pub mod view_ownership;
97
98pub mod grants;
99pub mod system_relations;
100pub mod table_grants;
101
102pub mod view_authorization;
103
104pub mod ownership;
105
106#[cfg(test)]
107mod owner_privileges;