def api_auth(function=None):
def real_decorator(func):<EOL><INDENT>def wrapped(request, *args, **kwargs):<EOL><INDENT>try:<EOL><INDENT>user = _auth_url(request.get_full_path(), request.body)<EOL>request.user = user  <EOL><DEDENT>except Exception as e:<EOL><INDENT>return JsonResponse({"<STR_LIT:error>": str(e)}, status=<NUM_LIT>)<EOL><DEDENT>return func(request, *args, **kwargs)<EOL><DEDENT>setattr(wrapped, '<STR_LIT>', True)<EOL>return wrapped<EOL><DEDENT>return real_decorator if not function else real_decorator(function)<EOL>
check:
1, timestamp in reasonable range
2, api key exists
3, entry point allowed for this api key
4, signature correctness

effect:
- add user object in request if the api key is binding with an user