[Checkins] SVN: megrok.login/trunk/ Upgrade megrok.login to stay compatible with grok >= 1.1.

Uli Fouquet uli at gnufix.de
Sat Jul 3 09:24:00 EDT 2010


Log message for revision 114134:
  Upgrade megrok.login to stay compatible with grok >= 1.1.

Changed:
  U   megrok.login/trunk/CHANGES.txt
  U   megrok.login/trunk/buildout.cfg
  U   megrok.login/trunk/src/megrok/login/authplugins.py
  U   megrok.login/trunk/src/megrok/login/ftesting.zcml
  U   megrok.login/trunk/src/megrok/login/grokker.py
  U   megrok.login/trunk/src/megrok/login/tests/custompausetup.py

-=-
Modified: megrok.login/trunk/CHANGES.txt
===================================================================
--- megrok.login/trunk/CHANGES.txt	2010-07-03 12:52:38 UTC (rev 114133)
+++ megrok.login/trunk/CHANGES.txt	2010-07-03 13:24:00 UTC (rev 114134)
@@ -4,9 +4,38 @@
 0.3 (unreleased)
 ================
 
-No changes yet.
+* Support for Grok >= 1.1. 
 
+  We now use zope.pluggableauth and friends if available. Note, that
+  if you run into problems like non-found authentication adapters, you
+  might have to add `zope.app.authentication` manually in your
+  project. You can do so by adding::
 
+    <include package="zope.app.authentication" file="configure.zcml"
+    />
+
+  in your projects' `configure.zcml`.
+
+  If you use ``includeDependencies`` in your projects'
+  ``configure.zcml`` (which is most likely true for all projects based
+  on `grokproject`, it should be sufficient to depend on
+  `megrok.login` in your project's ``setup.py``, as the
+  ``configure.zcml`` of `megrok.login` now includes
+  ``zope.app.authentication`` for you.
+
+* Default PAU setup now does not include 'No Challenge if
+  Authenticated' authenticator plugin anymore. Using this plugin in a
+  pipe of authenicators, already authenticated users that entered a
+  still forbidden page got ``Unauthorized`` errors instead of being
+  redirected to the login page.
+
+  Note that this new behaviour applies only to applications newly
+  created. If you have some older applications setup with an older
+  version of `megrok.login`, you have to modify the authenticator
+  plugins of your already setup PAU manually, for instance using the
+  ZMI.
+
+
 0.2 (2009-12-09)
 ================
 

Modified: megrok.login/trunk/buildout.cfg
===================================================================
--- megrok.login/trunk/buildout.cfg	2010-07-03 12:52:38 UTC (rev 114133)
+++ megrok.login/trunk/buildout.cfg	2010-07-03 13:24:00 UTC (rev 114134)
@@ -1,10 +1,14 @@
 [buildout]
-extends = http://grok.zope.org/releaseinfo/grok-1.1a1.cfg
-develop = .
+extends = http://grok.zope.org/releaseinfo/grok-1.1.1.cfg
+develop = . 
 parts = test
-find-links = http://download.zope.org/distribution/
+#find-links = http://download.zope.org/distribution/
+extensions = buildout.dumppickedversions
 versions = versions
 
+[versions]
+martian = 0.11
+
 [test]
 recipe = zc.recipe.testrunner
 eggs = megrok.login [test,]

Modified: megrok.login/trunk/src/megrok/login/authplugins.py
===================================================================
--- megrok.login/trunk/src/megrok/login/authplugins.py	2010-07-03 12:52:38 UTC (rev 114133)
+++ megrok.login/trunk/src/megrok/login/authplugins.py	2010-07-03 13:24:00 UTC (rev 114134)
@@ -12,11 +12,21 @@
 #
 ##############################################################################
 
-from zope.app.authentication.interfaces import IAuthenticatorPlugin
+try:
+    from zope.pluggableauth.interfaces import IAuthenticatorPlugin
+except ImportError:
+    # BBB
+    from zope.app.authentication.interfaces import IAuthenticatorPlugin
+
 from zope.app.authentication.interfaces import IQuerySchemaSearch
-from zope.app.authentication.principalfolder import (PrincipalInfo,
-                                                     PrincipalFolder,
-                                                     InternalPrincipal)
+try:
+    from zope.pluggableauth.factories import PrincipalInfo
+except ImportError:
+    # BBB
+    from zope.app.authentication.principalfolder import PrincipalInfo
+from zope.app.authentication.principalfolder import (
+    PrincipalFolder, InternalPrincipal
+    )
 from zope.app.authentication.principalfolder import ISearchSchema
 from zope.app.container.interfaces import DuplicateIDError
 from zope.app.security.principalregistry import principalRegistry
@@ -116,6 +126,8 @@
                         perm, self.prefix + id)
             except DuplicateIDError:
                 pass
+            except KeyError:
+                pass
         internal = self[id]
         if not internal.checkPassword(credentials["password"]):
             return None

Modified: megrok.login/trunk/src/megrok/login/ftesting.zcml
===================================================================
--- megrok.login/trunk/src/megrok/login/ftesting.zcml	2010-07-03 12:52:38 UTC (rev 114133)
+++ megrok.login/trunk/src/megrok/login/ftesting.zcml	2010-07-03 13:24:00 UTC (rev 114134)
@@ -5,6 +5,7 @@
 
   <include package="grok" />
   <include package="megrok.login" file="meta.zcml" />
+  <include package="megrok.login" file="configure.zcml" />
   <grok:grok package="megrok.login.tests" />
 
   <securityPolicy

Modified: megrok.login/trunk/src/megrok/login/grokker.py
===================================================================
--- megrok.login/trunk/src/megrok/login/grokker.py	2010-07-03 12:52:38 UTC (rev 114133)
+++ megrok.login/trunk/src/megrok/login/grokker.py	2010-07-03 13:24:00 UTC (rev 114134)
@@ -2,11 +2,22 @@
 import grok
 import megrok.login
 from zope import component
-
-from zope.app.authentication import PluggableAuthentication
+try:
+    from zope.pluggableauth import PluggableAuthentication
+except ImportError:
+    # BBB
+    from zope.app.authentication import PluggableAuthentication
 from zope.app.authentication.principalfolder import PrincipalFolder
-from zope.app.authentication.session import SessionCredentialsPlugin
-from zope.app.security.interfaces import IAuthentication
+try:
+    from zope.pluggableauth.plugins.session import SessionCredentialsPlugin
+except ImportError:
+    # BBB
+    from zope.app.authentication.session import SessionCredentialsPlugin
+try:
+    from zope.authentication.interfaces import IAuthentication
+except ImportError:
+    # BBB
+    from zope.app.security.interfaces import IAuthentication
 from megrok.login.authplugins import (PrincipalRegistryAuthenticator,
                                       AutoRegisteringPrincipalFolder)
 
@@ -43,9 +54,7 @@
     setupUtility(site, PluggableAuthentication(), IAuthentication,
                  setup=setupPAU,
                  name_in_container='megrok_login_pau')
-        
 
-
 def setupPAU(pau):
     """Callback to setup the Pluggable Authentication Utility """
     site = pau.__parent__.__parent__
@@ -71,6 +80,9 @@
         pau.authenticatorPlugins = ('principals', 'readonly_principals')
 
     pau['session'] = session = SessionCredentialsPlugin()
-    pau.credentialsPlugins = ('No Challenge if Authenticated', 'session',)
+    # If we use this, already authenticated users will get no login
+    # screen when they enter a forbidden page.
+    #pau.credentialsPlugins = ('No Challenge if Authenticated', 'session',)
+    pau.credentialsPlugins = ('session',)
     session.loginpagename = viewname
     return None

Modified: megrok.login/trunk/src/megrok/login/tests/custompausetup.py
===================================================================
--- megrok.login/trunk/src/megrok/login/tests/custompausetup.py	2010-07-03 12:52:38 UTC (rev 114133)
+++ megrok.login/trunk/src/megrok/login/tests/custompausetup.py	2010-07-03 13:24:00 UTC (rev 114134)
@@ -78,9 +78,9 @@
 import grok
 import megrok.login
 
-from zope.app.authentication import PluggableAuthentication
+from zope.pluggableauth import PluggableAuthentication
 from zope.app.authentication.principalfolder import PrincipalFolder
-from zope.app.authentication.session import SessionCredentialsPlugin
+from zope.pluggableauth.plugins.session import SessionCredentialsPlugin
 from zope.app.security.interfaces import IAuthentication
 from megrok.login.authplugins import (PrincipalRegistryAuthenticator,
                                       AutoRegisteringPrincipalFolder)



More information about the checkins mailing list