How to configure VPN access time restrictions

Hello everyone,

We are currently evaluating the Pritunl Enterprise solution for our company and plan to start testing it soon.
Before proceeding, I would like to clarify one point regarding time-based VPN access control.

Our current environment

  • We use a local Active Directory synchronized with Azure AD.

  • VPN authentication is integrated via SSO (Single Sign-On).

  • Our current VPN solution includes a time-based access policy — for example:

    • Users can connect to the VPN only between 07:00 and 20:00.

    • Outside this time window, VPN access is blocked by default, and users must request and get approval from their manager to temporarily enable access.

What I would like to know

In Pritunl, what would be the best approach to configure this kind of time-based access restriction?

  • Is there a native feature or policy that can handle connection schedules?

  • Or would it be necessary to integrate with an external access management or automation system (for example, via API or directory-based rules)?

Any guidance, best practices, or references from the documentation would be very helpful as we design our Pritunl deployment.

Thanks

This can be done with a plugin.

sudo tee /var/lib/pritunl/plugins/auth.py << 'EOF'
from datetime import datetime

def user_connect(host_id, server_id, org_id, user_id, host_name,
        server_name, org_name, user_name, remote_ip, mac_addr, mac_addrs,
        platform, device_id, device_name, bypass_secondary, has_token,
        password, **kwargs):
    current_hour = datetime.now().hour
    if current_hour >= 20 or current_hour < 7:
        return False, 'Access denied: Outside allowed hours'
    return True, None
EOF

sudo systemctl restart pritunl