[Checkins] SVN: zope.password/trunk/ Make security protection directives in `configure.zcml` execute only if ``zope.security`` is installed.
Dan Korostelev
nadako at gmail.com
Tue Mar 10 04:47:51 EDT 2009
Log message for revision 97790:
Make security protection directives in `configure.zcml` execute only if ``zope.security`` is installed.
Move "Password Manager Names" vocabulary here from ``zope.app.authentication``.
Fix changelog formatting.
Changed:
U zope.password/trunk/CHANGES.txt
U zope.password/trunk/README.txt
U zope.password/trunk/setup.py
U zope.password/trunk/src/zope/password/configure.zcml
U zope.password/trunk/src/zope/password/testing.py
A zope.password/trunk/src/zope/password/vocabulary.py
-=-
Modified: zope.password/trunk/CHANGES.txt
===================================================================
--- zope.password/trunk/CHANGES.txt 2009-03-10 07:50:08 UTC (rev 97789)
+++ zope.password/trunk/CHANGES.txt 2009-03-10 08:47:51 UTC (rev 97790)
@@ -3,9 +3,18 @@
=======
3.5.1 (unreleased)
+------------------
-- ...
+- Make security protection directives in `configure.zcml` execute only
+ if ``zope.security`` is installed. This will allow reuse of the
+ `configure.zcml` file in environments without ``zope.security``,
+ for example with ``repoze.zcml``.
+- Add "Password Manager Names" vocabulary for use with ``zope.schema``
+ and ``zope.component``. This change doesn't add depdendency on them,
+ because it's an optional feature and one who want to use that vocabulary
+ is probably already have them installed.
+
3.5.0 (2009-03-06)
------------------
Modified: zope.password/trunk/README.txt
===================================================================
--- zope.password/trunk/README.txt 2009-03-10 07:50:08 UTC (rev 97789)
+++ zope.password/trunk/README.txt 2009-03-10 08:47:51 UTC (rev 97790)
@@ -25,6 +25,7 @@
It is strongly recommended to use SSHAPasswordManager, as it's the most secure.
+
Usage
-----
@@ -38,3 +39,17 @@
"""Return whether the given encoded data coincide with the given password"""
The implementations mentioned above are in the ``zope.password.password`` module.
+
+
+Password Manager Names Vocabulary
+---------------------------------
+
+The ``zope.password.vocabulary`` module provides a vocabulary of registered
+password manager utility names. It is typically registered as an
+`IVocabularyFactory` utility named "Password Manager Names".
+
+It's intended to be used with ``zope.component`` and ``zope.schema``, so
+you need to have them installed and the utility registrations needs to
+be done properly. The `configure.zcml` file, contained in ``zope.password``
+does the registrations, as well as in `setUpPasswordManagers` function in
+``zope.password.testing`` module.
Modified: zope.password/trunk/setup.py
===================================================================
--- zope.password/trunk/setup.py 2009-03-10 07:50:08 UTC (rev 97789)
+++ zope.password/trunk/setup.py 2009-03-10 08:47:51 UTC (rev 97790)
@@ -43,7 +43,9 @@
keywords='zope3 zope authentication password',
packages=find_packages('src'),
package_dir = {'': 'src'},
- extras_require=dict(test=['zope.testing', 'zope.component']),
+ extras_require=dict(test=['zope.testing',
+ 'zope.component',
+ 'zope.schema']),
namespace_packages=['zope'],
install_requires=['setuptools',
'zope.interface',
Modified: zope.password/trunk/src/zope/password/configure.zcml
===================================================================
--- zope.password/trunk/src/zope/password/configure.zcml 2009-03-10 07:50:08 UTC (rev 97789)
+++ zope.password/trunk/src/zope/password/configure.zcml 2009-03-10 08:47:51 UTC (rev 97790)
@@ -1,43 +1,56 @@
<configure xmlns="http://namespaces.zope.org/zope">
- <class class=".password.PlainTextPasswordManager">
- <allow interface=".interfaces.IPasswordManager" />
- </class>
-
<utility
name="Plain Text"
provides=".interfaces.IPasswordManager"
factory=".password.PlainTextPasswordManager"
/>
- <class class=".password.MD5PasswordManager">
- <allow interface=".interfaces.IPasswordManager" />
- </class>
-
<utility
name="MD5"
provides=".interfaces.IPasswordManager"
factory=".password.MD5PasswordManager"
/>
- <class class=".password.SHA1PasswordManager">
- <allow interface=".interfaces.IPasswordManager" />
- </class>
-
<utility
name="SHA1"
provides=".interfaces.IPasswordManager"
factory=".password.SHA1PasswordManager"
/>
- <class class=".password.SSHAPasswordManager">
- <allow interface=".interfaces.IPasswordManager" />
- </class>
-
<utility
name="SSHA"
provides=".interfaces.IPasswordManager"
factory=".password.SSHAPasswordManager"
/>
+ <utility
+ component=".vocabulary.PasswordManagerNamesVocabulary"
+ provides="zope.schema.interfaces.IVocabularyFactory"
+ name="Password Manager Names"
+ />
+
+ <configure
+ xmlns:zcml="http://namespaces.zope.org/zcml"
+ zcml:condition="installed zope.security"
+ >
+
+ <class class=".password.PlainTextPasswordManager">
+ <allow interface=".interfaces.IPasswordManager" />
+ </class>
+
+ <class class=".password.MD5PasswordManager">
+ <allow interface=".interfaces.IPasswordManager" />
+ </class>
+
+ <class class=".password.SHA1PasswordManager">
+ <allow interface=".interfaces.IPasswordManager" />
+ </class>
+
+ <class class=".password.SSHAPasswordManager">
+ <allow interface=".interfaces.IPasswordManager" />
+ </class>
+
+ </configure>
+
</configure>
Modified: zope.password/trunk/src/zope/password/testing.py
===================================================================
--- zope.password/trunk/src/zope/password/testing.py 2009-03-10 07:50:08 UTC (rev 97789)
+++ zope.password/trunk/src/zope/password/testing.py 2009-03-10 08:47:51 UTC (rev 97790)
@@ -16,12 +16,16 @@
$Id$
"""
__docformat__ = "reStructuredText"
+
from zope.component import provideUtility
+from zope.schema.interfaces import IVocabularyFactory
+
from zope.password.interfaces import IPasswordManager
from zope.password.password import PlainTextPasswordManager
from zope.password.password import MD5PasswordManager
from zope.password.password import SHA1PasswordManager
from zope.password.password import SSHAPasswordManager
+from zope.password.vocabulary import PasswordManagerNamesVocabulary
def setUpPasswordManagers():
@@ -29,6 +33,7 @@
>>> from zope.component import getUtility
>>> setUpPasswordManagers()
+
>>> getUtility(IPasswordManager, 'Plain Text')
<zope.password.password.PlainTextPasswordManager object at 0x...>
>>> getUtility(IPasswordManager, 'SSHA')
@@ -37,9 +42,25 @@
<zope.password.password.MD5PasswordManager object at 0x...>
>>> getUtility(IPasswordManager, 'SHA1')
<zope.password.password.SHA1PasswordManager object at 0x...>
+
+ >>> voc = getUtility(IVocabularyFactory, 'Password Manager Names')
+ >>> voc = voc(None)
+ >>> voc
+ <zope.schema.vocabulary.SimpleVocabulary object at 0x...>
+ >>> 'SSHA' in voc
+ True
+ >>> 'Plain Text' in voc
+ True
+ >>> 'SHA1' in voc
+ True
+ >>> 'MD5' in voc
+ True
"""
provideUtility(PlainTextPasswordManager(), IPasswordManager, 'Plain Text')
provideUtility(SSHAPasswordManager(), IPasswordManager, 'SSHA')
provideUtility(MD5PasswordManager(), IPasswordManager, 'MD5')
provideUtility(SHA1PasswordManager(), IPasswordManager, 'SHA1')
+
+ provideUtility(PasswordManagerNamesVocabulary,
+ IVocabularyFactory, 'Password Manager Names')
Added: zope.password/trunk/src/zope/password/vocabulary.py
===================================================================
--- zope.password/trunk/src/zope/password/vocabulary.py (rev 0)
+++ zope.password/trunk/src/zope/password/vocabulary.py 2009-03-10 08:47:51 UTC (rev 97790)
@@ -0,0 +1,34 @@
+##############################################################################
+#
+# Copyright (c) 2009 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (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.
+#
+##############################################################################
+"""Vocabulary of password manager utility names
+
+This requires zope.schema, but you probably already have it, if you want
+to use this vocabulary.
+
+$Id$
+"""
+from zope.component import getUtilitiesFor
+from zope.interface import directlyProvides
+from zope.schema.interfaces import IVocabularyFactory
+from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
+
+from zope.password.interfaces import IPasswordManager
+
+def PasswordManagerNamesVocabulary(context=None):
+ terms = []
+ for name, util in getUtilitiesFor(IPasswordManager, context):
+ terms.append(SimpleTerm(name))
+ return SimpleVocabulary(terms)
+
+directlyProvides(PasswordManagerNamesVocabulary, IVocabularyFactory)
Property changes on: zope.password/trunk/src/zope/password/vocabulary.py
___________________________________________________________________
Added: svn:keywords
+ Id
More information about the Checkins
mailing list