def auth_required(secret_key_func):
    """
    Requires that the user be authenticated either by a signature or by
    being actively logged in.
    """
    def actual_decorator(obj):

        def test_func(request, *args, **kwargs):
            secret_key = secret_key_func(request, *args, **kwargs)
            return validate_signature(request, secret_key) or request.user.is_authenticated()

        decorator = request_passes_test(test_func)
        return wrap_object(obj, decorator)

    return actual_decorator
Requires that the user be authenticated either by a signature or by
    being actively logged in.