22Security Mechanisms
33===================
44
5- :Version: $Revision: 1.6 $
5+ :Version: $Revision: 1.7 $
66
77Current situation
88=================
@@ -110,15 +110,17 @@ default of deny in this situation.
110110
111111In practice, this is implemented as:
112112
113- 1. there's a mapping of user -> role (in hyperdb)
114- 2. there's a mapping of role -> permission (in code)
115- 3. there's a function that's available to all roundup code that can ask
113+ 1. there's a mapping of user -> role (in hyperdb)
114+ 2. there's a mapping of role -> permission (in code)
115+ 3. there's a set of permissions defined, possibly set against a specific class
116+ (in code)
117+ 4. there's a function that's available to all roundup code that can ask
116118 whether a particular user has a particular permission.
117119
118120Pros:
119121
120122 - quite obvious what is going on
121- - is the current system
123+ - is very similar to the current system
122124
123125Cons:
124126
@@ -135,8 +137,8 @@ Individual assignment of Permission to User is unwieldy. The concept of a
135137Role, which encompasses several Permissions and may be assigned to many Users,
136138is quite well developed in many projects. Roundup will take this path, and
137139allow the multiple assignment of Roles to Users, and multiple Permissions to
138- Roles. These definitions will be stored in the hyperdb.
139-
140+ Roles. These definitions will be stored in the hyperdb. They don't need to be
141+ pushed to the actual database though.
140142
141143A permission module defines::
142144
@@ -160,8 +162,13 @@ A permission module defines::
160162
161163 class PermissionClass(InMemoryImmutableClass):
162164 ''' Include the default attributes:
163- - name (String, key)
165+ - name (String)
166+ - classname (String)
164167 - description (String)
168+
169+ The classname may be unset, indicating that this permission is not
170+ locked to a particular class. That means there may be multiple
171+ Permissions for the same name for different classes.
165172 '''
166173
167174 class RoleClass(InMemoryImmutableClass):
@@ -171,37 +178,46 @@ A permission module defines::
171178 - permissions (PermissionClass Multilink)
172179 '''
173180
174- def hasPermission(db, userid, permission):
181+ def hasPermission(db, userid, permission, classname ):
175182 ''' Look through all the Roles, and hence Permissions, and see if
176- "permission" is there
183+ "permission" is there for the specified classname.
177184 '''
178185
179-
180- The instance dbinit module then has::
181-
182- in open():
186+ The instance dbinit module then has in ``open()``::
183187
184188 perm = permission.PermissionClass(db, "permission")
185189 role = permission.RoleClass(db, "role")
186190
191+ # create some Permissions
187192 wa = perm.create(name="Web Access",
188- description="User may log in through the web")
193+ description="User may use the web interface ")
189194 wr = perm.create(name="Web Registration",
190195 description="User may register through the web")
196+
191197 ma = perm.create(name="Mail Access",
192- description="User may log in through email")
198+ description="User may use the email interface ")
193199 mr = perm.create(name="Mail Registration",
194200 description="User may register through email")
195- ae = perm.create(name="Access Everything",
196- description="User may access everthing")
201+
202+ ee = perm.create(name="Edit",
203+ description="User may edit everthing")
204+ ei = perm.create(name="Edit", classname="issue",
205+ description="User is allowed to edit issues")
206+
207+ ae = perm.create(name="Assign",
208+ description="User may be assigned to anything")
209+ ai = perm.create(name="Assign", classname="issue",
210+ description="User may be assigned to issues")
211+
212+ # create some Roles that use the Permissions
197213 role.create(name="User", description="A regular user, no privs",
198- permissions=[wa, wr, ma, mr])
214+ permissions=[wa, wr, ma, mr, ei, ai ])
199215 role.create(name="Admin", description="An admin user, full privs",
200- permissions=[ae])
216+ permissions=[ee, ae])
201217 role.create(name="No Rego", description="A user who can't register",
202218 permissions=[wa, ma])
203219
204- in init():
220+ in `` init()``: :
205221
206222 r = db.getclass('role').lookup('Admin')
207223 user.create(username="admin", password=Password(adminpw),
0 commit comments