Tutorial: Implementing a Post-Auth Script with X.509 Attributes
Overview
Access Server includes a post-auth programming hook that lets you extend authentication behavior after a user successfully authenticates. This tutorial explains how to use a post-auth script to:
Restrict VPN access based on X.509 attributes in a client certificate.
Automatically map users to Access Server groups based on those attributes.
Authentication and the post-auth script role
Access Server's authentication system
Access Server supports several robust authentication systems without using a post-auth script — whether you manage it from the Admin Web UI or authenticate against a third-party system. These are the systems already supported:
Local: Access Server's built-in authentication system storing user credential hashes in the user properties database, with management handled in the Admin Web UI.
PAM: Linux system that requires console management or an SSH session on the OS.
LDAP: Once you set up the connection in the Admin Web UI, Access Server can authenticate against an LDAP server.
RADIUS: Once you set up the connection in the Admin Web UI, the Access Server can authenticate against a RADIUS server.
SAML: Once you set up the connection in the Admin Web UI, Access Server can use SAML single sign-on (SSO) by authenticating through an identity provider (IdP).
For more information about these authentication methods, refer to this detailed topic: Authentication System.
The post-auth script process
The user signs in with a VPN client or on the Client Web UI.
They successfully authenticate with their credentials.
The post-auth script runs (hence, post-auth — after authentication).
The post-auth script is a text file written in Python. It can do all sorts of interesting things, like automating user group assignment based on specific criteria, implementing a custom authentication system, adding an extra filter to the login process, or checking the user device's hardware address.
Prerequisites
An installed Access Server running in ePKI mode. For more info, refer to External Public Key Infrastructure.
Basic knowledge of Python scripting.
Root access on the Access Server host.
Supported X.509 attributes
The following X.509 attributes were tested for this tutorial:
CN | Common Name |
OU | Organizational Unit |
O | Organization |
L | Locality |
ST | State |
C | Country |
CN+ | Common Name of chain |
subjectAltName | Allows users to specify additional hostnames for a single SSL certificate |
basicConstraints | Used to identify the type of certificate holder/subject |
SHA256 | Certificate Fingerprint |
How the post-auth script with X.509 attributes works
This tutorial includes two sample post-auth scripts.
Script 1: Allow or deny access
Process overview:
The user attempts to authenticate.
The post-auth script reads the configured X.509 attribute from the client certificate.
If the value matches the expected value, the VPN connection succeeds.
If it doesn't match, Access Server denies the connection.
Script 2: Group mapping
Process overview:
The user attempts to authenticate.
The post-auth script reads the configured X.509 attribute.
If the value matches an existing Access Server group name, Access Server assigns the user to that group.
If no match exists, Access Server applies the default group settings.