From d9c735dc0e040194fd5a60b23986cc3859b97033 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Mon, 28 Jul 2008 07:07:49 +0000 Subject: --- docs/narr/security.rst | 67 ++++++++++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 29 deletions(-) (limited to 'docs') diff --git a/docs/narr/security.rst b/docs/narr/security.rst index e12ae9883..fb1ad3ee7 100644 --- a/docs/narr/security.rst +++ b/docs/narr/security.rst @@ -18,12 +18,15 @@ By default, :mod:`repoze.bfg` enables no security policy. All views are accessible by completely anonymous users. However, if you add the following bit of code to your application's -``configure.zcml``, you will enable a security policy:: +``configure.zcml``, you will enable a security policy: - +.. code-block:: xml + :linenos: + + The above insrcutable stanza enables the ``RemoteUserACLSecurityPolicy`` to be in effect for every request to @@ -42,14 +45,17 @@ You declaratively protected a particular view with a :term:`permission` via the ``configure.zcml`` application registry. For example, the following declaration protects the view named ``add_entry.html`` when invoked against an ``IBlog`` context with the -``add`` permission:: +``add`` permission: + +.. code-block:: xml + :linenos: - + If a security policy is in place when this view is found during normal application operations, the user will need to possess the ``add`` @@ -71,23 +77,26 @@ the context. This attribute can be defined on the model *instance* model *class* (if you just need type-level security). For example, an ACL might be attached to model for a blog via its -class:: - - from repoze.bfg.security import Everyone - from repoze.bfg.security import Allow - from zope.location.interfaces import ILocation - from zope.location.location import Location - - class IBlog(Interface): - pass - - class Blog(dict, Location): - __acl__ = [ - (Allow, Everyone, 'view'), - (Allow, 'group:editors', 'add'), - (Allow, 'group:editors', 'edit'), - ] - implements(IBlog, ILocation) +class: + +.. code-block:: python + :linenos: + + from repoze.bfg.security import Everyone + from repoze.bfg.security import Allow + from zope.location.interfaces import ILocation + from zope.location.location import Location + + class IBlog(Interface): + pass + + class Blog(dict, Location): + __acl__ = [ + (Allow, Everyone, 'view'), + (Allow, 'group:editors', 'add'), + (Allow, 'group:editors', 'edit'), + ] + implements(IBlog, ILocation) The above ACL indicates that the ``Everyone`` principal (a special system-defined principal indicating, literally, everyone) is allowed -- cgit v1.2.3