[Zope3-checkins] CVS: Zope3/src/zope/app/security - metadirectives.py:1.1 configure.zcml:1.6 meta.zcml:1.3 metaconfigure.py:1.4

Stephan Richter srichter@cosmos.phy.tufts.edu
Sat, 2 Aug 2003 16:06:07 -0400


Update of /cvs-repository/Zope3/src/zope/app/security
In directory cvs.zope.org:/tmp/cvs-serv31235/security

Modified Files:
	configure.zcml meta.zcml metaconfigure.py 
Added Files:
	metadirectives.py 
Log Message:
Converted all security-related ZCML directives to the new way of doing 
things.

Note: The Permission id is now required to be an id, which means it must 
be a dotted name or a URI.

I wonder whether we should enforce the same for role and principal ids?!?
Comments?



=== Added File Zope3/src/zope/app/security/metadirectives.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""securityPolicy Directive Schema

$Id: metadirectives.py,v 1.1 2003/08/02 20:05:30 srichter Exp $
"""
from zope.configuration.fields import GlobalObject
from zope.interface import Interface

class ISecurityPolicyDirective(Interface):
    """Defines the security policy that will be used for Zope."""

    component = GlobalObject(
        title=u"Component",
        description=u"Pointer to the object that will handle the security.",
        required=True)


=== Zope3/src/zope/app/security/configure.zcml 1.5 => 1.6 ===
--- Zope3/src/zope/app/security/configure.zcml:1.5	Tue Jul 22 11:09:35 2003
+++ Zope3/src/zope/app/security/configure.zcml	Sat Aug  2 16:05:30 2003
@@ -1,64 +1,59 @@
-<zopeConfigure
-   xmlns='http://namespaces.zope.org/zope'
-   xmlns:browser='http://namespaces.zope.org/browser'
-   >
+<configure xmlns="http://namespaces.zope.org/zope">
 
   <include package=".registries" />
 
   <!-- Standard Permissions -->
 
-  <permission id="zope.View"
-                       title="View"
-                       />
-
-  <permission id="zope.Security"
-                       title="Change security settings"
-                       />
-
-  <permission id="zope.ManageContent" 
-                       title="Manage Content"
-                       />
-
-  <permission id="zope.ManageBindings" 
-                       title="Manage Service Bindings"
-                       />
-
-  <permission id="zope.ManageCode" 
-                       title="Manage Code"
-                       description="Manage executable code, including
-                                    Python, SQL, ZPT, etc."
-                        />
-
-  <permission id="zope.ManageServices" 
-                       title="Manage Services"
-                        />
-
-  <!-- XXX What is this for? -->
-  <permission id="zope.ManageApplication" 
-                       title="Manage Application"
-                       />
-
-  <!-- XXX What is this for? -->
-  <permission id="zope.I18n" 
-                       title="Use Internationalization (?XXX)"
-                       />
+  <permission 
+      id="zope.View"
+      title="View" />
+
+  <permission 
+      id="zope.Security"
+      title="Change security settings" />
+
+  <permission 
+      id="zope.ManageContent" 
+      title="Manage Content" />
+
+  <permission 
+      id="zope.ManageBindings" 
+      title="Manage Service Bindings" />
+
+  <permission 
+      id="zope.ManageCode" 
+      title="Manage Code"
+      description="Manage executable code, including Python, SQL, ZPT, etc." />
+
+  <permission 
+      id="zope.ManageServices" 
+      title="Manage Services" />
+
+  <permission 
+      id="zope.ManageApplication" 
+      title="Manage Application"
+      description="Manage the Zope Application, such as Restart/Shutdown or 
+                   packing the ZODB." />
 
   <include package=".grants" />
 
   <securityPolicy 
-      name="zope.app.security.zopepolicy.zopeSecurityPolicy" />
+      component="zope.app.security.zopepolicy.zopeSecurityPolicy" />
 
-  <adapter factory="zope.app.security.basicauthadapter.BasicAuthAdapter"
-           provides="zope.app.interfaces.security.ILoginPassword"
-           for="zope.publisher.interfaces.http.IHTTPCredentials" />
+  <adapter 
+      factory="zope.app.security.basicauthadapter.BasicAuthAdapter"
+      provides="zope.app.interfaces.security.ILoginPassword"
+      for="zope.publisher.interfaces.http.IHTTPCredentials" />
+
+  <adapter 
+      factory="zope.app.security.ftpauth.FTPAuth"
+      provides="zope.app.interfaces.security.ILoginPassword"
+      for="zope.publisher.interfaces.ftp.IFTPCredentials" />
+
+  <adapter 
+      factory="zope.app.security.principallogging.PrincipalLogging"
+      provides="zope.publisher.interfaces.logginginfo.ILoggingInfo"
+      for="zope.app.interfaces.security.IPrincipal" />
 
-  <adapter factory="zope.app.security.ftpauth.FTPAuth"
-           provides="zope.app.interfaces.security.ILoginPassword"
-           for="zope.publisher.interfaces.ftp.IFTPCredentials" />
-
-  <adapter factory="zope.app.security.principallogging.PrincipalLogging"
-           provides="zope.publisher.interfaces.logginginfo.ILoggingInfo"
-           for="zope.app.interfaces.security.IPrincipal" />
-
-</zopeConfigure>
+</configure>
 


=== Zope3/src/zope/app/security/meta.zcml 1.2 => 1.3 ===
--- Zope3/src/zope/app/security/meta.zcml:1.2	Wed Dec 25 09:13:15 2002
+++ Zope3/src/zope/app/security/meta.zcml	Sat Aug  2 16:05:30 2003
@@ -1,11 +1,14 @@
-<zopeConfigure xmlns='http://namespaces.zope.org/zope'>
+<configure 
+    xmlns="http://namespaces.zope.org/zope"
+    xmlns:meta="http://namespaces.zope.org/meta">
 
   <include package=".registries" file="meta.zcml" />
   <include package=".grants" file="meta.zcml" />
 
-  <directives namespace="http://namespaces.zope.org/zope">
-    <directive name="securityPolicy" attributes="name"
-       handler="zope.app.security.metaconfigure.securityPolicy" />
-  </directives>
+  <meta:directive 
+     namespace="http://namespaces.zope.org/zope"
+     name="securityPolicy" 
+     schema=".metadirectives.ISecurityPolicyDirective"
+     handler=".metaconfigure.securityPolicy" />
 
-</zopeConfigure>
+</configure>


=== Zope3/src/zope/app/security/metaconfigure.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/security/metaconfigure.py:1.3	Mon Dec 30 22:35:10 2002
+++ Zope3/src/zope/app/security/metaconfigure.py	Sat Aug  2 16:05:30 2003
@@ -11,22 +11,19 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-""" Register security related configuration directives.
+"""Register security related configuration directives.
 
 $Id$
 """
-
 from zope.configuration.action import Action
 from zope.security.manager import setSecurityPolicy
 
-def securityPolicy(_context, name):
-    policy = _context.resolve(name)
-    if callable(policy):
-        policy = policy()
-    return [
-        Action(
+def securityPolicy(_context, component):
+
+    if callable(component):
+        component = component()
+
+    _context.action(
             discriminator = 'defaultPolicy',
             callable = setSecurityPolicy,
-            args = (policy,),
-            )
-        ]
+            args = (component,) )