in server/app/lib/asfuid.py [0:0]
def session_required(func):
"""Decorator for calls that require the user to be authenticated against OAuth.
Calls will be checked for an active, valid session, and if found, it will
add the session to the list of arguments for the originator. Otherwise, it
will return the standard no-auth JSON reply.
Thus, calls that require a session can use:
@asfuid.session_required
async def foo(form_data, session):
...
"""
@functools.wraps(func)
async def session_wrapper(form_data):
try:
session = Credentials() # Must be logged in via ASF OAuth
except AssertionError as e:
return {"success": False, "message": str(e)}, 403
return await func(form_data)
return session_wrapper