[Zope-CVS] CVS: Products/PluggableAuthService/plugins - HTTPBasicAuthHelper.py:1.6

Lennart Regebro regebro at nuxeo.com
Fri Sep 24 12:41:18 EDT 2004


Update of /cvs-repository/Products/PluggableAuthService/plugins
In directory cvs.zope.org:/tmp/cvs-serv7170/plugins

Modified Files:
	HTTPBasicAuthHelper.py 
Log Message:
Yet another attempt of ChallengeImplementation, that should cover all know usecases.


=== Products/PluggableAuthService/plugins/HTTPBasicAuthHelper.py 1.5 => 1.6 ===
--- Products/PluggableAuthService/plugins/HTTPBasicAuthHelper.py:1.5	Wed Sep 22 06:43:14 2004
+++ Products/PluggableAuthService/plugins/HTTPBasicAuthHelper.py	Fri Sep 24 12:40:48 2004
@@ -92,9 +92,20 @@
 
         """ Challenge the user for credentials.
         """
+        realm = response.realm
+        if realm:
+            response.setHeader('WWW-Authenticate', 'basic realm="%s"' % realm, 1)
         m = "<strong>You are not authorized to access this resource.</strong>"
-        raise Unauthorized, m
-
+        if response.debug_mode:
+            if response._auth:
+                m = m + '<p>\nUsername and password are not correct.'
+            else:
+                m = m + '<p>\nNo Authorization header found.'
+            
+        response.setBody(m, is_error=1)
+        response.setStatus(401)
+        return 1
+ 
     security.declarePrivate( 'resetCredentials' )
     def resetCredentials( self, request, response ):
 



More information about the Zope-CVS mailing list