This commit was generated by cvs2svn to compensate for changes in r2523,
[freeside.git] / rt / docs / design_docs / acls
1 $Header: /home/cvs/cvsroot/freeside/rt/docs/design_docs/acls,v 1.1 2002-08-12 06:17:07 ivan Exp $
2
3
4
5 # {{{ Requirements 
6
7 Here's the rough scheme I was thinking of for RT2 acls. Thoughts? I think
8 it's a lot more flexible than RT 1.0, but not so crazily complex that
9 it will be impossible to implement.  One of the "interesting" features
10 is the ability to grant acls based on watcher status. This now lives
11 in design-docs/acls
12
13         jesse
14
15 Who can rights be granted to:
16
17         users whose id is <foo>
18         users who are watchers of type <requestor/cc/admincc> for <queue/ticket> <id>
19         users who are watchers of type <requestor/cc/admincc> for <this ticket / this queue>
20
21
22 what scope do these rights apply to
23         queue <id>
24         system
25         
26
27 What rights can be granted
28         Display Ticket
29         Manipulate Ticket
30                 Only users with manipulate ticket level access will see comments
31         Maniplulate Ticket Status
32         Create Ticket   
33
34         Admin Queue Watchers 
35         Admin Ticket Watchers
36         Admin user accounts
37         Admin scrips
38         Admin scripscopes
39         Admin Queue ACLS
40         Admin System ACLs
41
42 # }}}
43
44
45 # {{{ Prinicpals  These are the entities in your Access Control Element
46 #
47
48 Principal: What user does this right apply to
49
50         Made up of: 
51                 PrincipalScope, PrincipalType and PrincipalId
52
53         
54         User:   
55                 Scope:  User    
56                 Type:   null
57                 Id:     A userid or 0
58
59         Owner:
60                 Scope:  Owner
61                 Type:   null
62                 Id:     none
63
64
65         Watchers:
66
67                 Scope: Ticket
68                 Type:   Requestors; Cc; AdminCc
69                 Id:     A ticket id or 0 for "this ticket"
70
71                 Scope: Queue
72                 Type:   Cc; AdminCc
73                 Id:     A queue id or 0 for "this queue"
74
75
76 # }}}
77
78 # {{{ Object: What object does this right apply to
79
80         Object is composed of an ObjectType and an ObjectId
81
82         Type:   System  
83         Id:     NULL
84
85         Type:   Queue
86         Id:     Integer ref to queue id or 0 for all queues
87         
88 # }}}
89
90 # {{{ Right: (What does this entry give the principal the right to do)
91
92
93
94         For the Object System:
95                 System::SetACL
96                 System::AdminScrips
97
98                 User::Display
99                 User::Create
100                 User::Destroy
101                 User::Modify
102                 User::SetPassword
103
104
105
106         For the Object "Queue":
107                 Queue::Admin
108                 Queue::SetACL
109                 Queue::Create
110                 Queue::Display
111                 Queue::Destroy
112                 Queue::ModifyWatchers
113                 Ticket::Create
114                 Ticket::Destory
115                 Ticket::Display
116                 Ticket::Update
117                 Ticket::UpdateRequestors
118                 Ticket::UpdateCc
119                 Ticket::UpdateAdminCc
120                 Ticket::NotifyWatchers
121
122                 
123                 DEFERRED
124
125                 Ticket::SetStatus:      (Values)
126                                         Open
127                                         Resolved
128                                         Stalled
129                                         <null> means any
130
131
132 # }}}
133
134
135 # {{{ Implementation:
136
137 # {{{ SQL Schema 
138 CREATE TABLE ACL (
139         id int not null primary_key autoincrement,
140         PrinicpalId INT(11),
141         PrincipalType VARCHAR(16),
142         PrincipalScope VARCHAR(16),
143         ObjectType VARCHAR(16),
144         ObjectId  INT,
145         Right VARCHAR(16)
146 );
147
148 # }}}
149
150 # {{{ perl implementation of rights searches
151
152 sub Principals {
153 if (defined $Ticket) {
154         return "($UserPrincipal) OR ($OwnerPrincipal) OR ($WatchersPrincipal)";
155         }
156 else {
157         return   "($UserPrincipal) OR ($WatchersPrincipal)";
158         }  
159 }
160         
161 $Principals = " ($UserPrincipal) OR ($OwnerPrincipal) OR ($WatchersPrincipal)";
162
163 $UserPrincipal = " ( ACE.PrincipalScope = 'User') AND 
164                    ( ACE.PrincipalId = $User OR ACE.PrincipalId = 0)";
165
166 $OwnerPrincipal = " ( ACE.PrinciaplScope = 'Owner') AND 
167                       ( Tickets.Owner = "$User ) AND    
168                       ( Tickets.Id = $Ticket)";
169
170 $WatchersPrincipal = " ( ACE.PrincipalScope = Watchers.Scope ) AND 
171                       ( ACE.PrincipalType = Watchers.Type ) AND 
172                       ( ACL.PrincipalId = Watchers.Value ) AND 
173                       ( Watchers.Owner = $User )";
174
175 $QueueObject = "( ACE.ObjectType = 'Queue' and (ACE.ObjectId = $Queue OR ACE.ObjectId = 0)";
176
177 $SystemObject = "( ACE.ObjectType = 'System' )";
178
179
180 # This select statement would figure out if A user has $Right at the queue level
181
182 SELECT ACE.id from ACE, Watchers, Tickets WHERE ( 
183              $QueueObject
184              AND ( ACE.Right = $Right) 
185              AND ($Principals))
186
187 # This select statement would figure outif a user has $Right for the "System"
188
189 SELECT ACE.id from ACE, Watchers, Tickets WHERE ( 
190              ($SystemObject) AND ( ACE.Right = $Right ) AND ($Principals))
191
192 # }}}
193
194 # }}}
195
196 # {{{ Examples
197 #
198
199 # }}}   
200
201
202
203 Unaddressed issues:
204
205         There needs to be a more refined method for grouping users, such that members of the customer service department
206 can't change sysadmins' passwords.