Esempio n. 1
0
 def on_response(self, request: HttpRequest, response: HttpResponse):
     auth_token = request.get_header('Authorization')
     try:
         bearer, token = auth_token.split(' ')
         decoded = self.__verify_bearer_and_token(token)
         return 'userinfo', decoded
     except Exception as e:
         raise Exception('Error while decoding auth')
Esempio n. 2
0
 def parse_request(self) -> HttpRequest:
     return HttpRequest(self.get_method(), self.get_path(),
                        self.get_params(), self.get_body(),
                        self.get_headers(), self.get_mimetype(),
                        self.context)
Esempio n. 3
0
 def get_request(self):
     body = LambdaRequestParser.__parse_http_body(
         self.get_body(), self.get_header(
             'Content-Type')) if self.get_body() is not None else None
     return HttpRequest(self.event, self.get_method(), self.get_path(),
                        self.get_url_params(), body, self.get_headers())
Esempio n. 4
0
 def on_request(self, request: HttpRequest):
     self.log.info('{}: {}  Params: {}'.format(
         request.get_method(), request.get_path(),
         str(request.get_all_params())))
Esempio n. 5
0
 def on_request(self, request: HttpRequest):
     if not self.__is_valid_request(request):
         raise MethodNotAllowed('%s method not allowed' %
                                request.get_method())
Esempio n. 6
0
 def __is_valid_request(self, request: HttpRequest):
     method = request.get_method()
     return method in self.allowed_methods
Esempio n. 7
0
    def on_request(self, request: HttpRequest):
        auth_token = request.get_header('Authorization')

        bearer, token = auth_token.split(' ')
        if self.authorizer.bearer != bearer:
            raise Exception('ERROR ::: BEARER doesnt match')