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')
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)
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())
def on_request(self, request: HttpRequest): self.log.info('{}: {} Params: {}'.format( request.get_method(), request.get_path(), str(request.get_all_params())))
def on_request(self, request: HttpRequest): if not self.__is_valid_request(request): raise MethodNotAllowed('%s method not allowed' % request.get_method())
def __is_valid_request(self, request: HttpRequest): method = request.get_method() return method in self.allowed_methods
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')