def auth_complete(self, *args, **kwargs): """Completes login process, must return user instance""" sessionID = self.strategy.session_get("ymsessionID") if not sessionID: raise AuthStateMissing(self, "Missing Session ID.") response = self.call_api("Member.Profile.Get", sessionID) # fetch user data kwargs.update({'response': response, 'backend': self}) return self.strategy.authenticate(*args, **kwargs)
def validate_state(self): """Validate state value. Raises exception on error, returns state value if valid.""" if not self.STATE_PARAMETER and not self.REDIRECT_STATE: return None state = self.get_session_state() request_state = self.get_request_state() if not request_state: raise AuthMissingParameter(self, 'state') elif not state: raise AuthStateMissing(self, 'state') elif not request_state == state: raise AuthStateForbidden(self) else: return state
def validate_state(self): """Validate state value. Raises exception on error, returns state value if valid.""" if not self.STATE_PARAMETER and not self.REDIRECT_STATE: return None state = self.strategy.session_get(self.name + '_state') if state: request_state = self.data.get('state') or \ self.data.get('redirect_state') if not request_state: raise AuthMissingParameter(self, 'state') elif not state: raise AuthStateMissing(self, 'state') elif not request_state == state: raise AuthStateForbidden(self) return state
def validate_state(self): """Validate state value. Raises exception on error, returns state value if valid.""" state = self.strategy.session_get(self.name + '_state') request_state = self.data.get('state') if request_state and isinstance(request_state, list): request_state = request_state[0] if not request_state: raise AuthMissingParameter(self, 'state') elif not state: raise AuthStateMissing(self, 'state') elif not request_state == state: raise AuthStateForbidden(self) else: return state
class AuthStateMissingTest(BaseExceptionTestCase): exception = AuthStateMissing('foobar') expected_message = 'Session value state missing.'