Changeset 1614
- Timestamp:
- 02/07/07 15:29:04
- Files:
-
- trunk/cherrypy/_cprequest.py (modified) (1 diff)
- trunk/cherrypy/lib/auth.py (modified) (1 diff)
- trunk/cherrypy/lib/cptools.py (modified) (3 diffs)
- trunk/cherrypy/test/test_httpauth.py (modified) (3 diffs)
- trunk/cherrypy/test/test_sessionauthenticate.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/_cprequest.py
r1612 r1614 305 305 to the script_name ('mount point') of the application which is 306 306 handling this request.""" 307 308 login = None 309 login__doc = """ 310 When authentication is used during the request processing this is 311 set to 'False' if it failed and to the 'username' value if it succeeded. 312 The default 'None' implies that no authentication happened.""" 307 313 308 314 app = None trunk/cherrypy/lib/auth.py
r1418 r1614 27 27 if httpauth.checkResponse(ah, password, method=cherrypy.request.method, 28 28 encrypt=encrypt): 29 cherrypy.request.login = ah["username"] 29 30 return True 30 31 32 cherrypy.request.login = False 31 33 return False 32 34 trunk/cherrypy/lib/cptools.py
r1462 r1614 229 229 return True 230 230 else: 231 cherrypy.session[self.session_key] = username231 cherrypy.session[self.session_key] = cherrypy.request.login = username 232 232 self.on_login(username) 233 233 raise cherrypy.HTTPRedirect(from_page or "/") … … 239 239 sess[self.session_key] = None 240 240 if username: 241 cherrypy.request.login = None 241 242 self.on_logout(username) 242 243 raise cherrypy.HTTPRedirect(from_page) … … 256 257 del cherrypy.response.headers["Content-Length"] 257 258 return True 258 259 cherrypy.request.login = username 259 260 self.on_check(username) 260 261 trunk/cherrypy/test/test_httpauth.py
r1468 r1614 15 15 class DigestProtected: 16 16 def index(self): 17 return " This is protected by Digest auth."17 return "Hello %s, you've been authorized." % cherrypy.request.login 18 18 index.exposed = True 19 19 20 20 class BasicProtected: 21 21 def index(self): 22 return " This is protected by Basic auth."22 return "Hello %s, you've been authorized." % cherrypy.request.login 23 23 index.exposed = True 24 24 … … 58 58 self.getPage('/basic/', [('Authorization', 'Basic dGVzdDp0ZXN0')]) 59 59 self.assertStatus('200 OK') 60 self.assertBody( 'This is protected by Basic auth.')60 self.assertBody("Hello test, you've been authorized.") 61 61 62 62 def testDigest(self): … … 112 112 self.getPage('/digest/', [('Authorization', auth)]) 113 113 self.assertStatus('200 OK') 114 self.assertBody( 'This is protected by Digest auth.')114 self.assertBody("Hello test, you've been authorized.") 115 115 116 116 if __name__ == "__main__": trunk/cherrypy/test/test_sessionauthenticate.py
r1324 r1614 8 8 def check(username, password): 9 9 # Dummy check_username_and_password function 10 if username != ' login' or password != 'password':10 if username != 'test' or password != 'password': 11 11 return u'Wrong login/password' 12 12 … … 19 19 20 20 def index(self): 21 return "Hi , you are logged in"21 return "Hi %s, you are logged in" % cherrypy.request.login 22 22 index.exposed = True 23 23 … … 37 37 38 38 # setup credentials 39 login_body = 'username= login&password=password&from_page=/'39 login_body = 'username=test&password=password&from_page=/' 40 40 41 41 # attempt a login … … 45 45 # get the page now that we are logged in 46 46 self.getPage('/', self.cookies) 47 self.assertBody('Hi , you are logged in')47 self.assertBody('Hi test, you are logged in') 48 48 49 49 # do a logout

