comparison MoinMoin/auth/__init__.py @ 6075:3f7f4cef7c2a

make log_attempt output easily parsed
author 'Karl O. Pinc' <kop@meme.com>
date Mon, 15 Sep 2014 21:53:09 -0500
parents a9567770da68
children 35473fe0967d
comparison
equal deleted inserted replaced
6074:6366f5b440ff 6075:3f7f4cef7c2a
250 check_surge_protect(request, action='auth-name', username=username) 250 check_surge_protect(request, action='auth-name', username=username)
251 251
252 u = user.User(request, name=username, password=password, auth_method=self.name) 252 u = user.User(request, name=username, password=password, auth_method=self.name)
253 if u.valid: 253 if u.valid:
254 logging.debug("%s: successfully authenticated user %r (valid)" % (self.name, u.name)) 254 logging.debug("%s: successfully authenticated user %r (valid)" % (self.name, u.name))
255 log_attempt("auth: login (moin)", True, request, username) 255 log_attempt("auth/login (moin)", True, request, username)
256 return ContinueLogin(u) 256 return ContinueLogin(u)
257 else: 257 else:
258 logging.debug("%s: could not authenticate user %r (not valid)" % (self.name, username)) 258 logging.debug("%s: could not authenticate user %r (not valid)" % (self.name, username))
259 log_attempt("auth: login (moin)", False, request, username) 259 log_attempt("auth/login (moin)", False, request, username)
260 return ContinueLogin(user_obj, _("Invalid username or password.")) 260 return ContinueLogin(user_obj, _("Invalid username or password."))
261 261
262 def login_hint(self, request): 262 def login_hint(self, request):
263 _ = request.getText 263 _ = request.getText
264 #if request.cfg.openidrp_registration_url: 264 #if request.cfg.openidrp_registration_url:
377 if u and self.autocreate: 377 if u and self.autocreate:
378 logging.debug("autocreating user") 378 logging.debug("autocreating user")
379 u.create_or_update() 379 u.create_or_update()
380 if u and u.valid: 380 if u and u.valid:
381 logging.debug("returning valid user %r" % u) 381 logging.debug("returning valid user %r" % u)
382 log_attempt("auth: request (given)", True, request, auth_username) 382 log_attempt("auth/request (given)", True, request, auth_username)
383 return u, True # True to get other methods called, too 383 return u, True # True to get other methods called, too
384 else: 384 else:
385 logging.debug("returning %r" % user_obj) 385 logging.debug("returning %r" % user_obj)
386 if u and not u.valid: 386 if u and not u.valid:
387 log_attempt("auth: request (given)", False, request, auth_username) 387 log_attempt("auth/request (given)", False, request, auth_username)
388 return user_obj, True 388 return user_obj, True
389 389
390 390
391 def handle_login(request, userobj=None, username=None, password=None, 391 def handle_login(request, userobj=None, username=None, password=None,
392 attended=True, openid_identifier=None, stage=None): 392 attended=True, openid_identifier=None, stage=None):
472 if 'setuid' in request.session and userobj and userobj.isSuperUser(): 472 if 'setuid' in request.session and userobj and userobj.isSuperUser():
473 old_user = userobj 473 old_user = userobj
474 uid = request.session['setuid'] 474 uid = request.session['setuid']
475 userobj = user.User(request, uid, auth_method='setuid') 475 userobj = user.User(request, uid, auth_method='setuid')
476 userobj.valid = True 476 userobj.valid = True
477 log_attempt("auth: login (setuid from %r)" % old_user.name, 477 log_attempt("auth/login (setuid from %r)" % old_user.name,
478 True, request, userobj.name) 478 True, request, userobj.name)
479 logging.debug("setup_suid returns %r, %r" % (userobj, old_user)) 479 logging.debug("setup_suid returns %r, %r" % (userobj, old_user))
480 return (userobj, old_user) 480 return (userobj, old_user)
481 481
482 def setup_from_session(request, session): 482 def setup_from_session(request, session):