Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
dd4f5983
Commit
dd4f5983
authored
Jan 09, 1998
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
*** empty log message ***
parent
6432f4ef
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
17 deletions
+47
-17
lib/python/AccessControl/Role.py
lib/python/AccessControl/Role.py
+3
-5
lib/python/AccessControl/User.py
lib/python/AccessControl/User.py
+44
-12
No files found.
lib/python/AccessControl/Role.py
View file @
dd4f5983
"""Access control support"""
__version__
=
'$Revision: 1.1
1
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
2
$'
[
11
:
-
2
]
from
Globals
import
HTMLFile
,
MessageDialog
...
...
@@ -17,13 +17,13 @@ class RoleManager:
(
'Add properties'
,
[]),
(
'Change properties'
,
[]),
(
'Delete properties'
,
[]),
(
'
Default
permission'
,[
''
]),
(
'
Shared
permission'
,[
''
]),
)
__ac_types__
=
((
'Full Access'
,
map
(
lambda
x
:
x
[
0
],
__ac_permissions__
)),
)
__ac_roles__
=
(
'Manager'
,
'Anonymous'
)
__ac_roles__
=
(
'Manager'
,
'Anonymous'
,
'Shared'
)
def
access_info
(
self
):
# Return access summary info
...
...
@@ -32,8 +32,6 @@ class RoleManager:
name
=
t
.
name
for
role
in
t
.
getRoles
():
data
[
role
]
=
name
# try: del data['Manager']
# except: pass
keys
=
data
.
keys
()
for
i
in
range
(
len
(
keys
)):
key
=
keys
[
i
]
...
...
lib/python/AccessControl/User.py
View file @
dd4f5983
"""Access control package"""
__version__
=
'$Revision: 1.3
2
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.3
3
$'
[
11
:
-
2
]
from
PersistentMapping
import
PersistentMapping
...
...
@@ -25,13 +25,35 @@ class User(Implicit, Persistent):
def
authenticate
(
self
,
password
):
return
password
==
self
.
__
def
hasRole
(
self
,
inst
,
roles
=
None
):
if
roles
is
None
:
return
1
for
role
in
roles
:
if
role
in
self
.
roles
:
def
hasRole
(
self
,
parent
,
roles
=
None
):
obj
=
parent
obj_roles
=
roles
usr_roles
=
self
.
roles
while
1
:
if
(
obj_roles
is
None
)
or
(
'Anonymous'
in
obj_roles
):
return
1
return
0
for
role
in
obj_roles
:
if
role
in
usr_roles
:
return
1
if
'Shared'
in
obj_roles
:
if
not
hasattr
(
obj
,
'aq_parent'
):
return
0
obj
=
obj
.
aq_parent
if
hasattr
(
obj
,
'__roles__'
):
obj_roles
=
obj
.
__roles__
else
:
obj_roles
=
[
'Shared'
,]
continue
return
0
# if (roles is None) or ('Anonymous' in roles):
# return 1
# for role in roles:
# if role in self.roles:
# return 1
# return 0
def
__len__
(
self
):
return
1
def
__str__
(
self
):
return
self
.
name
...
...
@@ -87,25 +109,35 @@ class UserFolder(Implicit, Persistent, Navigation, Tabs, Item,
return
keys
def
validate
(
self
,
request
,
auth
=
''
,
roles
=
None
):
parent
=
request
[
'PARENTS'
][
0
]
# If no authorization, only nobody can match
if
not
auth
:
if
roles
is
None
:
if
nobody
.
hasRole
(
parent
,
roles
)
:
return
nobody
return
None
# Only do basic authentication
if
lower
(
auth
[:
6
])
!=
'basic '
:
return
None
name
,
password
=
tuple
(
split
(
decodestring
(
split
(
auth
)[
-
1
]),
':'
))
# Check for superuser
if
self
.
_isTop
()
and
(
name
==
super
.
name
)
and
\
super
.
authenticate
(
password
):
return
super
# Try to get user
try
:
user
=
self
.
data
[
name
]
except
:
return
None
# Try to authenticate user
if
not
user
.
authenticate
(
password
):
return
None
if
roles
is
None
:
# Try to authorize user
if
user
.
hasRole
(
parent
,
roles
):
return
user
for
role
in
roles
:
if
role
in
user
.
roles
:
return
user
return
None
_mainUser
=
HTMLFile
(
'mainUser'
,
globals
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment