[Zope3-checkins] CVS: Zope3/src/zope/app/security/browser - auth.py:1.1 login.pt:1.1 login_failed.pt:1.1 logout.pt:1.1 redirect.pt:1.1 configure.zcml:1.4

Stephan Richter srichter at cosmos.phy.tufts.edu
Sat Mar 13 23:45:00 EST 2004


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

Modified Files:
	configure.zcml 
Added Files:
	auth.py login.pt login_failed.pt logout.pt redirect.pt 
Log Message:


Move the generic login/logout screens to zope.app.security.browser.




=== Added File Zope3/src/zope/app/security/browser/auth.py ===
##############################################################################
#
# Copyright (c) 2003 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.
#
##############################################################################
"""Login and Logout screens

$Id: auth.py,v 1.1 2004/03/14 04:45:00 srichter Exp $
"""
from zope.interface import implements
from zope.app.publisher.interfaces.http import ILogin, ILogout
from zope.app.security.principalregistry import UnauthenticatedPrincipal
from zope.app.pagetemplate import ViewPageTemplateFile
from zope.proxy import removeAllProxies

class HTTPAuthenticationLogin(object):
    implements(ILogin)

    def login(self, nextURL=None):
        """See zope.app.security.interfaces.ILogin"""
        if isinstance(removeAllProxies(self.request.user), \
                      UnauthenticatedPrincipal):
            self.request.unauthorized("basic realm='Zope'")
            return self.failed()
        else:
            if nextURL is None:
                return self.confirmation()
            else:
                self.request.response.redirect(nextURL)

    confirmation = ViewPageTemplateFile('login.pt')

    failed = ViewPageTemplateFile('login_failed.pt')


class HTTPAuthenticationLogout(object):
    """Since HTTP Authentication really does not know about logout, we are
    simply challenging the client again."""

    implements(ILogout)

    def __init__(self, context, request):
        self.context = context
        self.request = request

    def logout(self, nextURL=None):
        """See zope.app.security.interfaces.ILogout"""
        if not isinstance(self.request.user, UnauthenticatedPrincipal):
            self.request.unauthorized("basic realm='Zope'")
            if nextURL:
                return self.redirect()

        if nextURL is None:
            return self.confirmation()
        else:
            return self.request.response.redirect(nextURL)

    confirmation = ViewPageTemplateFile('logout.pt')

    redirect = ViewPageTemplateFile('redirect.pt')




=== Added File Zope3/src/zope/app/security/browser/login.pt ===
<html metal:use-macro="context/@@standard_macros/page">
  <body>
  <div metal:fill-slot="body">
  
     <h1 i18n:translate="">Login successful!</h1>

     <p style="font-size: 200%" i18n:translate="">
       You are now logged in as 
       <em tal:content="view/request/user/title" 
           i18n:name="UserTitle">Joe Smith</em>.
     </p>

     <a href="." i18n:translate="">Back to the main page.</a>

  </div>
  </body>

</html>


=== Added File Zope3/src/zope/app/security/browser/login_failed.pt ===
<html metal:use-macro="context/@@standard_macros/page">
  <body>
  <div metal:fill-slot="body">
  
     <h1 i18n:translate="">Login Failed!</h1>

     <p style="font-size: 150%" i18n:translate="">
       You cancelled the login procedure.
       <a tal:attributes= "href python: view.request.get('nextURL', '.')">
         Click here to return.
       </a>
     </p>

  </div>
  </body>

</html>


=== Added File Zope3/src/zope/app/security/browser/logout.pt ===
<html metal:use-macro="context/@@standard_macros/page">
  <body>
  <div metal:fill-slot="body">
  
     <h1 i18n:translate="">Logout successful!</h1>

     <p style="font-size: 200%" i18n:translate="">
       You are now logged out.
     </p>

     <a href="." i18n:translate="">Back to the main page.</a>

  </div>
  </body>

</html>


=== Added File Zope3/src/zope/app/security/browser/redirect.pt ===
<html metal:use-macro="context/@@standard_macros/page">
  <head>
    <metal:block fill-slot="headers">
      <meta http-equiv="refresh" content="0;url=./"
        tal:attributes="content string:0;;url=${view/request/nextURL}" />
    </metal:block>
  </head>
  <body>
  <div metal:fill-slot="body">
  
     <h1 i18n:translate="">You are being redirected!</h1>

     <p style="font-size: 150%">
       <a tal:attributes="href view/request/nextURL" i18n:translate="">
         If you you see this screen for more than 5 seconds, click here.
       </a>
     </p>

  </div>
  </body>

</html>


=== Zope3/src/zope/app/security/browser/configure.zcml 1.3 => 1.4 ===
--- Zope3/src/zope/app/security/browser/configure.zcml:1.3	Sat Mar 13 16:37:28 2004
+++ Zope3/src/zope/app/security/browser/configure.zcml	Sat Mar 13 23:45:00 2004
@@ -1,4 +1,6 @@
-<configure xmlns="http://namespaces.zope.org/zope">
+<configure
+   xmlns="http://namespaces.zope.org/zope"
+   xmlns:browser="http://namespaces.zope.org/browser">
 
   <view
       for="zope.app.security.interfaces.IPermissionField"
@@ -12,6 +14,24 @@
       provides="zope.app.form.interfaces.IDisplayWidget"
       type="zope.publisher.interfaces.browser.IBrowserRequest"
       factory=".permissionwidget.DisplayWidget"
+      />
+
+  <browser:page
+      name="login.html"
+      for="*"
+      class=".auth.HTTPAuthenticationLogin"
+      attribute="login"
+      permission="zope.Public"
+      allowed_interface="zope.app.publisher.interfaces.http.ILogin"
+      />
+
+  <browser:page
+      name="logout.html"
+      for="*"
+      class=".auth.HTTPAuthenticationLogout"
+      attribute="logout"
+      permission="zope.Public"
+      allowed_interface="zope.app.publisher.interfaces.http.ILogout"
       />
 
 </configure>




More information about the Zope3-Checkins mailing list