Exemplo n.º 1
0
    def decorated_view(*args, **kwargs):
        auth_request = AuthRequest(request, settings.OAUTH)
        redirect_uri = auth_request.redirect_uri

        # if the redirect uri is invalid display the error message immediately
        if not redirect_uri.is_valid():
            return redirect_uri.error_message['error_description']

        # if any other part of the auth request is invalid, redirect with
        # the error information appended to the redirect uri as params
        if not auth_request.is_valid():
            return redirect_with_params(redirect_uri, **auth_request.error_message)

        return route(auth_request, redirect_uri, *args, **kwargs)
Exemplo n.º 2
0
 def test_redirect_uri_invalid(self):
     mock_req = MockRequest({"response_type": "code", "client_id": "neuaer"})
     req = AuthRequest(mock_req, self.oauth_settings)
     self.assertFalse(req.is_valid(), msg="invalid redirect_uri should invalidate req")
Exemplo n.º 3
0
 def test_response_type_invalid(self):
     req = AuthRequest(MockRequest({"response_type": "foo"}), self.oauth_settings)
     self.assertFalse(req.is_valid(), msg="response type of anything but code should be invalid")
     self.assertEqual(req.error_message, "rt")
Exemplo n.º 4
0
 def test_client_id_missing(self):
     req = AuthRequest(MockRequest({"response_type": "code"}), self.oauth_settings)
     self.assertFalse(req.is_valid(), msg="missing client id should be invalid")
     self.assertEqual(req.error_message, "mc")
Exemplo n.º 5
0
 def test_response_type_missing(self):
     req = AuthRequest(MockRequest({}), self.oauth_settings)
     self.assertFalse(req.is_valid(), msg="request without args should be invalid")
     self.assertEqual(req.error_message, "rt")