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:

  1. 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.

  2. PAM: Linux system that requires console management or an SSH session on the OS.

  3. LDAP: Once you set up the connection in the Admin Web UI, Access Server can authenticate against an LDAP server.

  4. RADIUS: Once you set up the connection in the Admin Web UI, the Access Server can authenticate against a RADIUS server.

  5. 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⁠

  1. The user signs in with a VPN client or on the Client Web UI.

  2. They successfully authenticate with their credentials.

  3. 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⁠

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:

  1. The user attempts to authenticate.

  2. The post-auth script reads the configured X.509 attribute from the client certificate.

  3. If the value matches the expected value, the VPN connection succeeds.

  4. If it doesn't match, Access Server denies the connection.

Script 2: Group mapping⁠

Process overview:

  1. The user attempts to authenticate.

  2. The post-auth script reads the configured X.509 attribute.

  3. If the value matches an existing Access Server group name, Access Server assigns the user to that group.

  4. If no match exists, Access Server applies the default group settings.