def identity_from_form(self, visit_key): """Inspect the form to pull out identity information. Must have fields for user name, password, and a login submit button. Returns an identity dictionary or none if the form contained no identity information or the information was incorrect. """ params = request.params # only try to process credentials for login forms if params.has_key(self.submit_button_name): try: # form data contains login credentials user_name = params.pop(self.user_name_field) pw = params.pop(self.password_field) # just lose the submit button to prevent passing to final controller submit = params.pop(self.submit_button_name, None) submit_x = params.pop('%s.x' % self.submit_button_name, None) submit_y = params.pop('%s.y' % self.submit_button_name, None) set_login_attempted(True) identity = self.provider.validate_identity( user_name, pw, visit_key) if identity is None: log.warning("The credentials specified weren't valid") return None return identity except KeyError: log.error("Missing fields in login form") return None else: return None
def identity_from_form(self, visit_key): """Inspect the form to pull out identity information. Must have fields for user name, password, and a login submit button. Returns an identity dictionary or none if the form contained no identity information or the information was incorrect. """ params = request.params # only try to process credentials for login forms if params.has_key(self.submit_button_name): try: # form data contains login credentials user_name = params.pop(self.user_name_field) pw = params.pop(self.password_field) # just lose the submit button to prevent passing to final controller submit = params.pop(self.submit_button_name, None) submit_x = params.pop('%s.x' % self.submit_button_name, None) submit_y = params.pop('%s.y' % self.submit_button_name, None) set_login_attempted(True) identity = self.provider.validate_identity(user_name, pw, visit_key) if identity is None: log.warning("The credentials specified weren't valid") return None return identity except KeyError: log.error("Missing fields in login form") return None else: return None
def identity_from_http_auth(self, visit_key): """Only basic auth is handled at the moment.""" try: authorisation = request.headers['Authorization'] except KeyError: return None authScheme, schemeData = authorisation.split(' ', 1) # Only basic is handled at the moment if authScheme.lower() != 'basic': log.error("HTTP Auth is not basic") return None # decode credentials user_name, password = self.decode_basic_credentials(schemeData) set_login_attempted(True) return self.provider.validate_identity(user_name, password, visit_key)