[Zope3-checkins] SVN: Zope3/trunk/ Removed IAuthentication2 in
favor of adapting IAuthentication to ILogout.
Garrett Smith
garrett at mojave-corp.com
Thu Mar 31 20:23:26 EST 2005
Log message for revision 29768:
Removed IAuthentication2 in favor of adapting IAuthentication to ILogout.
Changed:
U Zope3/trunk/doc/CHANGES.txt
U Zope3/trunk/src/bugtracker/tests/placelesssetup.py
U Zope3/trunk/src/bugtracker/tests/test_vocabularies.py
U Zope3/trunk/src/zope/app/authentication/README.txt
U Zope3/trunk/src/zope/app/authentication/authentication.py
U Zope3/trunk/src/zope/app/authentication/browser/register.py
U Zope3/trunk/src/zope/app/authentication/groupfolder.txt
U Zope3/trunk/src/zope/app/authentication/interfaces.py
U Zope3/trunk/src/zope/app/exception/browser/tests/test_unauthorized.py
U Zope3/trunk/src/zope/app/publication/zopepublication.py
U Zope3/trunk/src/zope/app/security/__init__.py
U Zope3/trunk/src/zope/app/security/browser/auth.py
U Zope3/trunk/src/zope/app/security/browser/configure.zcml
U Zope3/trunk/src/zope/app/security/browser/principalterms.txt
U Zope3/trunk/src/zope/app/security/configure.zcml
U Zope3/trunk/src/zope/app/security/globalprincipals.txt
U Zope3/trunk/src/zope/app/security/interfaces.py
A Zope3/trunk/src/zope/app/security/logout.txt
U Zope3/trunk/src/zope/app/security/principal.py
U Zope3/trunk/src/zope/app/security/principalregistry.py
A Zope3/trunk/src/zope/app/security/tests/test_logout.py
U Zope3/trunk/src/zope/app/security/tests/test_securitydirectives.py
U Zope3/trunk/src/zope/app/security/vocabulary.py
U Zope3/trunk/src/zope/app/securitypolicy/browser/granting.txt
U Zope3/trunk/src/zope/app/securitypolicy/tests/test_principalpermissionmanager.py
U Zope3/trunk/src/zope/app/securitypolicy/tests/test_principalrolemanager.py
U Zope3/trunk/src/zope/app/securitypolicy/tests/test_securitydirectives.py
U Zope3/trunk/src/zope/app/securitypolicy/zopepolicy.txt
U Zope3/trunk/src/zope/app/zapi/README.txt
U Zope3/trunk/src/zope/app/zapi/__init__.py
-=-
Modified: Zope3/trunk/doc/CHANGES.txt
===================================================================
--- Zope3/trunk/doc/CHANGES.txt 2005-03-31 22:48:05 UTC (rev 29767)
+++ Zope3/trunk/doc/CHANGES.txt 2005-04-01 01:23:25 UTC (rev 29768)
@@ -303,12 +303,6 @@
zope.app.container.constraints.containers) that greatly simplify
expressing containment constraints.
- - Added IAuthentication2, which formally supports logout. Support for
- IAuthentication is deprecated and will be dropped in Zope 3.3. If
- you provide an IAuthentication utility, add a 'logout' method (see
- zope.app.security.interfaces.IAuthentication2) and register it as
- providing IAuthentication2.
-
- Added a view 'failsafelogin.html' that always uses HTTP basic auth
credentials to identify a principal. This can be used to login as
admin in the event a site authentication configuration is broken and
@@ -524,6 +518,9 @@
securitypolicy.zcml. If you want to change the default security policy
for a Zope instance, you can modify this file in your etc directory.
+ - Added formal support for logout. See zope/app/security/logout.txt for
+ more information.
+
- Made the 'Logout' link optionally configured by registering a marker
component in ZCML. To display the link, add this:
Modified: Zope3/trunk/src/bugtracker/tests/placelesssetup.py
===================================================================
--- Zope3/trunk/src/bugtracker/tests/placelesssetup.py 2005-03-31 22:48:05 UTC (rev 29767)
+++ Zope3/trunk/src/bugtracker/tests/placelesssetup.py 2005-04-01 01:23:25 UTC (rev 29768)
@@ -40,7 +40,7 @@
from zope.app.renderer.plaintext import IPlainTextSource
from zope.app.renderer.plaintext import PlainTextToHTMLRenderer
from zope.app.renderer.plaintext import PlainTextSourceFactory
-from zope.app.security.interfaces import IAuthentication2
+from zope.app.security.interfaces import IAuthentication
from zope.app.size.interfaces import ISized
from zope.app.traversing.interfaces import IContainmentRoot, ITraverser
from zope.app.traversing.interfaces import ITraversable, IPhysicallyLocatable
@@ -104,7 +104,7 @@
registry.register('Releases', ReleaseVocabulary)
registry.register('Users', UserVocabulary)
- ztapi.provideUtility(IAuthentication2, principalRegistry)
+ ztapi.provideUtility(IAuthentication, principalRegistry)
principalRegistry.definePrincipal(u'zope.srichter',
u'Stephan Richter', u'',
Modified: Zope3/trunk/src/bugtracker/tests/test_vocabularies.py
===================================================================
--- Zope3/trunk/src/bugtracker/tests/test_vocabularies.py 2005-03-31 22:48:05 UTC (rev 29767)
+++ Zope3/trunk/src/bugtracker/tests/test_vocabularies.py 2005-04-01 01:23:25 UTC (rev 29768)
@@ -27,7 +27,7 @@
from zope.app.annotation.attribute import AttributeAnnotations
from zope.app.annotation.interfaces import IAnnotations, IAttributeAnnotatable
from zope.app.container.contained import contained, Contained
-from zope.app.security.interfaces import IAuthentication2
+from zope.app.security.interfaces import IAuthentication
from zope.app.security.principalregistry import principalRegistry, Principal
from bugtracker.interfaces import IManagableVocabulary
@@ -194,7 +194,7 @@
def setUp(self):
PlacelessSetup.setUp(self)
- ztapi.provideUtility(IAuthentication2, principalRegistry)
+ ztapi.provideUtility(IAuthentication, principalRegistry)
principalRegistry.definePrincipal(
'0', 'title0', 'desc0', 'zero', 'pass0')
principalRegistry.definePrincipal(
Modified: Zope3/trunk/src/zope/app/authentication/README.txt
===================================================================
--- Zope3/trunk/src/zope/app/authentication/README.txt 2005-03-31 22:48:05 UTC (rev 29767)
+++ Zope3/trunk/src/zope/app/authentication/README.txt 2005-04-01 01:23:25 UTC (rev 29768)
@@ -323,7 +323,7 @@
Principal Searching
===================
-As a component that provides IAuthentication2, a PAU lets you lookup a
+As a component that provides IAuthentication, a PAU lets you lookup a
principal with a principal ID. The PAU looks up a principal by delegating to
its authenticators. In out example, none of the authenticators implement this
search capability, so when we look for a principal:
@@ -481,13 +481,13 @@
Issuing a Challenge
===================
-Part of PAU's IAuthentication2 contract is to challenge the user for
+Part of PAU's IAuthentication contract is to challenge the user for
credentials when its 'unauthorized' method is called. The need for this
functionality is driven by the following use case:
- A user attempts to perform an operation he is not authorized to perform.
- - A handler responds to the unauthorized error by calling IAuthentication2
+ - A handler responds to the unauthorized error by calling IAuthentication
'unauthorized'.
- The authentication component (in our case, a PAU) issues a challenge to
Modified: Zope3/trunk/src/zope/app/authentication/authentication.py
===================================================================
--- Zope3/trunk/src/zope/app/authentication/authentication.py 2005-03-31 22:48:05 UTC (rev 29767)
+++ Zope3/trunk/src/zope/app/authentication/authentication.py 2005-04-01 01:23:25 UTC (rev 29768)
@@ -21,7 +21,7 @@
from zope import component
from zope.schema.interfaces import ISourceQueriables
-from zope.app.security.interfaces import IAuthentication2
+from zope.app.security.interfaces import IAuthentication
from zope.app.component import queryNextUtility
from zope.app.component.site import SiteManagementFolder
@@ -31,7 +31,7 @@
class PluggableAuthentication(SiteManagementFolder):
zope.interface.implements(
- IAuthentication2,
+ IAuthentication,
interfaces.IPluggableAuthentication,
ISourceQueriables)
@@ -67,7 +67,7 @@
def getPrincipal(self, id):
if not id.startswith(self.prefix):
- next = queryNextUtility(self, IAuthentication2)
+ next = queryNextUtility(self, IAuthentication)
return (next is not None) and next.getPrincipal(id) or None
id = id[len(self.prefix):]
for name in self.authenticatorPlugins:
@@ -81,7 +81,7 @@
principal = interfaces.IFoundPrincipalFactory(info)()
principal.id = self.prefix + info.id
return principal
- next = queryNextUtility(self, IAuthentication2)
+ next = queryNextUtility(self, IAuthentication)
return (next is not None) and next.getPrincipal(self.prefix+id) or None
def getQueriables(self):
@@ -115,7 +115,7 @@
challengeProtocol = protocol
if challengeProtocol is None:
- next = queryNextUtility(self, IAuthentication2)
+ next = queryNextUtility(self, IAuthentication)
if next is not None:
next.unauthorized(id, request)
@@ -136,7 +136,7 @@
challengeProtocol = protocol
if challengeProtocol is None:
- next = queryNextUtility(self, IAuthentication2)
+ next = queryNextUtility(self, IAuthentication)
if next is not None:
next.logout(request)
Modified: Zope3/trunk/src/zope/app/authentication/browser/register.py
===================================================================
--- Zope3/trunk/src/zope/app/authentication/browser/register.py 2005-03-31 22:48:05 UTC (rev 29767)
+++ Zope3/trunk/src/zope/app/authentication/browser/register.py 2005-04-01 01:23:25 UTC (rev 29768)
@@ -1,10 +1,10 @@
from zope.app.component.site import UtilityRegistration
-from zope.app.security.interfaces import IAuthentication2
+from zope.app.security.interfaces import IAuthentication
from zope.app.authentication.interfaces import ICredentialsPlugin
from zope.app.authentication.interfaces import IAuthenticatorPlugin
def pluggableAuthenticationRegistration(view, component):
- return UtilityRegistration(u'', IAuthentication2, component)
+ return UtilityRegistration(u'', IAuthentication, component)
def credentialsPluginRegistration(view, name, component):
return UtilityRegistration(name, ICredentialsPlugin, component)
Modified: Zope3/trunk/src/zope/app/authentication/groupfolder.txt
===================================================================
--- Zope3/trunk/src/zope/app/authentication/groupfolder.txt 2005-03-31 22:48:05 UTC (rev 29767)
+++ Zope3/trunk/src/zope/app/authentication/groupfolder.txt 2005-04-01 01:23:25 UTC (rev 29768)
@@ -30,7 +30,7 @@
we'll create a sample authentication service:
>>> from zope import interface
- >>> from zope.app.security.interfaces import IAuthentication2
+ >>> from zope.app.security.interfaces import IAuthentication
>>> from zope.security.interfaces import IGroupAwarePrincipal
>>> from zope.app.authentication.groupfolder import setGroupsForPrincipal
@@ -48,7 +48,7 @@
>>> class Principals:
...
- ... interface.implements(IAuthentication2)
+ ... interface.implements(IAuthentication)
...
... def __init__(self, groups):
... self.principals = {
@@ -67,7 +67,7 @@
... setGroupsForPrincipal(PrincipalCreatedEvent(principal))
... return principal
-This class doesn't really implement the full `IAuthentication2` interface, but
+This class doesn't really implement the full `IAuthentication` interface, but
it implements the `getPrincipal` method used by groups. It works very much
like the pluggable authentication utility. It creates principals on demand. It
calls `setGroupsForPrincipal`, which is normally called as an event subscriber,
@@ -81,7 +81,7 @@
We will create and register a new principals utility:
>>> principals = Principals(groups)
- >>> ztapi.provideUtility(IAuthentication2, principals)
+ >>> ztapi.provideUtility(IAuthentication, principals)
Now we can set the principals on the group:
Modified: Zope3/trunk/src/zope/app/authentication/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/authentication/interfaces.py 2005-03-31 22:48:05 UTC (rev 29767)
+++ Zope3/trunk/src/zope/app/authentication/interfaces.py 2005-04-01 01:23:25 UTC (rev 29768)
@@ -19,6 +19,7 @@
import zope.interface
import zope.schema
+from zope.app.security.interfaces import ILogout
from zope.app.container.constraints import contains, containers
from zope.app.container.interfaces import IContainer
@@ -27,7 +28,7 @@
"""A plugin for a pluggable authentication component."""
-class IPluggableAuthentication(IContainer):
+class IPluggableAuthentication(ILogout, IContainer):
"""Provides authentication services with the help of various plugins."""
contains(IPlugin)
@@ -44,6 +45,10 @@
default=[],
)
+ def logout(request):
+ """Performs a logout by delegating to its authentictor plugins."""
+
+
class ICredentialsPlugin(IPlugin):
"""Handles credentials extraction and challenges per request."""
Modified: Zope3/trunk/src/zope/app/exception/browser/tests/test_unauthorized.py
===================================================================
--- Zope3/trunk/src/zope/app/exception/browser/tests/test_unauthorized.py 2005-03-31 22:48:05 UTC (rev 29767)
+++ Zope3/trunk/src/zope/app/exception/browser/tests/test_unauthorized.py 2005-04-01 01:23:25 UTC (rev 29768)
@@ -19,7 +19,7 @@
from zope.interface import implements
from zope.publisher.browser import TestRequest
from zope.app.testing import ztapi
-from zope.app.security.interfaces import IAuthentication2, IPrincipal
+from zope.app.security.interfaces import IAuthentication, IPrincipal
from zope.app.exception.browser.unauthorized import Unauthorized
from zope.app.testing.placelesssetup import PlacelessSetup
@@ -41,7 +41,7 @@
return self.id
class DummyAuthUtility(object):
- implements(IAuthentication2) # this is a lie
+ implements(IAuthentication) # this is a lie
def unauthorized(self, principal_id, request):
self.principal_id = principal_id
@@ -56,7 +56,7 @@
def setUp(self):
super(Test, self).setUp()
self.auth = DummyAuthUtility()
- ztapi.provideUtility(IAuthentication2, self.auth)
+ ztapi.provideUtility(IAuthentication, self.auth)
def tearDown(self):
super(Test, self).tearDown()
Modified: Zope3/trunk/src/zope/app/publication/zopepublication.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/zopepublication.py 2005-03-31 22:48:05 UTC (rev 29767)
+++ Zope3/trunk/src/zope/app/publication/zopepublication.py 2005-04-01 01:23:25 UTC (rev 29768)
@@ -48,7 +48,7 @@
from zope.app.publication.publicationtraverse import PublicationTraverse
from zope.app.security.principalregistry import principalRegistry as prin_reg
from zope.app.security.interfaces import IUnauthenticatedPrincipal
-from zope.app.security.interfaces import IAuthentication2
+from zope.app.security.interfaces import IAuthentication
from zope.app.component.interfaces import ISite
from zope.app.traversing.interfaces import IPhysicallyLocatable
@@ -95,7 +95,7 @@
sm = removeSecurityProxy(ob).getSiteManager()
- auth = sm.queryUtility(IAuthentication2)
+ auth = sm.queryUtility(IAuthentication)
if auth is None:
# No auth utility here
return
@@ -273,11 +273,11 @@
view = None
try:
# We need to get a location, because some template content of
- # the exception view might require one.
- #
+ # the exception view might require one.
+ #
# The object might not have a parent, because it might be a
# method. If we don't have a `__parent__` attribute but have
- # an im_self or a __self__, use it.
+ # an im_self or a __self__, use it.
loc = object
if not hasattr(object, '__parent__'):
loc = removeSecurityProxy(object)
@@ -324,7 +324,7 @@
logging.getLogger('SiteError').exception(
str(request.URL),
)
-
+
except:
# Problem rendering the view for this exception.
# Log an error.
Modified: Zope3/trunk/src/zope/app/security/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/security/__init__.py 2005-03-31 22:48:05 UTC (rev 29767)
+++ Zope3/trunk/src/zope/app/security/__init__.py 2005-04-01 01:23:25 UTC (rev 29768)
@@ -15,21 +15,36 @@
$Id$
"""
+from zope.component import adapts
+from zope.interface import implements, Interface
+from zope.app.security import interfaces
+
# Register some standard types
import _protections
_protections.protect()
del _protections
-class LogoutSupported:
+class LogoutSupported(object):
"""A class that can be registered as an adapter to flag logout support."""
- from zope.component import adapts
- from zope.interface import implements, Interface
- from zope.app.security.interfaces import ILogoutSupported
+ adapts(Interface)
- adapts(Interface)
- implements(ILogoutSupported)
+ implements(interfaces.ILogoutSupported)
def __init__(self, dummy):
pass
+
+
+class NoLogout(object):
+ """An adapter for IAuthentication utilities that don't implement ILogout."""
+
+ adapts(interfaces.IAuthentication)
+
+ implements(interfaces.ILogout)
+
+ def __init__(self, auth):
+ pass
+
+ def logout(self, request):
+ pass
Modified: Zope3/trunk/src/zope/app/security/browser/auth.py
===================================================================
--- Zope3/trunk/src/zope/app/security/browser/auth.py 2005-03-31 22:48:05 UTC (rev 29767)
+++ Zope3/trunk/src/zope/app/security/browser/auth.py 2005-04-01 01:23:25 UTC (rev 29768)
@@ -21,9 +21,9 @@
from zope import component
from zope.app.zapi import getName, getPath
from zope.app.publisher.interfaces.http import ILogin, ILogout
-from zope.app.security.interfaces import IAuthentication2
+from zope.app.security.interfaces import IAuthentication
from zope.app.security.interfaces import IUnauthenticatedPrincipal
-from zope.app.security.interfaces import ILogoutSupported
+from zope.app.security.interfaces import ILogout, ILogoutSupported
from zope.app.pagetemplate import ViewPageTemplateFile
from zope.proxy import removeAllProxies
from zope.app.i18n import ZopeMessageIDFactory as _
@@ -33,7 +33,7 @@
class AuthUtilitySearchView(object):
- __used_for__ = IAuthentication2
+ __used_for__ = IAuthentication
def __init__(self, context, request):
self.context = context
@@ -87,7 +87,7 @@
def login(self, nextURL=None):
# we don't want to keep challenging if we're authenticated
if IUnauthenticatedPrincipal.providedBy(self.request.principal):
- component.getUtility(IAuthentication2).unauthorized(
+ component.getUtility(IAuthentication).unauthorized(
self.request.principal.id, self.request)
return self.failed()
else:
@@ -136,7 +136,8 @@
def logout(self, nextURL=None):
if not IUnauthenticatedPrincipal.providedBy(self.request.principal):
- component.getUtility(IAuthentication2).logout(self.request)
+ auth = component.getUtility(IAuthentication)
+ ILogout(auth).logout(self.request)
if nextURL:
return self.redirect()
if nextURL is None:
Modified: Zope3/trunk/src/zope/app/security/browser/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/security/browser/configure.zcml 2005-03-31 22:48:05 UTC (rev 29767)
+++ Zope3/trunk/src/zope/app/security/browser/configure.zcml 2005-04-01 01:23:25 UTC (rev 29768)
@@ -4,7 +4,7 @@
<adapter
- for="zope.app.security.interfaces.IAuthentication2
+ for="zope.app.security.interfaces.IAuthentication
zope.publisher.interfaces.browser.IBrowserRequest"
provides="zope.app.form.browser.interfaces.ISourceQueryView"
factory="zope.app.security.browser.auth.AuthUtilitySearchView"
Modified: Zope3/trunk/src/zope/app/security/browser/principalterms.txt
===================================================================
--- Zope3/trunk/src/zope/app/security/browser/principalterms.txt 2005-03-31 22:48:05 UTC (rev 29767)
+++ Zope3/trunk/src/zope/app/security/browser/principalterms.txt 2005-04-01 01:23:25 UTC (rev 29768)
@@ -11,10 +11,10 @@
... self.id, self.title = id, title
>>> from zope.interface import implements
- >>> from zope.app.security.interfaces import IAuthentication2
+ >>> from zope.app.security.interfaces import IAuthentication
>>> from zope.app.security.interfaces import PrincipalLookupError
>>> class AuthUtility:
- ... implements(IAuthentication2)
+ ... implements(IAuthentication)
... data = {'jim': 'Jim Fulton', 'stephan': 'Stephan Richter'}
...
... def getPrincipal(self, id):
@@ -26,14 +26,14 @@
Now we need to install the authentication utility:
>>> from zope.app.testing import ztapi
- >>> ztapi.provideUtility(IAuthentication2, AuthUtility())
+ >>> ztapi.provideUtility(IAuthentication, AuthUtility())
We need a principal source so that we can create a view from it.
>>> from zope.app import zapi
>>> class PrincipalSource:
... def __contains__(self, id):
- ... auth = zapi.getUtility(IAuthentication2)
+ ... auth = zapi.getUtility(IAuthentication)
... try:
... auth.getPrincipal(id)
... except PrincipalLookupError:
Modified: Zope3/trunk/src/zope/app/security/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/security/configure.zcml 2005-03-31 22:48:05 UTC (rev 29767)
+++ Zope3/trunk/src/zope/app/security/configure.zcml 2005-04-01 01:23:25 UTC (rev 29768)
@@ -23,7 +23,7 @@
<include file="_protections.zcml" />
<utility
- provides=".interfaces.IAuthentication2"
+ provides=".interfaces.IAuthentication"
component=".principalregistry.principalRegistry" />
<localUtility class=".permission.LocalPermission">
@@ -64,6 +64,7 @@
attributes="getName getDescription __str__" />
</content>
+ <adapter factory=".NoLogout" />
<!-- Standard Permissions -->
Modified: Zope3/trunk/src/zope/app/security/globalprincipals.txt
===================================================================
--- Zope3/trunk/src/zope/app/security/globalprincipals.txt 2005-03-31 22:48:05 UTC (rev 29767)
+++ Zope3/trunk/src/zope/app/security/globalprincipals.txt 2005-04-01 01:23:25 UTC (rev 29768)
@@ -273,5 +273,5 @@
>>> p.id, g.id in p.groups
('zope.unknown4', True)
-Note that it is up to IAuthentication2 implementations to associate
+Note that it is up to IAuthentication implementations to associate
these groups with their principals, as appropriate.
Modified: Zope3/trunk/src/zope/app/security/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/security/interfaces.py 2005-03-31 22:48:05 UTC (rev 29767)
+++ Zope3/trunk/src/zope/app/security/interfaces.py 2005-04-01 01:23:25 UTC (rev 29768)
@@ -137,17 +137,14 @@
object hierarchy.
"""
+# BBB gone for 3.1
class IAuthentication2(IAuthentication):
- """The second iteration of IAuthentication."""
-
- def logout(request):
- """Perform a logout."""
+ pass
-
-class IAuthenticationUtility(IAuthentication2):
+class IAuthenticationUtility(IAuthentication):
"""This interface is deprecated
"""
-
+
def getPrincipals(name):
"""This interface is deprecated
"""
@@ -184,9 +181,16 @@
"""A Source of Principal Ids"""
+class ILogout(Interface):
+ """Provides support for logging out."""
+
+ def logout(request):
+ """Perform a logout."""
+
+
class ILogoutSupported(Interface):
"""A marker indicating that the security configuration supports logout.
-
+
Provide an adapter to this interface to signal that the security system
supports logout.
- """
\ No newline at end of file
+ """
Added: Zope3/trunk/src/zope/app/security/logout.txt
===================================================================
--- Zope3/trunk/src/zope/app/security/logout.txt 2005-03-31 22:48:05 UTC (rev 29767)
+++ Zope3/trunk/src/zope/app/security/logout.txt 2005-04-01 01:23:25 UTC (rev 29768)
@@ -0,0 +1,76 @@
+==============
+Logout Support
+==============
+
+Logout support is defined by a simple interface ILogout:
+
+ >>> from zope.app.security.interfaces import ILogout
+
+that has a single 'logout' method.
+
+The current use of ILogout is to adapt an IAuthentication component to ILogout
+To illustrate, we'll create a simple logout implementation that adapts
+IAuthentication:
+
+ >>> class SimpleLogout(object):
+ ...
+ ... adapts(IAuthentication)
+ ... implements(ILogout)
+ ...
+ ... def __init__(self, auth):
+ ... pass
+ ...
+ ... def logout(self, request):
+ ... print 'User has logged out'
+
+ >>> provideAdapter(SimpleLogout)
+
+and something to represent an authentication utility:
+
+ >>> class Authentication(object):
+ ...
+ ... implements(IAuthentication)
+
+ >>> auth = Authentication()
+
+To perform a logout, we adapt auth to ILogout and call 'logout':
+
+ >>> logout = ILogout(auth)
+ >>> logout.logout(TestRequest())
+ User has logged out
+
+
+The 'NoLogout' Adapter
+======================
+
+The class:
+
+ >>> from zope.app.security import NoLogout
+
+can be registered as a fallback provider of ILogout for IAuthentication
+components that are not otherwise adaptable to ILogout. NoLogout's logout
+method is a no-op:
+
+ >>> NoLogout(auth).logout(TestRequest())
+
+
+Logout User Interface
+=====================
+
+Because some authentication protocols do not formally support logout, it may
+not be possible for a user to logout once he or she has logged in. In such
+cases, it would be inappropriate to present a user interface for logging out.
+
+Because logout support is site-configurable, Zope provides an adapter that,
+when registered, indicates that the site is configured for logout:
+
+ >>> from zope.app.security import LogoutSupported
+
+This class merely serves as a flag as it implements ILogoutSupported:
+
+ >>> from zope.app.security.interfaces import ILogoutSupported
+ >>> ILogoutSupported.implementedBy(LogoutSupported)
+ True
+
+For more information on login/logout UI, see
+zope/app/security/browser/loginlogout.txt.
Property changes on: Zope3/trunk/src/zope/app/security/logout.txt
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: Zope3/trunk/src/zope/app/security/principal.py
===================================================================
--- Zope3/trunk/src/zope/app/security/principal.py 2005-03-31 22:48:05 UTC (rev 29767)
+++ Zope3/trunk/src/zope/app/security/principal.py 2005-04-01 01:23:25 UTC (rev 29768)
@@ -17,7 +17,7 @@
"""
from zope.app import zapi
from zope.app.security.interfaces import PrincipalLookupError
-from zope.app.security.interfaces import IAuthentication2
+from zope.app.security.interfaces import IAuthentication
# BBB Backward Compatibility
from zope.exceptions import NotFoundError
@@ -25,7 +25,7 @@
def checkPrincipal(context, principal_id):
- auth = zapi.getUtility(IAuthentication2, context=context)
+ auth = zapi.getUtility(IAuthentication, context=context)
try:
if auth.getPrincipal(principal_id):
return
Modified: Zope3/trunk/src/zope/app/security/principalregistry.py
===================================================================
--- Zope3/trunk/src/zope/app/security/principalregistry.py 2005-03-31 22:48:05 UTC (rev 29767)
+++ Zope3/trunk/src/zope/app/security/principalregistry.py 2005-04-01 01:23:25 UTC (rev 29768)
@@ -29,9 +29,9 @@
class PrincipalRegistry(object):
- implements(interfaces.IAuthentication2)
+ implements(interfaces.IAuthentication, interfaces.ILogout)
- # Methods implementing IAuthentication2
+ # Methods implementing IAuthentication
def authenticate(self, request):
a = interfaces.ILoginPassword(request, None)
Added: Zope3/trunk/src/zope/app/security/tests/test_logout.py
===================================================================
--- Zope3/trunk/src/zope/app/security/tests/test_logout.py 2005-03-31 22:48:05 UTC (rev 29767)
+++ Zope3/trunk/src/zope/app/security/tests/test_logout.py 2005-04-01 01:23:25 UTC (rev 29768)
@@ -0,0 +1,27 @@
+import unittest
+
+from zope.testing import doctest
+from zope.interface import implements
+from zope.component import provideAdapter, adapts
+from zope.publisher.tests.httprequest import TestRequest
+
+from zope.app.testing import placelesssetup
+from zope.app.security import interfaces
+
+def test_suite():
+ return unittest.TestSuite((
+ doctest.DocFileSuite(
+ '../logout.txt',
+ globs={'provideAdapter': provideAdapter,
+ 'TestRequest': TestRequest,
+ 'implements': implements,
+ 'adapts': adapts,
+ 'IAuthentication': interfaces.IAuthentication
+ },
+ setUp=placelesssetup.setUp,
+ tearDown=placelesssetup.tearDown,
+ ),
+ ))
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')
Property changes on: Zope3/trunk/src/zope/app/security/tests/test_logout.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: Zope3/trunk/src/zope/app/security/tests/test_securitydirectives.py
===================================================================
--- Zope3/trunk/src/zope/app/security/tests/test_securitydirectives.py 2005-03-31 22:48:05 UTC (rev 29767)
+++ Zope3/trunk/src/zope/app/security/tests/test_securitydirectives.py 2005-04-01 01:23:25 UTC (rev 29768)
@@ -24,7 +24,7 @@
from zope.app.testing.placelesssetup import PlacelessSetup
from zope.app.servicenames import Authentication
-from zope.app.security.interfaces import IAuthentication2, IPermission
+from zope.app.security.interfaces import IAuthentication, IPermission
from zope.app.security.principalregistry import principalRegistry
from zope.app.security.settings import Allow
import zope.app.security.tests
@@ -34,7 +34,7 @@
def setUp(self):
super(TestBase, self).setUp()
- ztapi.provideUtility(IAuthentication2, principalRegistry)
+ ztapi.provideUtility(IAuthentication, principalRegistry)
class TestPrincipalDirective(TestBase, unittest.TestCase):
Modified: Zope3/trunk/src/zope/app/security/vocabulary.py
===================================================================
--- Zope3/trunk/src/zope/app/security/vocabulary.py 2005-03-31 22:48:05 UTC (rev 29767)
+++ Zope3/trunk/src/zope/app/security/vocabulary.py 2005-04-01 01:23:25 UTC (rev 29768)
@@ -22,7 +22,7 @@
from zope.interface import implements
from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary
from zope.schema.interfaces import ISourceQueriables
-from zope.app.security.interfaces import IPermission, IAuthentication2
+from zope.app.security.interfaces import IPermission, IAuthentication
from zope.app.security.interfaces import PrincipalLookupError
from zope.app.component import queryNextUtility
@@ -147,7 +147,7 @@
>>> zapi.getUtility = temp
"""
- auth = zapi.getUtility(IAuthentication2)
+ auth = zapi.getUtility(IAuthentication)
try:
auth.getPrincipal(id)
except PrincipalLookupError:
@@ -174,27 +174,27 @@
authentication utilities to look for queriables.
>>> class DummyUtility1:
- ... implements(IAuthentication2)
+ ... implements(IAuthentication)
... __parent__ = None
... def __repr__(self): return 'dummy1'
>>> dummy1 = DummyUtility1()
>>> class DummyUtility2:
- ... implements(ISourceQueriables, IAuthentication2)
+ ... implements(ISourceQueriables, IAuthentication)
... __parent__ = None
... def getQueriables(self):
... return ('1', 1), ('2', 2), ('3', 3)
>>> dummy2 = DummyUtility2()
>>> class DummyUtility3(DummyUtility2):
- ... implements(IAuthentication2)
+ ... implements(IAuthentication)
... def getQueriables(self):
... return ('4', 4),
>>> dummy3 = DummyUtility3()
>>> from zope.app.component.testing import testingNextUtility
- >>> testingNextUtility(dummy1, dummy2, IAuthentication2)
- >>> testingNextUtility(dummy2, dummy3, IAuthentication2)
+ >>> testingNextUtility(dummy1, dummy2, IAuthentication)
+ >>> testingNextUtility(dummy2, dummy3, IAuthentication)
>>> temp = zapi.getUtility
>>> zapi.getUtility = lambda iface: dummy1
@@ -206,7 +206,7 @@
>>> zapi.getUtility = temp
"""
i = 0
- auth = zapi.getUtility(IAuthentication2)
+ auth = zapi.getUtility(IAuthentication)
yielded = []
while True:
queriables = ISourceQueriables(auth, None)
@@ -219,7 +219,7 @@
if queriable not in yielded:
yield unicode(i)+'.'+unicode(qid), queriable
yielded.append(queriable)
- auth = queryNextUtility(auth, IAuthentication2)
+ auth = queryNextUtility(auth, IAuthentication)
if auth is None:
break
i += 1
Modified: Zope3/trunk/src/zope/app/securitypolicy/browser/granting.txt
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/browser/granting.txt 2005-03-31 22:48:05 UTC (rev 29767)
+++ Zope3/trunk/src/zope/app/securitypolicy/browser/granting.txt 2005-04-01 01:23:25 UTC (rev 29768)
@@ -29,11 +29,11 @@
>>> class Principal:
... def __init__(self, id, title): self.id, self.title = id, title
- >>> from zope.app.security.interfaces import IAuthentication2
+ >>> from zope.app.security.interfaces import IAuthentication
>>> from zope.app.security.interfaces import PrincipalLookupError
>>> from zope.interface import implements
>>> class AuthUtility:
- ... implements(IAuthentication2)
+ ... implements(IAuthentication)
... data = {'jim': Principal('jim', 'Jim Fulton'),
... 'stephan': Principal('stephan', 'Stephan Richter')}
...
@@ -48,7 +48,7 @@
... for principal in self.data.values()
... if search in principal.title]
- >>> ztapi.provideUtility(IAuthentication2, AuthUtility())
+ >>> ztapi.provideUtility(IAuthentication, AuthUtility())
- Security-related Adapters
@@ -91,7 +91,7 @@
>>> from zope.app.security.browser.auth import AuthUtilitySearchView
>>> from zope.app.form.browser.interfaces import ISourceQueryView
- >>> ztapi.browserViewProviding(IAuthentication2,
+ >>> ztapi.browserViewProviding(IAuthentication,
... AuthUtilitySearchView,
... ISourceQueryView)
Modified: Zope3/trunk/src/zope/app/securitypolicy/tests/test_principalpermissionmanager.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/tests/test_principalpermissionmanager.py 2005-03-31 22:48:05 UTC (rev 29767)
+++ Zope3/trunk/src/zope/app/securitypolicy/tests/test_principalpermissionmanager.py 2005-04-01 01:23:25 UTC (rev 29768)
@@ -22,7 +22,7 @@
from zope.app.testing.placelesssetup import PlacelessSetup
from zope.app.security.interfaces import IPermission
-from zope.app.security.interfaces import IAuthentication2
+from zope.app.security.interfaces import IAuthentication
from zope.app.security.permission import Permission
from zope.app.security.settings import Allow, Deny, Unset
@@ -41,7 +41,7 @@
def setUp(self):
super(Test, self).setUp()
- ztapi.provideUtility(IAuthentication2, principalRegistry)
+ ztapi.provideUtility(IAuthentication, principalRegistry)
def _make_principal(self, id=None, title=None):
Modified: Zope3/trunk/src/zope/app/securitypolicy/tests/test_principalrolemanager.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/tests/test_principalrolemanager.py 2005-03-31 22:48:05 UTC (rev 29767)
+++ Zope3/trunk/src/zope/app/securitypolicy/tests/test_principalrolemanager.py 2005-04-01 01:23:25 UTC (rev 29768)
@@ -21,7 +21,7 @@
from zope.app.testing import ztapi
from zope.app.testing.placelesssetup import PlacelessSetup
-from zope.app.security.interfaces import IAuthentication2
+from zope.app.security.interfaces import IAuthentication
from zope.app.security.settings import Allow, Deny
from zope.app.security.principalregistry import principalRegistry
@@ -38,7 +38,7 @@
def setUp(self):
super(Test, self).setUp()
- ztapi.provideUtility(IAuthentication2, principalRegistry)
+ ztapi.provideUtility(IAuthentication, principalRegistry)
def _make_principal(self, id=None, title=None):
p = principalRegistry.definePrincipal(
Modified: Zope3/trunk/src/zope/app/securitypolicy/tests/test_securitydirectives.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/tests/test_securitydirectives.py 2005-03-31 22:48:05 UTC (rev 29767)
+++ Zope3/trunk/src/zope/app/securitypolicy/tests/test_securitydirectives.py 2005-04-01 01:23:25 UTC (rev 29768)
@@ -26,7 +26,7 @@
from zope.app.testing.placelesssetup import PlacelessSetup
from zope.app.security.interfaces import IPermission
-from zope.app.security.interfaces import IAuthentication2
+from zope.app.security.interfaces import IAuthentication
from zope.app.security.permission import Permission
from zope.app.security.settings import Allow
from zope.app.security.principalregistry import principalRegistry
@@ -52,7 +52,7 @@
def setUp(self):
super(TestBase, self).setUp()
- ztapi.provideUtility(IAuthentication2, principalRegistry)
+ ztapi.provideUtility(IAuthentication, principalRegistry)
class TestRoleDirective(TestBase, unittest.TestCase):
Modified: Zope3/trunk/src/zope/app/securitypolicy/zopepolicy.txt
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/zopepolicy.txt 2005-03-31 22:48:05 UTC (rev 29767)
+++ Zope3/trunk/src/zope/app/securitypolicy/zopepolicy.txt 2005-04-01 01:23:25 UTC (rev 29768)
@@ -497,16 +497,16 @@
For our examples here, we'll create and register a stub principal
authentication service:
- >>> from zope.app.security.interfaces import IAuthentication2
+ >>> from zope.app.security.interfaces import IAuthentication
>>> class FauxPrincipals(dict):
- ... zope.interface.implements(IAuthentication2)
+ ... zope.interface.implements(IAuthentication)
... def getPrincipal(self, id):
... return self[id]
>>> auth = FauxPrincipals()
>>> from zope.app.testing import ztapi
- >>> ztapi.provideUtility(IAuthentication2, auth)
+ >>> ztapi.provideUtility(IAuthentication, auth)
>>> from zope.app import zapi
Let's define a group:
Modified: Zope3/trunk/src/zope/app/zapi/README.txt
===================================================================
--- Zope3/trunk/src/zope/app/zapi/README.txt 2005-03-31 22:48:05 UTC (rev 29767)
+++ Zope3/trunk/src/zope/app/zapi/README.txt 2005-04-01 01:23:25 UTC (rev 29768)
@@ -18,19 +18,19 @@
Traceback (most recent call last):
...
ComponentLookupError:
- (<InterfaceClass zope.app.security.interfaces.IAuthentication2>, '')
+ (<InterfaceClass zope.app.security.interfaces.IAuthentication>, '')
But if we provide an authentication service:
>>> import zope.interface
- >>> from zope.app.security.interfaces import IAuthentication2
+ >>> from zope.app.security.interfaces import IAuthentication
>>> class FakeAuthenticationUtility:
- ... zope.interface.implements(IAuthentication2)
+ ... zope.interface.implements(IAuthentication)
>>> fake = FakeAuthenticationUtility()
>>> from zope.app.testing import ztapi
- >>> ztapi.provideUtility(IAuthentication2, fake)
+ >>> ztapi.provideUtility(IAuthentication, fake)
Then we should be able to get the service back when we ask for the
principals:
Modified: Zope3/trunk/src/zope/app/zapi/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/zapi/__init__.py 2005-03-31 22:48:05 UTC (rev 29767)
+++ Zope3/trunk/src/zope/app/zapi/__init__.py 2005-04-01 01:23:25 UTC (rev 29768)
@@ -38,8 +38,8 @@
name = getName
def principals():
- from zope.app.security.interfaces import IAuthentication2
- return getUtility(IAuthentication2)
+ from zope.app.security.interfaces import IAuthentication
+ return getUtility(IAuthentication)
# BBB: Gone in 3.3.
from zope.deprecation import deprecated
More information about the Zope3-Checkins
mailing list