Skip to content

Commit

Permalink
Forceauth backport #48 (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
mamico authored Jul 19, 2023
1 parent ce25469 commit e41df6c
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
pyvenv.cfg
.python-version
.coverage
coverage.json
*.egg-info
*.log
*.mo
*.py?
*.swp
# dirs
bin/
share/
buildout-cache/
develop-eggs/
eggs/
Expand Down
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Changelog
4.0.5 (unreleased)
------------------

- Add X-ForceAuth header and iw.rejectanonymous
backport from 5.0.0 #48
[mamico]

- Remove twitter feeds.
[folix-01]

Expand Down
8 changes: 8 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,14 @@ e poi lanciare il buildout con ``bin/buildout``.

Successivamente va installato dal pannello di controllo di Plone.

Forzare autenticazione
----------------------

Se le richieste arrivano con un header X-ForceAuth Plone forza l'autenticazione per quelle richieste,
il meccanismo è utile ad esempiop se si vuole fare accedere alla ZMI o alle interfacce Plone legacy
senza però esporle pubblicamente.


Test con Volto standalone
-------------------------

Expand Down
1 change: 1 addition & 0 deletions base.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ mode = 755
[versions]
# Don't use a released version of design.plone.policy
design.plone.policy =
iw.rejectanonymous = 1.2.7

[sources]
# collective.volto.dropdownmenu = git https://github.com/collective/collective.volto.dropdownmenu.git pushurl=git@github.com:collective/collective.volto.dropdownmenu.git
Expand Down
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"Framework :: Plone :: Addon",
"Framework :: Plone :: 5.2",
"Programming Language :: Python",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Operating System :: OS Independent",
"License :: OSI Approved :: GNU General Public License v2 (GPLv2)",
],
Expand Down Expand Up @@ -63,6 +63,7 @@
"rer.customersatisfaction>=1.1.0",
"redturtle.faq",
"redturtle.rssservice",
"iw.rejectanonymous",
],
extras_require={
"test": [
Expand All @@ -79,7 +80,5 @@
entry_points="""
[z3c.autoinclude.plugin]
target = plone
[console_scripts]
update_locale = design.plone.policy.locales.update:update_locale
""",
)
6 changes: 6 additions & 0 deletions src/design/plone/policy/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,10 @@
name="design.plone.policy-hiddenprofiles"
/>

<subscriber
for="Products.CMFCore.interfaces.ISiteRoot
zope.traversing.interfaces.IBeforeTraverseEvent"
handler=".rejectanonymous.insertRejectAnonymousHook"
/>

</configure>
8 changes: 8 additions & 0 deletions src/design/plone/policy/rejectanonymous.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
from iw.rejectanonymous import rejectAnonymous


def insertRejectAnonymousHook(portal, event):
"""force authentication for request with X-ForceAuth header"""
if event.request.getHeader("X-ForceAuth"):
event.request.post_traverse(rejectAnonymous, (portal, event.request))

0 comments on commit e41df6c

Please sign in to comment.