You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/Client token validation.md
+64-17Lines changed: 64 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,12 @@ openvpn-auth-oauth2 supports advanced token validation using the [Common Express
4
4
5
5
## Overview
6
6
7
-
CEL validation provides a flexible way to enforce security policies by allowing you to write custom expressions that evaluate to `true` or `false`. This validation happens after the OAuth2 authentication flow completes but before the OpenVPN connection is established.
7
+
CEL validation provides a flexible way to enforce security policies by allowing you to write custom expressions that evaluate to `true` or `false`. This validation happens:
8
+
9
+
1.**During interactive authentication** - After the OAuth2 authentication flow completes but before the OpenVPN connection is established
10
+
2.**During token refresh** - When an existing OpenVPN session is refreshed using a refresh token (non-interactive authentication)
11
+
12
+
This ensures that access policies are continuously enforced throughout the lifecycle of the VPN connection, not just during initial authentication.
8
13
9
14
## Configuration
10
15
@@ -15,23 +20,28 @@ To enable CEL validation, configure the `oauth2.validate.cel` property in your c
> CEL validation is performed **both during initial OAuth2 authentication and during token refresh**. This means your validation rules will be continuously enforced throughout the entire lifecycle of a VPN session. Make sure your expressions account for both scenarios using the `authMode` variable if needed.
34
+
27
35
## Available Variables
28
36
29
37
The following variables are available in your CEL expressions:
30
38
31
39
| Variable | Type | Description |
32
40
|----------|------|-------------|
33
-
|`openvpnUserCommonName`|`string`| The common name (CN) of the OpenVPN client certificate |
34
-
|`openvpnUserIPAddr`|`string`| The IP address of the OpenVPN client |
41
+
|`authMode`|`string`| The authentication mode: `"interactive"` (initial OAuth2 login) or `"non-interactive"` (token refresh) |
42
+
|`openVPNSessionState`|`string`| The OpenVPN session state (e.g., `""`, `"Empty"`, `"Initial"`, `"Authenticated"`, `"Expired"`, `"Invalid"`, `"AuthenticatedEmptyUser"`, `"ExpiredEmptyUser"`) |
43
+
|`openVPNUserCommonName`|`string`| The common name (CN) of the OpenVPN client certificate |
44
+
|`openVPNUserIPAddr`|`string`| The IP address of the OpenVPN client |
35
45
|`oauth2TokenClaims`|`map<string, dynamic>`| All claims from the OAuth2 ID token |
36
46
37
47
## Expression Requirements
@@ -53,7 +63,8 @@ oauth2:
53
63
oauth2TokenClaims.department == 'engineering'
54
64
```
55
65
56
-
**Important:** If you try to access a claim that doesn't exist without using `has()`, the expression evaluation will fail and the user will be denied access.
66
+
> [!IMPORTANT]
67
+
> If you try to access a claim that doesn't exist without using `has()`, the expression evaluation will fail, and the user will be denied access.
57
68
58
69
## Examples
59
70
@@ -64,7 +75,7 @@ Ensure the OpenVPN common name matches the OAuth2 username claim:
Copy file name to clipboardExpand all lines: docs/Configuration.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -107,7 +107,7 @@ Usage of openvpn-auth-oauth2:
107
107
--oauth2.validate.groups value
108
108
oauth2 required user groups. If multiple groups are configured, the user needs to be least in one group. Comma separated list. Example: group1,group2,group3 (env: CONFIG_OAUTH2_VALIDATE_GROUPS)
109
109
--oauth2.validate.cel string
110
-
CEL expression for custom token validation. The expression must evaluate to a boolean value. Available variables: openvpnUserCommonName (string), openvpnUserIPAddr (string), oauth2TokenClaims (map). Example: openvpnUserCommonName == oauth2TokenClaims.preferred_username (env: CONFIG_OAUTH2_VALIDATE_CEL)
110
+
CEL expression for custom token validation. The expression must evaluate to a boolean value.
111
111
--oauth2.validate.ipaddr
112
112
validate client ipaddr between VPN and oidc token (env: CONFIG_OAUTH2_VALIDATE_IPADDR)
0 commit comments