| 1 |
# Upgrade V2 |
| 2 |
|
| 3 |
Version 2 includes configuration changes for username resolution, client-specific |
| 4 |
configuration, token validation, and security hardening. |
| 5 |
|
| 6 |
## Table of contents |
| 7 |
|
| 8 |
- [Upgrade checklist](#upgrade-checklist) |
| 9 |
- [Required configuration changes](#required-configuration-changes) |
| 10 |
- [Environment variable prefix](#environment-variable-prefix) |
| 11 |
- [Strict configuration parsing](#strict-configuration-parsing) |
| 12 |
- [Common name mode](#common-name-mode) |
| 13 |
- [Short URL](#short-url) |
| 14 |
- [Pass-through socket permissions](#pass-through-socket-permissions) |
| 15 |
- [Security hardening](#security-hardening) |
| 16 |
- [Debug listener](#debug-listener) |
| 17 |
- [OAuth2 provider HTTP requests](#oauth2-provider-http-requests) |
| 18 |
- [Custom HTML templates and client config names](#custom-html-templates-and-client-config-names) |
| 19 |
- [Reverse proxy headers](#reverse-proxy-headers) |
| 20 |
- [OpenVPN plugin](#openvpn-plugin) |
| 21 |
- [OAuth2 identity and CEL expressions](#oauth2-identity-and-cel-expressions) |
| 22 |
- [OAuth2 client authentication style](#oauth2-client-authentication-style) |
| 23 |
- [CEL context](#cel-context) |
| 24 |
- [OpenVPN username](#openvpn-username) |
| 25 |
- [Client-specific configuration](#client-specific-configuration) |
| 26 |
- [Common name client config](#common-name-client-config) |
| 27 |
- [Token claim client config](#token-claim-client-config) |
| 28 |
- [Profile selector](#profile-selector) |
| 29 |
- [Additive group routes](#additive-group-routes) |
| 30 |
- [Token validation](#token-validation) |
| 31 |
- [Common name validation](#common-name-validation) |
| 32 |
- [IP address validation](#ip-address-validation) |
| 33 |
- [Roles validation](#roles-validation) |
| 34 |
- [ACR validation](#acr-validation) |
| 35 |
- [Combining validation rules](#combining-validation-rules) |
| 36 |
- [Environment variable rename reference](#environment-variable-rename-reference) |
| 37 |
- [Verify the upgrade](#verify-the-upgrade) |
| 38 |
|
| 39 |
## Upgrade checklist |
| 40 |
|
| 41 |
Complete the steps that apply to your deployment: |
| 42 |
|
| 43 |
- [ ] [Rename all environment variables](#environment-variable-prefix). |
| 44 |
- [ ] [Remove unsupported settings and fix invalid configuration](#strict-configuration-parsing). |
| 45 |
- [ ] [Review the security changes](#security-hardening), especially for debug, |
| 46 |
reverse proxy, custom template, and plugin configurations. |
| 47 |
- [ ] [Update OAuth2 authentication and CEL settings](#oauth2-identity-and-cel-expressions). |
| 48 |
- [ ] [Migrate client-specific configuration](#client-specific-configuration), if enabled. |
| 49 |
- [ ] [Migrate token validation](#token-validation), if configured. |
| 50 |
- [ ] [Verify the migrated deployment](#verify-the-upgrade). |
| 51 |
|
| 52 |
## Required configuration changes |
| 53 |
|
| 54 |
Review these changes for every deployment. The subsections about removed |
| 55 |
options apply only when those options were configured in version 1. |
| 56 |
|
| 57 |
### Environment variable prefix |
| 58 |
|
| 59 |
Version 2 uses the project-specific `OPENVPN_AUTH_OAUTH2_` prefix for |
| 60 |
environment variables. The `CONFIG_` prefix used by version 1 is no longer |
| 61 |
supported. Rename every environment variable before upgrading. |
| 62 |
|
| 63 |
| Version 1 | Version 2 | |
| 64 |
| --- | --- | |
| 65 |
| `CONFIG_FILE` | `OPENVPN_AUTH_OAUTH2_CONFIG_FILE` | |
| 66 |
| `CONFIG_HTTP_LISTEN` | `OPENVPN_AUTH_OAUTH2_HTTP_LISTEN` | |
| 67 |
| `CONFIG_OAUTH2_CLIENT_ID` | `OPENVPN_AUTH_OAUTH2_OAUTH2_CLIENT_ID` | |
| 68 |
|
| 69 |
The suffix conversion also changes: dots and dashes both become single |
| 70 |
underscores. The earlier project-prefixed spelling used double underscores for |
| 71 |
dashes. Review the complete |
| 72 |
[environment variable rename reference](#environment-variable-rename-reference) |
| 73 |
for affected names and an example that applies both changes. |
| 74 |
|
| 75 |
### Strict configuration parsing |
| 76 |
|
| 77 |
Version 2 rejects invalid configuration input instead of silently using a |
| 78 |
default: |
| 79 |
|
| 80 |
- Boolean environment values must be exactly `true` or `false`. |
| 81 |
- Malformed environment values, such as an invalid duration, stop startup with |
| 82 |
an error. |
| 83 |
- Unknown variables with the `OPENVPN_AUTH_OAUTH2_` prefix stop startup with an |
| 84 |
error. |
| 85 |
- Positional command-line arguments are rejected. |
| 86 |
|
| 87 |
The unused top-level YAML `config:` property has been removed. Select the |
| 88 |
configuration file with `--config` or `OPENVPN_AUTH_OAUTH2_CONFIG_FILE`. |
| 89 |
|
| 90 |
Configuration precedence remains, from lowest to highest priority: built-in |
| 91 |
defaults, YAML, environment variables, and command-line flags. |
| 92 |
|
| 93 |
`openvpn.command-timeout` is now a public option for the maximum time to wait |
| 94 |
for an OpenVPN management command response. Its default is `10s`. It can be |
| 95 |
configured through YAML, the `--openvpn.command-timeout` flag, or |
| 96 |
`OPENVPN_AUTH_OAUTH2_OPENVPN_COMMAND_TIMEOUT`. |
| 97 |
|
| 98 |
#### Common name mode |
| 99 |
|
| 100 |
The common name mode has been removed. Version 2 always keeps the common name |
| 101 |
unchanged in the OAuth2 state. Remove every configured form of the option: |
| 102 |
|
| 103 |
| Source | Removed setting | |
| 104 |
| --- | --- | |
| 105 |
| YAML | `openvpn.common-name.mode` | |
| 106 |
| Command line | `--openvpn.common-name.mode` | |
| 107 |
| Version 1 environment | `CONFIG_OPENVPN_COMMON__NAME_MODE` | |
| 108 |
|
| 109 |
If you previously used `mode: omit` to keep the web authentication URL short, |
| 110 |
verify that the complete `client-pending-auth` command remains within OpenVPN's |
| 111 |
1023-byte management command limit. |
| 112 |
|
| 113 |
#### Short URL |
| 114 |
|
| 115 |
The `http.short-url` option and the `/?s=` redirect endpoint have been removed. |
| 116 |
Version 2 always uses `/oauth2/start?state=` for the authentication URL. Remove |
| 117 |
every configured form of the option. The complete `client-pending-auth` command, |
| 118 |
including the URL and client identifiers, must fit within OpenVPN's 1023-byte |
| 119 |
management command limit. |
| 120 |
|
| 121 |
| Source | Removed setting | |
| 122 |
| --- | --- | |
| 123 |
| YAML | `http.short-url` | |
| 124 |
| Command line | `--http.short-url` | |
| 125 |
| Version 1 environment | `CONFIG_HTTP_SHORT__URL` | |
| 126 |
|
| 127 |
#### Pass-through socket permissions |
| 128 |
|
| 129 |
`openvpn.pass-through.socket-mode` now requires explicit octal notation and |
| 130 |
accepts only permission values from `0000` through `0777`. Use either a leading |
| 131 |
zero, such as `0660`, or the `0o660` form. Unprefixed and decimal values are no |
| 132 |
longer accepted. |
| 133 |
|
| 134 |
For YAML configuration, quote the value so other YAML tools also preserve its |
| 135 |
octal notation: |
| 136 |
|
| 137 |
```yaml |
| 138 |
openvpn: |
| 139 |
pass-through: |
| 140 |
socket-mode: "0660" |
| 141 |
``` |
| 142 |
|
| 143 |
For command-line or environment configuration, use `0660`: |
| 144 |
|
| 145 |
```shell |
| 146 |
--openvpn.pass-through.socket-mode=0660 |
| 147 |
OPENVPN_AUTH_OAUTH2_OPENVPN_PASS_THROUGH_SOCKET_MODE=0660 |
| 148 |
``` |
| 149 |
|
| 150 |
If you previously used decimal `432` to obtain permissions `0660`, replace it |
| 151 |
with the explicit octal value `0660`. |
| 152 |
|
| 153 |
## Security hardening |
| 154 |
|
| 155 |
Review each subsection and apply the migration steps for the features used by |
| 156 |
your deployment. |
| 157 |
|
| 158 |
### Debug listener |
| 159 |
|
| 160 |
The default `debug.listen` address changes from `:9001` to |
| 161 |
`127.0.0.1:9001`. When `debug.pprof` is enabled without an explicit listen |
| 162 |
address, the profiling endpoint is now available only from the local host. |
| 163 |
|
| 164 |
Existing configurations that set `debug.listen` keep their configured address. |
| 165 |
If remote profiling access is required, prefer a secure tunnel or explicitly |
| 166 |
set a protected listen address. The profiling endpoint exposes runtime details |
| 167 |
and must not be available on an untrusted network. |
| 168 |
|
| 169 |
### OAuth2 provider HTTP requests |
| 170 |
|
| 171 |
Version 2 accepts an HTTP redirect from an OAuth2 provider only when the target |
| 172 |
uses the same host as the original request. A request that starts with HTTPS |
| 173 |
also cannot redirect to HTTP. This prevents authorization data or tokens from |
| 174 |
being redirected to an unexpected host or an unencrypted connection. |
| 175 |
|
| 176 |
Provider requests now have an overall timeout of 30 seconds. A provider that |
| 177 |
relies on cross-host redirects or takes longer than 30 seconds will cause |
| 178 |
authentication to fail. Where possible, update the configured issuer, |
| 179 |
discovery URL, or custom endpoint to its final URL instead of relying on an HTTP |
| 180 |
redirect. |
| 181 |
|
| 182 |
### Custom HTML templates and client config names |
| 183 |
|
| 184 |
Version 2 renders `http.template` files with Go's `html/template` package |
| 185 |
instead of `text/template`. Dynamic values are contextually escaped for their |
| 186 |
location in HTML, including text, attributes, URLs, CSS, and JavaScript. |
| 187 |
Retest custom templates before upgrading. A template that relied on a dynamic |
| 188 |
value being inserted as raw HTML will now render that value as text or reject an |
| 189 |
unsafe context. |
| 190 |
|
| 191 |
Contextual escaping is required because template values can include profile |
| 192 |
names derived from identity provider claims or CEL expressions. Without |
| 193 |
escaping, a crafted value could become browser-rendered markup or script. |
| 194 |
|
| 195 |
Client config names containing `<`, `>`, `"`, `'`, `&`, `` ` ``, or control |
| 196 |
characters are also rejected. These names are used as both configuration file |
| 197 |
names and values in the browser-based profile selector. Rename affected |
| 198 |
`<name>.conf` files and update `openvpn.client-config.expression` to return the |
| 199 |
new names. |
| 200 |
|
| 201 |
### Reverse proxy headers |
| 202 |
|
| 203 |
If `http.enable-proxy-headers` is enabled, `http.trusted-proxies` is now |
| 204 |
required. openvpn-auth-oauth2 will reject the configuration if proxy headers are |
| 205 |
enabled without at least one trusted proxy CIDR. |
| 206 |
|
| 207 |
Use the CIDR ranges of the reverse proxies that connect directly to |
| 208 |
openvpn-auth-oauth2: |
| 209 |
|
| 210 |
```yaml |
| 211 |
http: |
| 212 |
enable-proxy-headers: true |
| 213 |
trusted-proxies: |
| 214 |
- 127.0.0.1/32 |
| 215 |
- 10.0.0.0/24 |
| 216 |
``` |
| 217 |
|
| 218 |
Environment variable configuration: |
| 219 |
|
| 220 |
```ini |
| 221 |
OPENVPN_AUTH_OAUTH2_HTTP_ENABLE_PROXY_HEADERS=true |
| 222 |
OPENVPN_AUTH_OAUTH2_HTTP_TRUSTED_PROXIES=127.0.0.1/32,10.0.0.0/24 |
| 223 |
``` |
| 224 |
|
| 225 |
If openvpn-auth-oauth2 is not behind a reverse proxy, keep |
| 226 |
`http.enable-proxy-headers` disabled. |
| 227 |
|
| 228 |
### OpenVPN plugin |
| 229 |
|
| 230 |
The OpenVPN plugin is no longer experimental. |
| 231 |
|
| 232 |
The plugin management socket now requires password authentication. Existing |
| 233 |
OpenVPN plugin configurations that pass only the listen socket must add a |
| 234 |
password file argument, and openvpn-auth-oauth2 must use the same password for |
| 235 |
`openvpn.password`. |
| 236 |
|
| 237 |
Before: |
| 238 |
|
| 239 |
```openvpn |
| 240 |
plugin /path/to/openvpn-auth-oauth2.so "unix:///var/run/openvpn-oauth2.sock" |
| 241 |
``` |
| 242 |
|
| 243 |
After: |
| 244 |
|
| 245 |
```openvpn |
| 246 |
plugin /path/to/openvpn-auth-oauth2.so "unix:///var/run/openvpn-oauth2.sock" "/etc/openvpn/oauth2-plugin-password.txt" |
| 247 |
``` |
| 248 |
|
| 249 |
openvpn-auth-oauth2 configuration: |
| 250 |
|
| 251 |
```yaml |
| 252 |
openvpn: |
| 253 |
addr: unix:///var/run/openvpn-oauth2.sock |
| 254 |
password: "file:///etc/openvpn-auth-oauth2/oauth2-plugin-password.txt" |
| 255 |
``` |
| 256 |
|
| 257 |
The two password files must contain the same password. They can be separate |
| 258 |
files so OpenVPN and openvpn-auth-oauth2 can each read a file from the path |
| 259 |
allowed by their service permissions. |
| 260 |
|
| 261 |
## OAuth2 identity and CEL expressions |
| 262 |
|
| 263 |
Review this section when the deployment configures the OAuth2 client |
| 264 |
authentication style, username resolution, or any CEL expression. |
| 265 |
|
| 266 |
### OAuth2 client authentication style |
| 267 |
|
| 268 |
Version 2 replaces the Go-specific `oauth2.auth-style` values with concise |
| 269 |
configuration values: |
| 270 |
|
| 271 |
| Version 1 value | Version 2 value | |
| 272 |
| --- | --- | |
| 273 |
| `AuthStyleAutoDetect` | `auto` | |
| 274 |
| `AuthStyleInParams` | `params` | |
| 275 |
| `AuthStyleInHeader` | `header` | |
| 276 |
|
| 277 |
Update the value in YAML, the `--oauth2.auth-style` command-line flag, or the |
| 278 |
`OPENVPN_AUTH_OAUTH2_OAUTH2_AUTH_STYLE` environment variable. The version 1 |
| 279 |
values are no longer accepted. |
| 280 |
|
| 281 |
### CEL context |
| 282 |
|
| 283 |
Version 2 uses one namespaced context for username resolution, validation, and |
| 284 |
client config resolution. Update every CEL expression to use the new names: |
| 285 |
|
| 286 |
| Previous field | Version 2 field | |
| 287 |
| --- | --- | |
| 288 |
| `authMode` | `auth.mode` | |
| 289 |
| `openVPNSessionState` | `openvpn.sessionState` | |
| 290 |
| `openVPNUserCommonName` | `openvpn.commonName` | |
| 291 |
| `openVPNUserIPAddr` | `openvpn.ip` | |
| 292 |
| `oauth2TokenIPAddr` | `token.ip` | |
| 293 |
| `oauth2TokenClaims` | `token.claims` | |
| 294 |
| `username` | `user.username` | |
| 295 |
|
| 296 |
The four context namespaces are typed objects in version 2. Field names and |
| 297 |
types are checked when the configuration loads. Unknown fixed fields now |
| 298 |
prevent startup instead of producing an evaluation error during |
| 299 |
authentication. `token.claims` remains a dynamic map, so use |
| 300 |
`has(token.claims.department)` for optional claims. |
| 301 |
|
| 302 |
Version 2 also exposes normalized `user.subject`, `user.email`, `user.groups`, |
| 303 |
and `user.roles` fields. Prefer these fields when an expression should work |
| 304 |
across generic OIDC, UserInfo, GitHub, and refresh authentication. Raw |
| 305 |
`token.claims` can be empty when a provider supplies identity data through |
| 306 |
another source. |
| 307 |
|
| 308 |
Provider data and groups or roles are resolved first. The |
| 309 |
`oauth2.openvpn-username` expression then sets the final `user.username`, and |
| 310 |
validation and client config resolution use that final identity. |
| 311 |
|
| 312 |
### OpenVPN username |
| 313 |
|
| 314 |
The following options were removed or renamed: |
| 315 |
|
| 316 |
| Version 1 option | Version 2 option | |
| 317 |
| --- | --- | |
| 318 |
| `oauth2.openvpn-username-claim` | `oauth2.openvpn-username` | |
| 319 |
| `oauth2.openvpn-username-cel` | `oauth2.openvpn-username` | |
| 320 |
|
| 321 |
`oauth2.openvpn-username` is a CEL expression and must evaluate to a string. |
| 322 |
The default changed from the claim name `preferred_username` to |
| 323 |
`user.username`. This uses the provider's normalized username, including |
| 324 |
`preferred_username` for OIDC and the GitHub login for GitHub. |
| 325 |
|
| 326 |
If you used `oauth2.openvpn-username-claim`, convert the claim name into a CEL token claim lookup: |
| 327 |
|
| 328 |
```yaml |
| 329 |
# Version 1 |
| 330 |
oauth2: |
| 331 |
openvpn-username-claim: email |
| 332 |
|
| 333 |
# Version 2 |
| 334 |
oauth2: |
| 335 |
openvpn-username: user.email |
| 336 |
``` |
| 337 |
|
| 338 |
If you used `oauth2.openvpn-username-cel`, move it to |
| 339 |
`oauth2.openvpn-username` and translate its fields to the namespaced context: |
| 340 |
|
| 341 |
```yaml |
| 342 |
# Version 1 |
| 343 |
oauth2: |
| 344 |
openvpn-username-cel: 'oauth2TokenClaims.email.split("@")[0]' |
| 345 |
|
| 346 |
# Version 2 |
| 347 |
oauth2: |
| 348 |
openvpn-username: 'user.email.split("@")[0]' |
| 349 |
``` |
| 350 |
|
| 351 |
The environment variable for the new option is |
| 352 |
`OPENVPN_AUTH_OAUTH2_OAUTH2_OPENVPN_USERNAME`. |
| 353 |
Unlike version 1's provider-specific paths, the expression is applied |
| 354 |
consistently when identity comes from an ID token, UserInfo, or the GitHub API, |
| 355 |
and during validated refresh authentication. |
| 356 |
|
| 357 |
## Client-specific configuration |
| 358 |
|
| 359 |
Version 2 changes OpenVPN client-specific configuration from a single config |
| 360 |
name lookup to an expression-based resolver. |
| 361 |
|
| 362 |
The default client configuration directory changes from |
| 363 |
`/etc/openvpn-auth-oauth2/client-config-dir/` to |
| 364 |
`/etc/openvpn-auth-oauth2/client-config/`, matching the directory created by |
| 365 |
the installation packages. Deployments relying on the previous default must |
| 366 |
move their client configuration files or explicitly configure the previous |
| 367 |
path with `openvpn.client-config.path`. |
| 368 |
|
| 369 |
The following options are removed: |
| 370 |
|
| 371 |
| Version 1 option | Version 2 replacement | |
| 372 |
|-----------------------------------------------------|-------------------------------------------------| |
| 373 |
| `openvpn.client-config.token-claim` | `openvpn.client-config.expression` | |
| 374 |
| `openvpn.client-config.user-selector.enabled` | `openvpn.client-config.strategy: user-selector` | |
| 375 |
| `openvpn.client-config.user-selector.static-values` | `openvpn.client-config.expression` | |
| 376 |
|
| 377 |
`openvpn.client-config.expression` is a CEL expression and must evaluate |
| 378 |
to an ordered list of strings. It receives the full shared CEL context. |
| 379 |
`user.username` contains the resolved OpenVPN username, |
| 380 |
`user.groups` and `user.roles` contain normalized provider data, and |
| 381 |
`token.claims` contains raw ID token claims. |
| 382 |
|
| 383 |
The default strategy is now `merge`. It loads every resolved config file, |
| 384 |
deduplicates repeated config names and identical config lines, and skips missing |
| 385 |
config files. Keep authorization in `oauth2.validate.groups` or |
| 386 |
`oauth2.validate.expression`; client config files only assign OpenVPN settings |
| 387 |
such as routes. |
| 388 |
|
| 389 |
When `openvpn.client-config.expression` returns an empty list, version 2 loads |
| 390 |
`DEFAULT.conf`. This follows OpenVPN's `client-config-dir` default-file pattern. |
| 391 |
When the expression returns one or more config names, missing `<name>.conf` files |
| 392 |
are ignored by default. Set `openvpn.client-config.ignore-not-found: false` to |
| 393 |
deny the client when a returned config file does not exist. |
| 394 |
|
| 395 |
### Common name client config |
| 396 |
|
| 397 |
Version 1 could use the OpenVPN common name as the implicit client config name: |
| 398 |
|
| 399 |
```yaml |
| 400 |
# Version 1 |
| 401 |
openvpn: |
| 402 |
client-config: |
| 403 |
enabled: true |
| 404 |
path: /etc/openvpn-auth-oauth2/client-config |
| 405 |
``` |
| 406 |
|
| 407 |
In version 2, configure the resolver explicitly: |
| 408 |
|
| 409 |
```yaml |
| 410 |
# Version 2 |
| 411 |
openvpn: |
| 412 |
client-config: |
| 413 |
enabled: true |
| 414 |
path: /etc/openvpn-auth-oauth2/client-config |
| 415 |
expression: | |
| 416 |
[openvpn.commonName] |
| 417 |
``` |
| 418 |
|
| 419 |
To use the resolved OpenVPN username instead, use `user.username`: |
| 420 |
|
| 421 |
```yaml |
| 422 |
openvpn: |
| 423 |
client-config: |
| 424 |
enabled: true |
| 425 |
path: /etc/openvpn-auth-oauth2/client-config |
| 426 |
expression: | |
| 427 |
[user.username] |
| 428 |
``` |
| 429 |
|
| 430 |
### Token claim client config |
| 431 |
|
| 432 |
Version 1 could read a config name from one token claim: |
| 433 |
|
| 434 |
```yaml |
| 435 |
# Version 1 |
| 436 |
openvpn: |
| 437 |
client-config: |
| 438 |
enabled: true |
| 439 |
path: /etc/openvpn-auth-oauth2/client-config |
| 440 |
token-claim: groups |
| 441 |
``` |
| 442 |
|
| 443 |
In version 2, read the claim through `client-config.expression`: |
| 444 |
|
| 445 |
```yaml |
| 446 |
# Version 2 |
| 447 |
openvpn: |
| 448 |
client-config: |
| 449 |
enabled: true |
| 450 |
path: /etc/openvpn-auth-oauth2/client-config |
| 451 |
expression: | |
| 452 |
token.claims.groups |
| 453 |
``` |
| 454 |
|
| 455 |
If the claim can contain several values, all matching config files are merged by |
| 456 |
default. |
| 457 |
|
| 458 |
### Profile selector |
| 459 |
|
| 460 |
Version 1 enabled the selector with `user-selector.enabled`: |
| 461 |
|
| 462 |
```yaml |
| 463 |
# Version 1 |
| 464 |
openvpn: |
| 465 |
client-config: |
| 466 |
enabled: true |
| 467 |
path: /etc/openvpn-auth-oauth2/client-config |
| 468 |
token-claim: groups |
| 469 |
user-selector: |
| 470 |
enabled: true |
| 471 |
``` |
| 472 |
|
| 473 |
In version 2, use `strategy: user-selector`: |
| 474 |
|
| 475 |
```yaml |
| 476 |
# Version 2 |
| 477 |
openvpn: |
| 478 |
client-config: |
| 479 |
enabled: true |
| 480 |
path: /etc/openvpn-auth-oauth2/client-config |
| 481 |
strategy: user-selector |
| 482 |
expression: | |
| 483 |
token.claims.groups |
| 484 |
``` |
| 485 |
|
| 486 |
Static selector values also move into the expression: |
| 487 |
|
| 488 |
```yaml |
| 489 |
# Version 1 |
| 490 |
openvpn: |
| 491 |
client-config: |
| 492 |
enabled: true |
| 493 |
path: /etc/openvpn-auth-oauth2/client-config |
| 494 |
user-selector: |
| 495 |
enabled: true |
| 496 |
static-values: |
| 497 |
- corporate |
| 498 |
- guest |
| 499 |
``` |
| 500 |
|
| 501 |
```yaml |
| 502 |
# Version 2 |
| 503 |
openvpn: |
| 504 |
client-config: |
| 505 |
enabled: true |
| 506 |
path: /etc/openvpn-auth-oauth2/client-config |
| 507 |
strategy: user-selector |
| 508 |
expression: | |
| 509 |
["corporate", "guest"] |
| 510 |
``` |
| 511 |
|
| 512 |
### Additive group routes |
| 513 |
|
| 514 |
To assign several config files without showing the selector, keep the default |
| 515 |
`merge` strategy and return every allowed config name: |
| 516 |
|
| 517 |
```yaml |
| 518 |
oauth2: |
| 519 |
validate: |
| 520 |
groups: |
| 521 |
- GRP-VPN |
| 522 |
|
| 523 |
openvpn: |
| 524 |
client-config: |
| 525 |
enabled: true |
| 526 |
path: /etc/openvpn-auth-oauth2/client-config |
| 527 |
expression: | |
| 528 |
user.groups.filter(g, g in [ |
| 529 |
"GRP-VPN", |
| 530 |
"GRP-ADMIN", |
| 531 |
"GRP-NETWORK" |
| 532 |
]) + |
| 533 |
[user.username] |
| 534 |
``` |
| 535 |
|
| 536 |
## Token validation |
| 537 |
|
| 538 |
Version 2 renames the general CEL validation option and its environment |
| 539 |
variable: |
| 540 |
|
| 541 |
| Version 1 | Version 2 | |
| 542 |
| --- | --- | |
| 543 |
| `oauth2.validate.cel` | `oauth2.validate.expression` | |
| 544 |
| `CONFIG_OAUTH2_VALIDATE_CEL` | `OPENVPN_AUTH_OAUTH2_OAUTH2_VALIDATE_EXPRESSION` | |
| 545 |
|
| 546 |
Update the fields used by the expression as described in [CEL context](#cel-context). |
| 547 |
|
| 548 |
Version 2 removes the following dedicated validation options: |
| 549 |
|
| 550 |
| Version 1 option | Version 2 replacement | |
| 551 |
| --- | --- | |
| 552 |
| `oauth2.validate.acr` | `oauth2.validate.expression` | |
| 553 |
| `oauth2.validate.common-name` | `oauth2.validate.expression` | |
| 554 |
| `oauth2.validate.common-name-case-sensitive` | `oauth2.validate.expression` | |
| 555 |
| `oauth2.validate.ipaddr` | `oauth2.validate.expression` | |
| 556 |
| `oauth2.validate.issuer` | Removed | |
| 557 |
| `oauth2.validate.roles` | `oauth2.validate.expression` | |
| 558 |
|
| 559 |
`oauth2.validate.groups` stays available and does not need to be migrated. |
| 560 |
Remove `oauth2.validate.issuer` and `CONFIG_OAUTH2_VALIDATE_ISSUER` from your |
| 561 |
configuration. The setting did not disable issuer checks; issuer validation is |
| 562 |
always enforced for OIDC discovery and ID token verification. |
| 563 |
|
| 564 |
### Common name validation |
| 565 |
|
| 566 |
Version 1 compared the OpenVPN common name with a configured ID token claim. |
| 567 |
By default, the comparison was case-insensitive. |
| 568 |
|
| 569 |
```yaml |
| 570 |
# Version 1 |
| 571 |
oauth2: |
| 572 |
validate: |
| 573 |
common-name: preferred_username |
| 574 |
``` |
| 575 |
|
| 576 |
Use a CEL expression with `lowerAscii()` for the same case-insensitive behavior: |
| 577 |
|
| 578 |
```yaml |
| 579 |
# Version 2 |
| 580 |
oauth2: |
| 581 |
validate: |
| 582 |
expression: | |
| 583 |
has(token.claims.preferred_username) && |
| 584 |
openvpn.commonName.lowerAscii() == string(token.claims.preferred_username).lowerAscii() |
| 585 |
``` |
| 586 |
|
| 587 |
If you used case-sensitive common name validation: |
| 588 |
|
| 589 |
```yaml |
| 590 |
# Version 1 |
| 591 |
oauth2: |
| 592 |
validate: |
| 593 |
common-name: preferred_username |
| 594 |
common-name-case-sensitive: true |
| 595 |
``` |
| 596 |
|
| 597 |
Use a direct CEL comparison: |
| 598 |
|
| 599 |
```yaml |
| 600 |
# Version 2 |
| 601 |
oauth2: |
| 602 |
validate: |
| 603 |
expression: | |
| 604 |
has(token.claims.preferred_username) && |
| 605 |
openvpn.commonName == string(token.claims.preferred_username) |
| 606 |
``` |
| 607 |
|
| 608 |
### IP address validation |
| 609 |
|
| 610 |
Version 1 compared the OpenVPN client IP address with the `ipaddr` ID token claim: |
| 611 |
|
| 612 |
```yaml |
| 613 |
# Version 1 |
| 614 |
oauth2: |
| 615 |
validate: |
| 616 |
ipaddr: true |
| 617 |
``` |
| 618 |
|
| 619 |
Version 2 exposes the OpenVPN client IP as `openvpn.ip` and the token IP address claim as `token.ip`: |
| 620 |
|
| 621 |
```yaml |
| 622 |
# Version 2 |
| 623 |
oauth2: |
| 624 |
validate: |
| 625 |
expression: 'openvpn.ip == token.ip' |
| 626 |
``` |
| 627 |
|
| 628 |
### Roles validation |
| 629 |
|
| 630 |
Version 1 allowed access if at least one configured role was present in the token roles: |
| 631 |
|
| 632 |
```yaml |
| 633 |
# Version 1 |
| 634 |
oauth2: |
| 635 |
validate: |
| 636 |
roles: |
| 637 |
- admin |
| 638 |
- vpn-user |
| 639 |
``` |
| 640 |
|
| 641 |
Use the normalized roles list: |
| 642 |
|
| 643 |
```yaml |
| 644 |
# Version 2 |
| 645 |
oauth2: |
| 646 |
validate: |
| 647 |
expression: | |
| 648 |
'admin' in user.roles || 'vpn-user' in user.roles |
| 649 |
``` |
| 650 |
|
| 651 |
For GitHub provider configurations, team validation is also migrated to CEL. |
| 652 |
The GitHub provider always fetches organizations from `/user/orgs` and teams |
| 653 |
from `/user/teams`. It exposes organizations through `user.groups`. Teams are |
| 654 |
available through `user.roles` in the same `org:slug` format used by version 1: |
| 655 |
|
| 656 |
```yaml |
| 657 |
# Version 1 |
| 658 |
oauth2: |
| 659 |
provider: github |
| 660 |
validate: |
| 661 |
roles: |
| 662 |
- my-org:vpn-users |
| 663 |
- my-org:admins |
| 664 |
``` |
| 665 |
|
| 666 |
```yaml |
| 667 |
# Version 2 |
| 668 |
oauth2: |
| 669 |
provider: github |
| 670 |
validate: |
| 671 |
expression: | |
| 672 |
'my-org:vpn-users' in user.roles || 'my-org:admins' in user.roles |
| 673 |
``` |
| 674 |
|
| 675 |
Keep organization checks with `oauth2.validate.groups`; for GitHub this still |
| 676 |
uses the `/user/orgs` API. |
| 677 |
|
| 678 |
### ACR validation |
| 679 |
|
| 680 |
Version 1 used `oauth2.validate.acr` to require an Authentication Context Class Reference value: |
| 681 |
|
| 682 |
```yaml |
| 683 |
# Version 1 |
| 684 |
oauth2: |
| 685 |
validate: |
| 686 |
acr: |
| 687 |
- phr |
| 688 |
- phrh |
| 689 |
``` |
| 690 |
|
| 691 |
Use CEL to check the `acr` claim: |
| 692 |
|
| 693 |
```yaml |
| 694 |
# Version 2 |
| 695 |
oauth2: |
| 696 |
validate: |
| 697 |
expression: | |
| 698 |
has(token.claims.acr) && |
| 699 |
(token.claims.acr == 'phr' || token.claims.acr == 'phrh') |
| 700 |
``` |
| 701 |
|
| 702 |
### Combining validation rules |
| 703 |
|
| 704 |
If you used multiple removed validation options, combine them into one CEL expression: |
| 705 |
|
| 706 |
```yaml |
| 707 |
# Version 1 |
| 708 |
oauth2: |
| 709 |
validate: |
| 710 |
common-name: preferred_username |
| 711 |
ipaddr: true |
| 712 |
roles: |
| 713 |
- vpn-user |
| 714 |
``` |
| 715 |
|
| 716 |
```yaml |
| 717 |
# Version 2 |
| 718 |
oauth2: |
| 719 |
validate: |
| 720 |
expression: | |
| 721 |
has(token.claims.preferred_username) && |
| 722 |
openvpn.commonName.lowerAscii() == string(token.claims.preferred_username).lowerAscii() && |
| 723 |
openvpn.ip == token.ip && |
| 724 |
'vpn-user' in user.roles |
| 725 |
``` |
| 726 |
|
| 727 |
You can keep `oauth2.validate.groups` alongside CEL: |
| 728 |
|
| 729 |
```yaml |
| 730 |
oauth2: |
| 731 |
validate: |
| 732 |
groups: |
| 733 |
- vpn-users |
| 734 |
expression: | |
| 735 |
has(token.claims.acr) && |
| 736 |
token.claims.acr == 'phr' |
| 737 |
``` |
| 738 |
|
| 739 |
## Environment variable rename reference |
| 740 |
|
| 741 |
The earlier project-prefixed spelling used double underscores for dashes. |
| 742 |
Rename every affected variable as follows: |
| 743 |
|
| 744 |
| Previous project-prefixed name | Version 2 name | |
| 745 |
| --- | --- | |
| 746 |
| `OPENVPN_AUTH_OAUTH2_HTTP_ASSETS__PATH` | `OPENVPN_AUTH_OAUTH2_HTTP_ASSETS_PATH` | |
| 747 |
| `OPENVPN_AUTH_OAUTH2_HTTP_ENABLE__PROXY__HEADERS` | `OPENVPN_AUTH_OAUTH2_HTTP_ENABLE_PROXY_HEADERS` | |
| 748 |
| `OPENVPN_AUTH_OAUTH2_HTTP_TRUSTED__PROXIES` | `OPENVPN_AUTH_OAUTH2_HTTP_TRUSTED_PROXIES` | |
| 749 |
| `OPENVPN_AUTH_OAUTH2_LOG_VPN__CLIENT__IP` | `OPENVPN_AUTH_OAUTH2_LOG_VPN_CLIENT_IP` | |
| 750 |
| `OPENVPN_AUTH_OAUTH2_OAUTH2_AUTHORIZE__PARAMS` | `OPENVPN_AUTH_OAUTH2_OAUTH2_AUTHORIZE_PARAMS` | |
| 751 |
| `OPENVPN_AUTH_OAUTH2_OAUTH2_AUTH__STYLE` | `OPENVPN_AUTH_OAUTH2_OAUTH2_AUTH_STYLE` | |
| 752 |
| `OPENVPN_AUTH_OAUTH2_OAUTH2_CLIENT_PRIVATE__KEY` | `OPENVPN_AUTH_OAUTH2_OAUTH2_CLIENT_PRIVATE_KEY` | |
| 753 |
| `OPENVPN_AUTH_OAUTH2_OAUTH2_CLIENT_PRIVATE__KEY__ID` | `OPENVPN_AUTH_OAUTH2_OAUTH2_CLIENT_PRIVATE_KEY_ID` | |
| 754 |
| `OPENVPN_AUTH_OAUTH2_OAUTH2_GROUPS__CLAIM` | `OPENVPN_AUTH_OAUTH2_OAUTH2_GROUPS_CLAIM` | |
| 755 |
| `OPENVPN_AUTH_OAUTH2_OAUTH2_OPENVPN__USERNAME` | `OPENVPN_AUTH_OAUTH2_OAUTH2_OPENVPN_USERNAME` | |
| 756 |
| `OPENVPN_AUTH_OAUTH2_OAUTH2_REFRESH_USE__SESSION__ID` | `OPENVPN_AUTH_OAUTH2_OAUTH2_REFRESH_USE_SESSION_ID` | |
| 757 |
| `OPENVPN_AUTH_OAUTH2_OAUTH2_REFRESH_VALIDATE__USER` | `OPENVPN_AUTH_OAUTH2_OAUTH2_REFRESH_VALIDATE_USER` | |
| 758 |
| `OPENVPN_AUTH_OAUTH2_OAUTH2_REFRESH__NONCE` | `OPENVPN_AUTH_OAUTH2_OAUTH2_REFRESH_NONCE` | |
| 759 |
| `OPENVPN_AUTH_OAUTH2_OAUTH2_USER__INFO` | `OPENVPN_AUTH_OAUTH2_OAUTH2_USER_INFO` | |
| 760 |
| `OPENVPN_AUTH_OAUTH2_OPENVPN_AUTH__PENDING__TIMEOUT` | `OPENVPN_AUTH_OAUTH2_OPENVPN_AUTH_PENDING_TIMEOUT` | |
| 761 |
| `OPENVPN_AUTH_OAUTH2_OPENVPN_AUTH__TOKEN__USER` | `OPENVPN_AUTH_OAUTH2_OPENVPN_AUTH_TOKEN_USER` | |
| 762 |
| `OPENVPN_AUTH_OAUTH2_OPENVPN_BYPASS_COMMON__NAMES` | `OPENVPN_AUTH_OAUTH2_OPENVPN_BYPASS_COMMON_NAMES` | |
| 763 |
| `OPENVPN_AUTH_OAUTH2_OPENVPN_CLIENT__CONFIG_ENABLED` | `OPENVPN_AUTH_OAUTH2_OPENVPN_CLIENT_CONFIG_ENABLED` | |
| 764 |
| `OPENVPN_AUTH_OAUTH2_OPENVPN_CLIENT__CONFIG_EXPRESSION` | `OPENVPN_AUTH_OAUTH2_OPENVPN_CLIENT_CONFIG_EXPRESSION` | |
| 765 |
| `OPENVPN_AUTH_OAUTH2_OPENVPN_CLIENT__CONFIG_IGNORE__NOT__FOUND` | `OPENVPN_AUTH_OAUTH2_OPENVPN_CLIENT_CONFIG_IGNORE_NOT_FOUND` | |
| 766 |
| `OPENVPN_AUTH_OAUTH2_OPENVPN_CLIENT__CONFIG_PATH` | `OPENVPN_AUTH_OAUTH2_OPENVPN_CLIENT_CONFIG_PATH` | |
| 767 |
| `OPENVPN_AUTH_OAUTH2_OPENVPN_CLIENT__CONFIG_STRATEGY` | `OPENVPN_AUTH_OAUTH2_OPENVPN_CLIENT_CONFIG_STRATEGY` | |
| 768 |
| `OPENVPN_AUTH_OAUTH2_OPENVPN_COMMON__NAME_ENVIRONMENT__VARIABLE__NAME` | `OPENVPN_AUTH_OAUTH2_OPENVPN_COMMON_NAME_ENVIRONMENT_VARIABLE_NAME` | |
| 769 |
| `OPENVPN_AUTH_OAUTH2_OPENVPN_ENFORCE__UNIQUE__USER` | `OPENVPN_AUTH_OAUTH2_OPENVPN_ENFORCE_UNIQUE_USER` | |
| 770 |
| `OPENVPN_AUTH_OAUTH2_OPENVPN_OVERRIDE__USERNAME` | `OPENVPN_AUTH_OAUTH2_OPENVPN_OVERRIDE_USERNAME` | |
| 771 |
| `OPENVPN_AUTH_OAUTH2_OPENVPN_PASS__THROUGH_ADDRESS` | `OPENVPN_AUTH_OAUTH2_OPENVPN_PASS_THROUGH_ADDRESS` | |
| 772 |
| `OPENVPN_AUTH_OAUTH2_OPENVPN_PASS__THROUGH_ENABLED` | `OPENVPN_AUTH_OAUTH2_OPENVPN_PASS_THROUGH_ENABLED` | |
| 773 |
| `OPENVPN_AUTH_OAUTH2_OPENVPN_PASS__THROUGH_PASSWORD` | `OPENVPN_AUTH_OAUTH2_OPENVPN_PASS_THROUGH_PASSWORD` | |
| 774 |
| `OPENVPN_AUTH_OAUTH2_OPENVPN_PASS__THROUGH_SOCKET__GROUP` | `OPENVPN_AUTH_OAUTH2_OPENVPN_PASS_THROUGH_SOCKET_GROUP` | |
| 775 |
| `OPENVPN_AUTH_OAUTH2_OPENVPN_PASS__THROUGH_SOCKET__MODE` | `OPENVPN_AUTH_OAUTH2_OPENVPN_PASS_THROUGH_SOCKET_MODE` | |
| 776 |
| `OPENVPN_AUTH_OAUTH2_PROVIDER_GOOGLE_VALIDATE_GROUPS__TRANSITIVE` | `OPENVPN_AUTH_OAUTH2_PROVIDER_GOOGLE_VALIDATE_GROUPS_TRANSITIVE` | |
| 777 |
|
| 778 |
For `CONFIG_` variables, apply both the prefix and suffix changes. For example, |
| 779 |
rename `CONFIG_HTTP_ASSETS__PATH` to |
| 780 |
`OPENVPN_AUTH_OAUTH2_HTTP_ASSETS_PATH`. Variables not listed in this table only |
| 781 |
require the prefix change. |
| 782 |
|
| 783 |
## Verify the upgrade |
| 784 |
|
| 785 |
After migrating the configuration: |
| 786 |
|
| 787 |
1. Start version 2 and confirm that configuration parsing reports no unknown, |
| 788 |
removed, or malformed settings. |
| 789 |
2. Complete browser-based authentication and confirm that OpenVPN receives the |
| 790 |
expected username. |
| 791 |
3. If refresh authentication is enabled, verify an authentication refresh. |
| 792 |
4. If client-specific configuration is enabled, verify the selected or merged |
| 793 |
configuration files and their resulting OpenVPN settings. |
| 794 |
5. Exercise every enabled integration affected by the security changes, such |
| 795 |
as a reverse proxy, custom HTML template, debug listener, or OpenVPN plugin. |