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
065657f1
Commit
065657f1
authored
Jan 09, 2001
by
Shane Hathaway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added comments to allowed() and converted an old AttributeError bug into an
authentication failure.
parent
061b94cc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
21 deletions
+39
-21
lib/python/AccessControl/User.py
lib/python/AccessControl/User.py
+39
-21
No files found.
lib/python/AccessControl/User.py
View file @
065657f1
...
...
@@ -84,7 +84,7 @@
##############################################################################
"""Access control package"""
__version__
=
'$Revision: 1.12
4
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.12
5
$'
[
11
:
-
2
]
import
Globals
,
socket
,
ts_regex
,
SpecialUsers
import
os
...
...
@@ -217,40 +217,58 @@ class BasicUser(Implicit):
parent
=
parent
.
aq_parent
else
:
return
r
def
allowed
(
self
,
parent
,
roles
=
None
):
"""Check whether the user has access to parent, assuming that
parent.__roles__ is the given roles."""
if
roles
is
None
or
'Anonymous'
in
roles
:
def
allowed
(
self
,
object
,
object_roles
=
None
):
"""Check whether the user has access to object, assuming that
object.__roles__ is the given roles."""
if
object_roles
is
None
or
'Anonymous'
in
object_roles
:
return
1
usr_roles
=
self
.
getRolesInContext
(
paren
t
)
for
role
in
roles
:
usr_roles
=
self
.
getRolesInContext
(
objec
t
)
for
role
in
object_
roles
:
if
role
in
usr_roles
:
if
(
hasattr
(
self
,
'aq_parent'
)
and
hasattr
(
self
.
aq_parent
,
'aq_parent'
)):
if
parent
is
None
:
return
1
if
(
not
hasattr
(
parent
,
'aq_inContextOf'
)
and
hasattr
(
parent
,
'im_self'
)):
# This is a method, grab it's self.
parent
=
parent
.
im_self
if
not
parent
.
aq_inContextOf
(
self
.
aq_parent
.
aq_parent
,
1
):
if
'Shared'
in
roles
:
# The user apparently has one of the necessary
# roles, but first make sure the object exists
# in the context of the parent of the acl_users
# folder.
ufolder
=
getattr
(
self
,
'aq_parent'
,
None
)
ucontext
=
getattr
(
ufolder
,
'aq_parent'
,
None
)
if
ucontext
is
not
None
:
if
object
is
None
:
# This is a strange rule, though
# it doesn't cause any security holes. SDH
return
1
if
not
hasattr
(
object
,
'aq_inContextOf'
):
if
hasattr
(
object
,
'im_self'
):
# This is a method. Grab its self.
object
=
object
.
im_self
if
not
hasattr
(
object
,
'aq_inContextOf'
):
# object is not wrapped, therefore we
# can't determine context.
# Fail the access attempt. Otherwise
# this would be a security hole.
return
None
if
not
object
.
aq_inContextOf
(
ucontext
,
1
):
if
'Shared'
in
object_roles
:
# Damn, old role setting. Waaa
roles
=
self
.
_shared_roles
(
paren
t
)
object_roles
=
self
.
_shared_roles
(
objec
t
)
if
'Anonymous'
in
roles
:
return
1
return
None
# Note that if self were not wrapped, it would
# not be possible to determine the user's context
# and this method would return 1.
# However, as long as user folders always return
# wrapped user objects, this is safe.
return
1
if
'Shared'
in
roles
:
# Damn, old role setting. Waaa
roles
=
self
.
_shared_roles
(
paren
t
)
roles
=
self
.
_shared_roles
(
objec
t
)
if
roles
is
None
or
'Anonymous'
in
roles
:
return
1
while
'Shared'
in
roles
:
roles
.
remove
(
'Shared'
)
return
self
.
allowed
(
paren
t
,
roles
)
return
self
.
allowed
(
objec
t
,
roles
)
return
None
hasRole
=
allowed
domains
=
[]
...
...
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