Skip to content
This repository has been archived by the owner on Apr 9, 2023. It is now read-only.

Commit

Permalink
Merge pull request #43 from plone/deserial-anon
Browse files Browse the repository at this point in the history
Handle error when deserializing content when not authenticated
  • Loading branch information
vangheem committed Dec 24, 2016
2 parents fdf719d + 2f0259b commit c425e63
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ cache:
directories:
- eggs
install:
- python bootstrap-buildout.py
- bin/buildout -t 3
- pip install zc.buildout
- buildout -t 3
- pip install flake8
- pip install coverage==4.0.3
- sleep 15
script:
- bin/py.test -s --cov=plone.server -v --cov-report term-missing src
- bin/py.test -s --cov=plone.server -v --cov-report term-missing src
- bin/code-analysis
after_success:
- coveralls
Expand Down
4 changes: 4 additions & 0 deletions src/plone.server/CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
1.0a9 (unreleased)
------------------

- Handle error when deserializing content when not authenticated and checking
permissions
[vangheem]

- add `pshell` command
[vangheem]

Expand Down
3 changes: 2 additions & 1 deletion src/plone.server/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ Getting started

We use buildout of course::

python3.5 bootstrap-buildout.py
virtualenv .
./bin/pip install zc.buildout
./bin/buildout

The buildout installs the app itself, code analysis tools, and a test runner.
Expand Down
9 changes: 7 additions & 2 deletions src/plone.server/plone/server/json/deserialize_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from zope.schema.interfaces import ValidationError
from zope.security import checkPermission
from zope.security.interfaces import IPermission
from zope.security.interfaces import NoInteraction


@implementer(IResourceDeserializeFromJson)
Expand Down Expand Up @@ -136,6 +137,10 @@ def check_permission(self, permission_name):
if permission is None:
self.permission_cache[permission_name] = True
else:
self.permission_cache[permission_name] = bool(
checkPermission(permission.title, self.context))
try:
self.permission_cache[permission_name] = bool(
checkPermission(permission.title, self.context))
except NoInteraction:
# not authenticated
return False
return self.permission_cache[permission_name]

0 comments on commit c425e63

Please sign in to comment.