def wrapper(*args, **kw): user_id = kw.get('user') token_info = kw.get('token_info') try: with verify_user(user_id, token_info): parameters = ParameterDict(kw) return func(parameters) except MKException as exc: return problem( status=MK_STATUS.get(type(exc), 500), title=str(exc), detail="An exception occurred.", )
def __call__(self, environ, start_response): path_args = environ[ARGS_KEY] try: rfc7662 = _verify_user(environ) except MKException as exc: return problem( status=401, title=str(exc), )(environ, start_response) with set_user_context(rfc7662["sub"], rfc7662): wsgi_app = self.func(ParameterDict(path_args)) return wsgi_app(environ, start_response)
def __call__(self, environ, start_response): path_args = environ[ARGS_KEY] auth_header = environ.get('HTTP_AUTHORIZATION', '') try: rfc7662 = bearer_auth(auth_header) except MKException as exc: return problem( status=401, title=str(exc), ext={'auth_header': auth_header}, )(environ, start_response) with verify_user(rfc7662['sub'], rfc7662): wsgi_app = self.func(ParameterDict(path_args)) return wsgi_app(environ, start_response)
def __call__(self, environ: WSGIEnvironment, start_response: StartResponse) -> WSGIResponse: path_args = environ[ARGS_KEY] try: rfc7662 = _verify_user(environ, datetime.now()) except MKException as exc: return problem( status=401, title=str(exc), )(environ, start_response) with set_user_context(rfc7662["sub"], rfc7662): wsgi_app = self.endpoint.wrapped(ParameterDict(path_args)) return wsgi_app(environ, start_response)