Example #1
0
 def test_verify(self):
     query = (
         "redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Fauthz"
         "&response_type=code&client_id=0123456789"
     )
     ar = AuthorizationRequest().deserialize(query, "urlencoded")
     assert ar.verify()
Example #2
0
 def test_urlencoded_missing_required(self):
     ar = AuthorizationRequest(response_type=["code"])
     with pytest.raises(MissingRequiredAttribute):
         ar.verify()
Example #3
0
 def test_verify(self):
     query = 'redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Fauthz&response_type=code&client_id=0123456789'
     ar = AuthorizationRequest().deserialize(query, "urlencoded")
     assert ar.verify()
Example #4
0
 def test_urlencoded_missing_required(self):
     ar = AuthorizationRequest(response_type=["code"])
     with pytest.raises(MissingRequiredAttribute):
         ar.verify()
Example #5
0
        if not areq:
            logger.debug("No AuthzRequest")
            return self._error("invalid_request", "No parsable AuthzRequest")

        logger.debug("AuthzRequest: %s" % (areq.to_dict(),))
        try:
            redirect_uri = self.get_redirect_uri(areq)
        except (RedirectURIError, ParameterError), err:
            return self._error("invalid_request", "%s" % err)
        except UnknownClient, err:
            return self._error("unauthorized_client", "%s" % err)

        try:
            # verify that the request message is correct
            areq.verify()
        except (MissingRequiredAttribute, ValueError), err:
            return self._redirect_authz_error("invalid_request", redirect_uri,
                                              "%s" % err)

        # Check if the person is already authenticated
        a_args = {}
        if cookie:
            logger.debug("Cookie: %s" % cookie)
            a_args["cookie"] = cookie
        if authn:
            try:
                a_args["authorization"] = authn
            except KeyError:
                pass
        if not areq:
            logger.debug("No AuthzRequest")
            return self._error("invalid_request", "No parsable AuthzRequest")

        logger.debug("AuthzRequest: %s" % (areq.to_dict(), ))
        try:
            redirect_uri = self.get_redirect_uri(areq)
        except (RedirectURIError, ParameterError), err:
            return self._error("invalid_request", "%s" % err)
        except UnknownClient, err:
            return self._error("unauthorized_client", "%s" % err)

        try:
            # verify that the request message is correct
            areq.verify()
        except (MissingRequiredAttribute, ValueError), err:
            return self._redirect_authz_error("invalid_request", redirect_uri,
                                              "%s" % err)

        # Check if the person is already authenticated
        a_args = {}
        if cookie:
            logger.debug("Cookie: %s" % cookie)
            a_args["cookie"] = cookie
        if authn:
            try:
                a_args["authorization"] = authn
            except KeyError:
                pass