systemprompt_models/auth/
roles.rs1use std::collections::HashSet;
7
8#[derive(Debug, Clone)]
9pub struct BaseRole {
10 pub name: &'static str,
11 pub display_name: &'static str,
12 pub description: &'static str,
13 pub permissions: HashSet<&'static str>,
14}
15
16#[derive(Debug, Copy, Clone)]
17pub struct BaseRoles;
18
19impl BaseRoles {
20 pub const ANONYMOUS: &'static str = "anonymous";
21 pub const USER: &'static str = "user";
22 pub const ADMIN: &'static str = "admin";
23
24 pub const fn available_roles() -> &'static [&'static str] {
25 &[Self::USER, Self::ADMIN]
26 }
27
28 pub fn anonymous() -> BaseRole {
29 BaseRole {
30 name: Self::ANONYMOUS,
31 display_name: "Anonymous",
32 description: "Unauthenticated user with minimal permissions",
33 permissions: HashSet::from(["users.read"]),
34 }
35 }
36
37 pub fn admin() -> BaseRole {
38 BaseRole {
39 name: Self::ADMIN,
40 display_name: "Administrator",
41 description: "Full system administrator with all permissions",
42 permissions: HashSet::new(),
43 }
44 }
45
46 pub fn all() -> Vec<BaseRole> {
47 vec![Self::anonymous(), Self::admin()]
48 }
49
50 pub const fn is_admin_permission_wildcard() -> bool {
51 true
52 }
53}