def has_sudo_privileges(request):
    """
    Check if a request is allowed to perform sudo actions
    """
    if getattr(request, '_sudo', None) is None:
        try:
            request._sudo = (
                request.user.is_authenticated() and
                constant_time_compare(
                    request.get_signed_cookie(COOKIE_NAME, salt=COOKIE_SALT, max_age=COOKIE_AGE),
                    request.session[COOKIE_NAME]
                )
            )
        except (__HOLE__, BadSignature):
            request._sudo = False
    return request._sudo
dataset/ETHPy150Open mattrobenolt/django-sudo/sudo/utils.py/has_sudo_privileges