def _on_auth_done(self,
                      is_auth_ok,
                      auth_failure_detail=None,
                      auth_failure_debug_details=None,
                      principal=None):

        # :TODO: how to differentiate between an authentication failure
        # and a failure with the authentication infrastructure

        if not is_auth_ok:

            self.set_status(httplib.UNAUTHORIZED)

            if _include_auth_failure_debug_details():

                if auth_failure_detail:
                    self.set_header(
                        auth_failure_detail_header_name,
                        "0x{:04x}".format(auth_failure_detail))

                if auth_failure_debug_details:
                    for (name, value) in auth_failure_debug_details.items():
                        name = "%s%s" % (debug_header_prefix, name)
                        value = strutil.make_http_header_value_friendly(value)
                        self.set_header(name, value)

            self.finish()

            return

        # the request has been successfully authenticated:-)
        # all that's left now is to asyc'y forward the request
        # to the app service
        aasf = async_app_service_forwarder.AsyncAppServiceForwarder(
            self.request.method,
            self.request.uri,
            self.request.headers,
            self.get_request_body_if_exists(),
            principal)
        aasf.forward(self._on_app_service_done)
Exemple #2
0
 def test_value_is_not_a_string(self):
     v = 1
     hv = strutil.make_http_header_value_friendly(v)
     self.assertIsNotNone(hv)
     self.assertEqual(hv, str(v))
Exemple #3
0
 def test_value_with_tabs_and_newline(self):
     v = "dave\t\nwas\r"
     hv = strutil.make_http_header_value_friendly(v)
     self.assertIsNotNone(hv)
     self.assertEqual(hv, "dave\\t\\nwas\\r")
Exemple #4
0
 def test_value_is_none(self):
     v = None
     hv = strutil.make_http_header_value_friendly(v)
     self.assertIsNotNone(hv)
     self.assertEqual(hv, "<None>")