Make Plone give proper 403 Forbidden errors

五迷三道 提交于 2020-01-04 02:43:24

问题


Default Plone behavior is to display login box when the user tries to access content for which he or she does not have permission.

How to change this behavior so that instead and Unauthorized page is displayed? How to customize this unauthorized page to have custom texts. etc?


回答1:


Customize this template: Products.CMFPlone/Products/CMFPlone/skins/plone_login/require_login.py, either via "old style" skin customization or "new style" jbot customization: http://pypi.python.org/pypi/z3c.jbot (see CMF Objects section)




回答2:


PAS responds to a 401 Unauthorized error by invoking any challenge plugins, so to avoid the login form deactivate these plugins in acl_users.

A 403 Forbidden should not result in a challenge. However in production mode (but not debug mode) these errors are hidden and they are transformed into 404 Not Found.




回答3:


FYI, there's now also a PAS plugin that only redirects to login form if the UA is a browser:

https://pypi.python.org/pypi/koodaamo.pas.browseronlyredirect/



来源:https://stackoverflow.com/questions/6351610/make-plone-give-proper-403-forbidden-errors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!