<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def authenticated(f):
 """Access only with a valid session."""


    @functools.wraps(f)
    def wrapper(request, *args, **kwargs):
        if d1_common.const.SUBJECT_AUTHENTICATED not in request.all_subjects_set:
            raise d1_common.types.exceptions.NotAuthorized(
                0,
                'Access allowed only for authenticated subjects. Please reconnect with '
                'a valid DataONE session certificate. active_subjects="{}"'.format(
                    d1_gmn.app.auth.format_active_subjects(request)
                ),
            )
        return f(request, *args, **kwargs)

    return wrapper