Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
139
Merge Requests
139
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
91a3e907
Commit
91a3e907
authored
Sep 25, 2013
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
respect caller script's proxy roles in checking Python Script guard.
parent
abf7491b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
6 deletions
+16
-6
product/ERP5Type/patches/PythonScript.py
product/ERP5Type/patches/PythonScript.py
+16
-6
No files found.
product/ERP5Type/patches/PythonScript.py
View file @
91a3e907
...
...
@@ -102,7 +102,7 @@ def checkGuard(guard, ob):
# returns 1 if guard passes against ob, else 0.
# TODO : implement TALES evaluation by defining an appropriate
# context.
u
=
None
sm
=
None
if
guard
.
permissions
:
for
p
in
guard
.
permissions
:
if
_checkPermission
(
p
,
ob
):
...
...
@@ -110,10 +110,19 @@ def checkGuard(guard, ob):
else
:
return
0
if
guard
.
roles
:
if
u
is
None
:
u
=
getSecurityManager
().
getUser
()
if
sm
is
None
:
sm
=
getSecurityManager
()
u
=
sm
.
getUser
()
def
getRoles
():
stack
=
sm
.
_context
.
stack
if
stack
and
len
(
stack
)
>
1
:
eo
=
stack
[
-
2
]
# -1 is the current script.
proxy_roles
=
getattr
(
eo
,
'_proxy_roles'
,
None
)
if
proxy_roles
:
return
proxy_roles
return
u
.
getRolesInContext
(
ob
)
# Require at least one of the given roles.
u_roles
=
u
.
getRolesInContext
(
ob
)
u_roles
=
getRoles
(
)
for
role
in
guard
.
roles
:
if
role
in
u_roles
:
break
...
...
@@ -121,8 +130,9 @@ def checkGuard(guard, ob):
return
0
if
guard
.
groups
:
# Require at least one of the specified groups.
if
u
is
None
:
u
=
getSecurityManager
().
getUser
()
if
sm
is
None
:
sm
=
getSecurityManager
()
u
=
sm
.
getUser
()
b
=
aq_base
(
u
)
if
hasattr
(
b
,
'getGroupsInContext'
):
u_groups
=
u
.
getGroupsInContext
(
ob
)
...
...
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