Inspired by https://github.com/sample/pritunl-keycloak-user-check. Check repo for more information. Setup process is very similar.
The pritunl-authentik-user-check
is a plugin for Pritunl that checks if a user is available in Authentik.
The script acts as a middleware between Pritunl and Authentik, performing real-time user status checks during VPN connection attempts. It ensures that only users who exist in Authentik and are active are allowed to access the Pritunl VPN.
Before deploying the script, you need to adjust several parameters to match your Keycloak and Pritunl setup:
AUTHENTIK_BASE_URL
: The URL of your Authentik instance.AUTHENTIK_API_TOKEN
: Authentik API token of the user who access to /core/users/DEBUG
: Set toTrue
for detailed logging, useful for debugging.SEARCH_BY_EMAIL
: Set toTrue
to search users by email,False
to search by username.
Follow these steps to deploy the pritunl-authentik-user-check
script on your Pritunl server:
- Ensure you have a Keycloak client set up for your Pritunl server.
- Place
authentik_user_check.py
to the Pritunl plugins directory. By default, this directory is/var/lib/pritunl/plugins
. - Adjust the parameters in the script as per your Keycloak configuration.
- sudo
systemctl restart pritunl
. - Check the Pritunl logs to ensure that the plugin is loaded correctly and functioning as expected
tail /var/log/pritunl.log -n 100
.