| 1 |
# Providers |
| 2 |
|
| 3 |
This page documents the setup at the OIDC provider. |
| 4 |
|
| 5 |
If this is your first deployment, start with [Getting Started](Getting%20Started) |
| 6 |
and return here when prompted to register the OIDC application. |
| 7 |
|
| 8 |
## Microsoft Entra ID (formerly known as Azure AD) |
| 9 |
|
| 10 |
<details> |
| 11 |
<summary>Expand</summary> |
| 12 |
|
| 13 |
### Register an app with Microsoft Entra ID |
| 14 |
|
| 15 |
1. Sign in to your admin account on the tenant. |
| 16 |
2. Navigate to the [App registrations](https://aad.portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredApps) page in the Entra ID admin center. |
| 17 |
3. Click on the `New registration` button to start the process of registering a new application. |
| 18 |
4. Enter a unique name for your application in the `Name` field. |
| 19 |
5. In the `Supported account types` section, select the appropriate option based on your requirements. If unsure, leave the default value selected. |
| 20 |
6. For the `Redirect URI`, select `Web` from the dropdown menu and input the public endpoint of your `openvpn-auth-oauth2` instance. For example, `https://openvpn-auth-oauth2.example.com/oauth2/callback`. |
| 21 |
7. Click on the `Register` button to create the application. |
| 22 |
8. Once the application is created, navigate to the `Certificates & secrets` section on the left-hand side menu. |
| 23 |
9. In the `Client secrets` tab, click on `New client secret` to generate a new secret for your application. |
| 24 |
10. Copy the generated client secret. This will be used as a configuration option for `openvpn-auth-oauth2`. |
| 25 |
11. Navigate to the `Token configuration` section on the left-hand side menu. |
| 26 |
12. Click on `Add optional claim` to add a new claim to your tokens. |
| 27 |
13. In the right panel, select `ID` as the token type. |
| 28 |
14. From the list of available claims, select `ipaddr`. |
| 29 |
15. Click on `Add` to include this claim in your tokens. |
| 30 |
|
| 31 |
References: |
| 32 |
|
| 33 |
- https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app |
| 34 |
- https://learn.microsoft.com/en-us/azure/active-directory/develop/active-directory-optional-claims |
| 35 |
|
| 36 |
### Configuration |
| 37 |
|
| 38 |
<table> |
| 39 |
<thead><tr><td>env/sysconfig configuration</td></tr></thead> |
| 40 |
<tbody><tr><td> |
| 41 |
|
| 42 |
```ini |
| 43 |
OPENVPN_AUTH_OAUTH2_OAUTH2_ISSUER=https://login.microsoftonline.com/$TENANT_ID/v2.0 |
| 44 |
OPENVPN_AUTH_OAUTH2_OAUTH2_CLIENT_ID=<client_id> |
| 45 |
OPENVPN_AUTH_OAUTH2_OAUTH2_CLIENT_SECRET=<client_secret> |
| 46 |
# The scopes openid profile are required, but configured by default. |
| 47 |
# offline_access is required for non-interactive session refresh. |
| 48 |
# OPENVPN_AUTH_OAUTH2_OAUTH2_SCOPES=openid profile offline_access |
| 49 |
``` |
| 50 |
</td></tr></tbody> |
| 51 |
<thead><tr><td>yaml configuration</td></tr></thead> |
| 52 |
<tbody><tr><td> |
| 53 |
|
| 54 |
```yaml |
| 55 |
oauth2: |
| 56 |
issuer: "https://login.microsoftonline.com/$TENANT_ID/v2.0" |
| 57 |
client: |
| 58 |
id: "<client_id>" |
| 59 |
secret: "<client_secret>" |
| 60 |
# The scopes openid profile are required, but configured by default. |
| 61 |
# offline_access is required for non-interactive session refresh. |
| 62 |
#scopes: |
| 63 |
# - "openid" |
| 64 |
# - "profile" |
| 65 |
# - "offline_access" |
| 66 |
|
| 67 |
``` |
| 68 |
</td></tr></tbody> |
| 69 |
</table> |
| 70 |
|
| 71 |
|
| 72 |
### Restrict auth to specific groups in your directory. (optional) |
| 73 |
|
| 74 |
Restrict login based on groups can be configured inside the App Registration directly. |
| 75 |
This is preferred. |
| 76 |
Users get the notice from Azure that they aren’t part of the group, and the login is denied. |
| 77 |
|
| 78 |
Reference: https://learn.microsoft.com/en-us/entra/identity-platform/howto-restrict-your-app-to-a-set-of-users#assign-the-app-to-users-and-groups-to-restrict-access |
| 79 |
|
| 80 |
To require multiple groups, define `OPENVPN_AUTH_OAUTH2_OAUTH2_VALIDATE_GROUPS`. |
| 81 |
|
| 82 |
</details> |
| 83 |
|
| 84 |
## Google Cloud / Google Workspace |
| 85 |
|
| 86 |
<details> |
| 87 |
<summary>Expand</summary> |
| 88 |
|
| 89 |
### Register an app on Google Cloud Console |
| 90 |
|
| 91 |
1. Login as admin into your [Google Cloud Console](https://console.cloud.google.com/). |
| 92 |
2. In the project Dashboard center pane, choose **"APIs & Services"**. |
| 93 |
3. If necessary, complete the `OAuth consent screen` wizard. You will probably want to create an `Internal` application. |
| 94 |
* If you reuse an existing application, your users may already have given consent for the usage of this application, |
| 95 |
which may not include refresh tokens. |
| 96 |
4. In the left Nav pane, choose **"Credentials"**. |
| 97 |
5. In the center pane, choose **"OAuth consent screen"** tab. Fill in **"Product name shown to users"** and hit save. |
| 98 |
6. In the center pane, choose **"Credentials"** tab. |
| 99 |
* Open the **"New credentials"** drop-down |
| 100 |
* Choose **"OAuth client ID"** |
| 101 |
* Choose **"Web application"** |
| 102 |
* Application name is freeform, choose something appropriate |
| 103 |
* Authorized redirect URIs is the location of oauth2/callback ex: https://yourdomain:9000/oauth2/callback |
| 104 |
* Choose "Create" |
| 105 |
7. Take note of the Client ID and Client Secret. |
| 106 |
|
| 107 |
### Restrict auth to specific Google Groups in your domain. (optional) |
| 108 |
|
| 109 |
> **IMPORTANT** |
| 110 |
> |
| 111 |
> For `oauth2.validate.groups`, you have to set the IDs of the groups, not the names. |
| 112 |
|
| 113 |
1. Navigate to the [Google Cloud Identity API](https://console.cloud.google.com/apis/api/cloudidentity.googleapis.com/) page and click on the "Enable API" button. |
| 114 |
2. Access the [Google Admin Portal](https://admin.google.com/ac/groups) and locate the group that is required for the `openvpn-auth-oauth2` authorization. |
| 115 |
3. The URL of the group page should follow this pattern: `https://admin.google.com/ac/groups/<ID>`. Replace `<ID>` with the ID of the group. Make sure to copy this ID for future use. If there are multiple groups, repeat this step for each one. |
| 116 |
4. Insert the copied IDs into the `OPENVPN_AUTH_OAUTH2_OAUTH2_VALIDATE_GROUPS` configuration setting in your `openvpn-auth-oauth2` setup. |
| 117 |
5. **Optional**: If oauth2 scopes are set in the configuration, the `https://www.googleapis.com/auth/cloud-identity.groups.readonly` scope is required for group validation. |
| 118 |
|
| 119 |
### Configuration |
| 120 |
|
| 121 |
Set the following variables in your openvpn-auth-oauth2 configuration file: |
| 122 |
|
| 123 |
<table> |
| 124 |
<thead><tr><td>env/sysconfig configuration</td></tr></thead> |
| 125 |
<tbody><tr><td> |
| 126 |
|
| 127 |
```ini |
| 128 |
OPENVPN_AUTH_OAUTH2_OAUTH2_PROVIDER=google |
| 129 |
OPENVPN_AUTH_OAUTH2_OAUTH2_ISSUER=https://accounts.google.com |
| 130 |
OPENVPN_AUTH_OAUTH2_OAUTH2_CLIENT_ID=162738495-xxxxx.apps.googleusercontent.com |
| 131 |
OPENVPN_AUTH_OAUTH2_OAUTH2_CLIENT_SECRET=GOCSPX-xxxxxxxx |
| 132 |
OPENVPN_AUTH_OAUTH2_OAUTH2_OPENVPN_USERNAME=user.email |
| 133 |
|
| 134 |
# The scopes openid profile email are required, but configured by default. |
| 135 |
# https://www.googleapis.com/auth/cloud-identity.groups.readonly is mandatory for group validation. |
| 136 |
# Enabled by default, if scopes aren't set in the config. |
| 137 |
#OPENVPN_AUTH_OAUTH2_OAUTH2_SCOPES=openid profile email https://www.googleapis.com/auth/cloud-identity.groups.readonly |
| 138 |
#OPENVPN_AUTH_OAUTH2_OAUTH2_VALIDATE_GROUPS=03x8tuzt3hqdv5v |
| 139 |
``` |
| 140 |
</td></tr></tbody> |
| 141 |
<thead><tr><td>yaml configuration</td></tr></thead> |
| 142 |
<tbody><tr><td> |
| 143 |
|
| 144 |
```yaml |
| 145 |
oauth2: |
| 146 |
provider: "google" |
| 147 |
issuer: "https://accounts.google.com" |
| 148 |
client: |
| 149 |
id: "162738495-xxxxx.apps.googleusercontent.com" |
| 150 |
secret: "GOCSPX-xxxxxxxx" |
| 151 |
openvpn-username: "user.email" |
| 152 |
# The scopes openid profile email are required, but configured by default. |
| 153 |
# https://www.googleapis.com/auth/cloud-identity.groups.readonly is mandatory for group validation. |
| 154 |
# Enabled by default, if scopes aren't set in the config. |
| 155 |
#scopes: |
| 156 |
# - "openid" |
| 157 |
# - "profile" |
| 158 |
# - "email" |
| 159 |
# - "https://www.googleapis.com/auth/cloud-identity.groups.readonly" |
| 160 |
validate: |
| 161 |
groups: |
| 162 |
- "03x8tuzt3hqdv5v" |
| 163 |
``` |
| 164 |
</td></tr></tbody> |
| 165 |
</table> |
| 166 |
|
| 167 |
### Transitive (nested) group membership (optional) |
| 168 |
|
| 169 |
By default, a user is only accepted when they are a **direct** member of one of the |
| 170 |
groups configured in `oauth2.validate.groups`. If your groups are nested (a group is |
| 171 |
a member of another group), enable transitive membership resolution so that members |
| 172 |
of nested sub-groups are accepted as well: |
| 173 |
|
| 174 |
<table> |
| 175 |
<thead><tr><td>env/sysconfig configuration</td></tr></thead> |
| 176 |
<tbody><tr><td> |
| 177 |
|
| 178 |
```ini |
| 179 |
OPENVPN_AUTH_OAUTH2_PROVIDER_GOOGLE_VALIDATE_GROUPS_TRANSITIVE=true |
| 180 |
``` |
| 181 |
</td></tr></tbody> |
| 182 |
<thead><tr><td>yaml configuration</td></tr></thead> |
| 183 |
<tbody><tr><td> |
| 184 |
|
| 185 |
```yaml |
| 186 |
provider: |
| 187 |
google: |
| 188 |
validate: |
| 189 |
groups-transitive: true |
| 190 |
``` |
| 191 |
</td></tr></tbody> |
| 192 |
</table> |
| 193 |
|
| 194 |
When enabled, membership is resolved through the Cloud Identity |
| 195 |
[`checkTransitiveMembership`](https://cloud.google.com/identity/docs/reference/rest/v1/groups.memberships/checkTransitiveMembership) |
| 196 |
API, which still requires the `https://www.googleapis.com/auth/cloud-identity.groups.readonly` scope. |
| 197 |
|
| 198 |
> **IMPORTANT** |
| 199 |
> |
| 200 |
> The `checkTransitiveMembership` API is only available for Google Workspace Enterprise |
| 201 |
> Standard, Enterprise Plus, and Enterprise for Education; and Cloud Identity Premium |
| 202 |
> accounts. On other plans the API returns an error and group validation fails. |
| 203 |
|
| 204 |
### Google consent screen always asking for permission grant |
| 205 |
|
| 206 |
If `oauth2.refresh.enabled` is set to `true`, Google SSO will always ask for permission grant. On technical side, |
| 207 |
this is because the `approval_prompt=force` is set on URL to obtain a refresh token. openvpn-auth-oauth2 requires a |
| 208 |
refresh token to validate the user on re-auth. |
| 209 |
|
| 210 |
To avoid this, you can set `oauth2.refresh.validate-user` to `false`. Read more about this in the [Configuration](Configuration.md#non-interactive-session-refresh) page. |
| 211 |
|
| 212 |
</details> |
| 213 |
|
| 214 |
## Keycloak |
| 215 |
|
| 216 |
<details> |
| 217 |
<summary>Expand</summary> |
| 218 |
|
| 219 |
### Register an App with Keycloak |
| 220 |
|
| 221 |
1. Sign in to your admin account on the Keycloak admin console. |
| 222 |
2. Choose an existing realm or create a new one. |
| 223 |
3. Create a new client: |
| 224 |
- Set the Client ID as `openvpn-auth-oauth2`. |
| 225 |
- Set the Client Type as `OpenID Connect`. |
| 226 |
- Name the client as `openvpn-auth-oauth2`. |
| 227 |
4. In the capability configuration page, enable 'Client authentication' and 'Standard flow' for the Authentication flow. Make sure 'Authorization' is turned off. |
| 228 |
5. In the login settings page, set the following values: |
| 229 |
- Root URL: `https://openvpn-auth-oauth2.example.com` |
| 230 |
- Valid Redirect URIs: `https://openvpn-auth-oauth2.example.com/oauth2/callback` |
| 231 |
- Web Origins: `https://openvpn-auth-oauth2.example.com` |
| 232 |
- Click 'Save'. |
| 233 |
6. Navigate to the 'Credentials' tab and note down the Client ID and Client Secret. |
| 234 |
|
| 235 |
### Configuration |
| 236 |
|
| 237 |
Set the following variables in your `openvpn-auth-oauth2` configuration file: |
| 238 |
|
| 239 |
<table> |
| 240 |
<thead><tr><td>env/sysconfig configuration</td></tr></thead> |
| 241 |
<tbody><tr><td> |
| 242 |
|
| 243 |
```ini |
| 244 |
OPENVPN_AUTH_OAUTH2_OAUTH2_ISSUER=https://<keycloak-domain>/auth/realms/<realm-name> |
| 245 |
OPENVPN_AUTH_OAUTH2_OAUTH2_CLIENT_ID=<client_id> |
| 246 |
OPENVPN_AUTH_OAUTH2_OAUTH2_CLIENT_SECRET=<client_secret> |
| 247 |
# The scopes openid profile are required, but configured by default. |
| 248 |
# offline_access is required for non-interactive session refresh. |
| 249 |
# OPENVPN_AUTH_OAUTH2_OAUTH2_SCOPES=openid profile offline_access |
| 250 |
``` |
| 251 |
</td></tr></tbody> |
| 252 |
<thead><tr><td>yaml configuration</td></tr></thead> |
| 253 |
<tbody><tr><td> |
| 254 |
|
| 255 |
```yaml |
| 256 |
oauth2: |
| 257 |
issuer: "https://<keycloak-domain>/auth/realms/<realm-name>" |
| 258 |
client: |
| 259 |
id: "<client_id>" |
| 260 |
secret: "<client_secret>" |
| 261 |
# The scopes openid profile are required, but configured by default. |
| 262 |
# offline_access is required for non-interactive session refresh. |
| 263 |
#scopes: |
| 264 |
# - "openid" |
| 265 |
# - "profile" |
| 266 |
# - "offline_access" |
| 267 |
|
| 268 |
``` |
| 269 |
</td></tr></tbody> |
| 270 |
</table> |
| 271 |
|
| 272 |
### Role Mapping for openvpn-auth-oauth2 (optional) |
| 273 |
|
| 274 |
openvpn-auth-oauth2 expects roles to be passed in the `roles` claim of the JWT token. |
| 275 |
If you are using Keycloak, you can map the roles to the `roles` claim in the token. To do this, follow these steps: |
| 276 |
|
| 277 |
1. Sign in to your admin account on the Keycloak admin console. |
| 278 |
2. On the left-hand side menu, navigate to `Client scopes`. |
| 279 |
3. Click on `Roles`. |
| 280 |
4. In the `Mappers` tab, select `client roles`. |
| 281 |
5. Set `Token Claim Name` from `resource_access.${client_id}.roles` to `roles` |
| 282 |
6. Set `Add to ID token` to `ON` |
| 283 |
7. Click `Save` |
| 284 |
8. In the `Mappers` tab, select `realm roles`. |
| 285 |
9. Set `Token Claim Name` from `resource_access.${client_id}.roles` to `roles` |
| 286 |
10. Set `Add to ID token` to `ON` |
| 287 |
11. Click `Save` |
| 288 |
|
| 289 |
### Compare client OpenVPN and Web client IPs. (optional) |
| 290 |
|
| 291 |
Currently, there is no known configuration to enrich the token with the client's IP address in Keycloak. |
| 292 |
If you know how to do this, please contribute to the documentation. |
| 293 |
|
| 294 |
</details> |
| 295 |
|
| 296 |
## GitHub |
| 297 |
|
| 298 |
|
| 299 |
<details> |
| 300 |
<summary>Expand</summary> |
| 301 |
|
| 302 |
### Caveats |
| 303 |
|
| 304 |
A user must explicitly [request](https://help.github.com/articles/requesting-organization-approval-for-oauth-apps/) an |
| 305 |
[organization](https://developer.github.com/v3/orgs/) give openvpn-auth-oauth2 |
| 306 |
[resource access](https://help.github.com/articles/approving-oauth-apps-for-your-organization/). |
| 307 |
openvpn-auth-oauth2 will not have the correct permissions to determine if the user is in that organization otherwise, and the user will |
| 308 |
not be able to log in. This request mechanism is a feature of the GitHub API. |
| 309 |
|
| 310 |
### Register the application in the identity provider |
| 311 |
|
| 312 |
In GitHub, [register](https://github.com/settings/developers) a new application. The callback address should be the /oauth2/callback endpoint of your |
| 313 |
openvpn-auth-oauth2 URL (e.g. https://login.example.com/oauth2/callback). |
| 314 |
|
| 315 |
After registering the app, you will receive an OAuth2 client ID and secret. These values will be inputted into the configuration below. |
| 316 |
|
| 317 |
### Configuration |
| 318 |
|
| 319 |
<table> |
| 320 |
<thead><tr><td>env/sysconfig configuration</td></tr></thead> |
| 321 |
<tbody><tr><td> |
| 322 |
|
| 323 |
```ini |
| 324 |
OPENVPN_AUTH_OAUTH2_OAUTH2_PROVIDER=github |
| 325 |
OPENVPN_AUTH_OAUTH2_OAUTH2_ISSUER=https://github.com |
| 326 |
OPENVPN_AUTH_OAUTH2_OAUTH2_CLIENT_ID=<client_id> |
| 327 |
OPENVPN_AUTH_OAUTH2_OAUTH2_CLIENT_SECRET=<client_secret> |
| 328 |
OPENVPN_AUTH_OAUTH2_OAUTH2_VALIDATE_GROUPS=your_github_org_name |
| 329 |
``` |
| 330 |
</td></tr></tbody> |
| 331 |
<thead><tr><td>yaml configuration</td></tr></thead> |
| 332 |
<tbody><tr><td> |
| 333 |
|
| 334 |
```yaml |
| 335 |
oauth2: |
| 336 |
provider: "github" |
| 337 |
issuer: "https://github.com" |
| 338 |
client: |
| 339 |
id: "<client_id>" |
| 340 |
secret: "<client_secret>" |
| 341 |
validate: |
| 342 |
groups: "your_github_org_name" |
| 343 |
``` |
| 344 |
</td></tr></tbody> |
| 345 |
</table> |
| 346 |
|
| 347 |
</details> |
| 348 |
|
| 349 |
## GitLab |
| 350 |
|
| 351 |
|
| 352 |
<details> |
| 353 |
<summary>Expand</summary> |
| 354 |
|
| 355 |
Supported: Self-Managed GitLab, GitLab.com |
| 356 |
|
| 357 |
### Register an app in GitLab |
| 358 |
|
| 359 |
To use GitLab as an OpenID Connect provider, you need to register an application in your GitLab account. |
| 360 |
This will provide you with a client ID and client secret that you will use in the configuration. |
| 361 |
Supported apps: |
| 362 |
|
| 363 |
* [User owned applications](https://docs.gitlab.com/integration/oauth_provider/#create-a-user-owned-application). |
| 364 |
* [Group owned applications](https://docs.gitlab.com/integration/oauth_provider/#create-a-group-owned-application). |
| 365 |
* [Instance-wide applications](https://docs.gitlab.com/integration/oauth_provider/#create-an-instance-wide-application). |
| 366 |
|
| 367 |
If you are using Self-Managed GitLab, your instance must have enabled HTTPS. |
| 368 |
|
| 369 |
### Configuration |
| 370 |
|
| 371 |
<table> |
| 372 |
<thead><tr><td>env/sysconfig configuration</td></tr></thead> |
| 373 |
<tbody><tr><td> |
| 374 |
|
| 375 |
```ini |
| 376 |
OPENVPN_AUTH_OAUTH2_OAUTH2_ISSUER=https://gitlab.com/ |
| 377 |
OPENVPN_AUTH_OAUTH2_OAUTH2_SCOPES=openid profile email |
| 378 |
OPENVPN_AUTH_OAUTH2_OAUTH2_USER_INFO=true |
| 379 |
OPENVPN_AUTH_OAUTH2_OAUTH2_CLIENT_ID=<client_id> |
| 380 |
OPENVPN_AUTH_OAUTH2_OAUTH2_CLIENT_SECRET=<client_secret> |
| 381 |
``` |
| 382 |
</td></tr></tbody> |
| 383 |
<thead><tr><td>yaml configuration</td></tr></thead> |
| 384 |
<tbody><tr><td> |
| 385 |
|
| 386 |
```yaml |
| 387 |
oauth2: |
| 388 |
issuer: "https://gitlab.com/" |
| 389 |
scopes: |
| 390 |
- "openid" |
| 391 |
- "profile" |
| 392 |
- "email" |
| 393 |
client: |
| 394 |
id: "<client_id>" |
| 395 |
secret: "<client_secret>" |
| 396 |
user-info: true |
| 397 |
``` |
| 398 |
</td></tr></tbody> |
| 399 |
</table> |
| 400 |
|
| 401 |
</details> |
| 402 |
|
| 403 |
## Digitalocean |
| 404 |
|
| 405 |
|
| 406 |
<details> |
| 407 |
<summary>Expand</summary> |
| 408 |
|
| 409 |
### Register an application in Digitalocean |
| 410 |
|
| 411 |
Developers must [register their application](https://cloud.digitalocean.com/account/api/applications/new) to use OAuth. |
| 412 |
A registered application is assigned a client ID and client secret. |
| 413 |
The client secret should be kept confidential, |
| 414 |
and only used between the application and the DigitalOcean authorization server https://cloud.digitalocean.com/v1/oauth. |
| 415 |
|
| 416 |
### Configuration |
| 417 |
|
| 418 |
<table> |
| 419 |
<thead><tr><td>env/sysconfig configuration</td></tr></thead> |
| 420 |
<tbody><tr><td> |
| 421 |
|
| 422 |
```ini |
| 423 |
OPENVPN_AUTH_OAUTH2_OAUTH2_ISSUER=https://cloud.digitalocean.com/ |
| 424 |
OPENVPN_AUTH_OAUTH2_OAUTH2_SCOPES=read |
| 425 |
OPENVPN_AUTH_OAUTH2_OAUTH2_CLIENT_ID=<client_id> |
| 426 |
OPENVPN_AUTH_OAUTH2_OAUTH2_CLIENT_SECRET=<client_secret> |
| 427 |
OPENVPN_AUTH_OAUTH2_OAUTH2_ENDPOINT_TOKEN=https://cloud.digitalocean.com/v1/oauth/token |
| 428 |
OPENVPN_AUTH_OAUTH2_OAUTH2_ENDPOINT_AUTH=https://cloud.digitalocean.com/v1/oauth/authorize |
| 429 |
``` |
| 430 |
</td></tr></tbody> |
| 431 |
<thead><tr><td>yaml configuration</td></tr></thead> |
| 432 |
<tbody><tr><td> |
| 433 |
|
| 434 |
```yaml |
| 435 |
oauth2: |
| 436 |
issuer: "https://cloud.digitalocean.com/" |
| 437 |
scopes: |
| 438 |
- "read" |
| 439 |
client: |
| 440 |
id: "<client_id>" |
| 441 |
secret: "<client_secret>" |
| 442 |
endpoints: |
| 443 |
token: "https://cloud.digitalocean.com/v1/oauth/token" |
| 444 |
auth: "https://cloud.digitalocean.com/v1/oauth/authorize" |
| 445 |
``` |
| 446 |
</td></tr></tbody> |
| 447 |
</table> |
| 448 |
|
| 449 |
</details> |
| 450 |
|
| 451 |
## Zitadel |
| 452 |
|
| 453 |
<details> |
| 454 |
<summary>Expand</summary> |
| 455 |
|
| 456 |
### Register an application in Zitadel |
| 457 |
|
| 458 |
1. Create a project in Zitadel |
| 459 |
2. Create a new application in a project |
| 460 |
3. Enter name and choose a web type |
| 461 |
4. Authentication method: POST |
| 462 |
5. Redirect URL: http://<vpn>:9000/oauth2/callback |
| 463 |
6. Save Client ID and Client Secret to use below |
| 464 |
|
| 465 |
After creating application, on page URLs you can find all links that you need. |
| 466 |
|
| 467 |
### Configuration |
| 468 |
|
| 469 |
<table> |
| 470 |
<thead><tr><td>env/sysconfig configuration</td></tr></thead> |
| 471 |
<tbody><tr><td> |
| 472 |
|
| 473 |
```ini |
| 474 |
OPENVPN_AUTH_OAUTH2_OAUTH2_ISSUER=https://company.zitadel.cloud |
| 475 |
OPENVPN_AUTH_OAUTH2_OAUTH2_CLIENT_ID=<client_id> |
| 476 |
OPENVPN_AUTH_OAUTH2_OAUTH2_CLIENT_SECRET=<client_secret> |
| 477 |
# The scopes openid profile email are required, but configured by default. |
| 478 |
# offline_access is required for non-interactive session refresh. |
| 479 |
#OPENVPN_AUTH_OAUTH2_OAUTH2_SCOPES=openid profile email offline_access |
| 480 |
``` |
| 481 |
</td></tr></tbody> |
| 482 |
<thead><tr><td>yaml configuration</td></tr></thead> |
| 483 |
<tbody><tr><td> |
| 484 |
|
| 485 |
```yaml |
| 486 |
oauth2: |
| 487 |
issuer: "https://company.zitadel.cloud" |
| 488 |
client: |
| 489 |
id: "<client_id>" |
| 490 |
secret: "<client_secret>" |
| 491 |
# The scopes openid profile are required, but configured by default. |
| 492 |
# offline_access is required for non-interactive session refresh. |
| 493 |
#scopes: |
| 494 |
# - "openid" |
| 495 |
# - "profile" |
| 496 |
# - "email" |
| 497 |
# - "offline_access" |
| 498 |
``` |
| 499 |
</td></tr></tbody> |
| 500 |
</table> |
| 501 |
|
| 502 |
</details> |
| 503 |
|
| 504 |
## Authentik |
| 505 |
|
| 506 |
<details> |
| 507 |
<summary>Expand</summary> |
| 508 |
|
| 509 |
### Register an application in Authentik |
| 510 |
|
| 511 |
1. Sign in to your Authentik admin interface |
| 512 |
2. Navigate to **Applications** → **Providers** |
| 513 |
3. Click **Create** and select **OAuth2/OpenID Provider** |
| 514 |
4. Configure the provider: |
| 515 |
- **Name**: `openvpn-auth-oauth2` |
| 516 |
- **Client Type**: `confidential` |
| 517 |
- **Redirect URIs**: `https://openvpn-auth-oauth2.example.com/oauth2/callback` |
| 518 |
- **Signing Key**: Select an appropriate certificate |
| 519 |
- **Subject Mode**: Based on the User's hashed ID |
| 520 |
- **Issuer Mode**: Each provider has a different issuer, based on the application slug |
| 521 |
5. Under **Advanced protocol settings**, add `offline_access` to the **Scopes** list (defaults are typically email, openid, and profile). This is only needed if you intend to use [non-interactive session refresh](Non-interactive%20session%20refresh.md) |
| 522 |
6. Save and note the **Client ID** and **Client Secret** |
| 523 |
7. Create an Application: |
| 524 |
- Navigate to **Applications** → **Applications** |
| 525 |
- Click **Create** |
| 526 |
- **Name**: `OpenVPN OAuth2` |
| 527 |
- **Slug**: `openvpn-oauth2` |
| 528 |
- **Provider**: Select the provider created above |
| 529 |
8. Configure group/user access as needed in the **Policy Bindings** tab |
| 530 |
|
| 531 |
### Configuration |
| 532 |
|
| 533 |
<table> |
| 534 |
<thead><tr><td>env/sysconfig configuration</td></tr></thead> |
| 535 |
<tbody><tr><td> |
| 536 |
|
| 537 |
```ini |
| 538 |
OPENVPN_AUTH_OAUTH2_OAUTH2_ISSUER=https://auth.example.com/application/o/openvpn-oauth2/ |
| 539 |
OPENVPN_AUTH_OAUTH2_OAUTH2_CLIENT_ID=<client_id> |
| 540 |
OPENVPN_AUTH_OAUTH2_OAUTH2_CLIENT_SECRET=<client_secret> |
| 541 |
OPENVPN_AUTH_OAUTH2_OAUTH2_REFRESH_NONCE=empty |
| 542 |
``` |
| 543 |
</td></tr></tbody> |
| 544 |
<thead><tr><td>yaml configuration</td></tr></thead> |
| 545 |
<tbody><tr><td> |
| 546 |
|
| 547 |
```yaml |
| 548 |
oauth2: |
| 549 |
provider: "authentik" |
| 550 |
issuer: "https://auth.example.com/application/o/openvpn-oauth2/" |
| 551 |
client: |
| 552 |
id: "<client_id>" |
| 553 |
secret: "<client_secret>" |
| 554 |
refresh-nonce: "empty" |
| 555 |
``` |
| 556 |
</td></tr></tbody> |
| 557 |
</table> |
| 558 |
|
| 559 |
</details> |
| 560 |
|
| 561 |
## Okta |
| 562 |
|
| 563 |
<details> |
| 564 |
<summary>Expand</summary> |
| 565 |
|
| 566 |
### Register an app with Okta |
| 567 |
|
| 568 |
1. Sign in to your Okta Admin Console. |
| 569 |
2. Navigate to **Applications** → **Applications** and click **Create App Integration**. |
| 570 |
3. Select **OIDC - OpenID Connect** as the sign-in method and **Web Application** as the application type, then click **Next**. |
| 571 |
4. Enter a name for the application, for example `openvpn-auth-oauth2`. |
| 572 |
5. In the **Grant type** section, keep **Authorization Code** enabled. |
| 573 |
Additionally enable **Refresh Token** if you plan to use non-interactive session refresh, see below. |
| 574 |
6. Set the **Sign-in redirect URI** to the public endpoint of your `openvpn-auth-oauth2` instance, |
| 575 |
for example `https://openvpn-auth-oauth2.example.com/oauth2/callback`. |
| 576 |
7. Under **Assignments**, limit the application to the groups that are allowed to connect to the VPN. |
| 577 |
8. Click **Save**, then note the **Client ID** and **Client secret** from the **General** tab. |
| 578 |
|
| 579 |
References: |
| 580 |
|
| 581 |
- https://help.okta.com/en-us/content/topics/apps/apps_app_integration_wizard_oidc.htm |
| 582 |
- https://developer.okta.com/docs/concepts/auth-servers/ |
| 583 |
- https://developer.okta.com/docs/guides/refresh-tokens/main/ |
| 584 |
|
| 585 |
### Configuration |
| 586 |
|
| 587 |
<table> |
| 588 |
<thead><tr><td>env/sysconfig configuration</td></tr></thead> |
| 589 |
<tbody><tr><td> |
| 590 |
|
| 591 |
```ini |
| 592 |
OPENVPN_AUTH_OAUTH2_OAUTH2_ISSUER=https://<your-org>.okta.com |
| 593 |
OPENVPN_AUTH_OAUTH2_OAUTH2_CLIENT_ID=<client_id> |
| 594 |
OPENVPN_AUTH_OAUTH2_OAUTH2_CLIENT_SECRET=<client_secret> |
| 595 |
``` |
| 596 |
</td></tr></tbody> |
| 597 |
<thead><tr><td>yaml configuration</td></tr></thead> |
| 598 |
<tbody><tr><td> |
| 599 |
|
| 600 |
```yaml |
| 601 |
oauth2: |
| 602 |
issuer: "https://<your-org>.okta.com" |
| 603 |
client: |
| 604 |
id: "<client_id>" |
| 605 |
secret: "<client_secret>" |
| 606 |
``` |
| 607 |
</td></tr></tbody> |
| 608 |
</table> |
| 609 |
|
| 610 |
### Restrict auth to specific groups in your directory. (optional) |
| 611 |
|
| 612 |
Restricting access through the **Assignments** tab of the Okta application is preferred. |
| 613 |
Okta denies the login itself, and users get a notice from Okta that the application isn't assigned to them. |
| 614 |
|
| 615 |
Reference: https://help.okta.com/en-us/content/topics/provisioning/lcm/lcm-assign-app-groups.htm |
| 616 |
|
| 617 |
### Non-interactive session refresh (optional) |
| 618 |
|
| 619 |
The refresh token grant enabled during the registration above is required for |
| 620 |
[non-interactive session refresh](Non-interactive%20session%20refresh.md). |
| 621 |
|
| 622 |
Keep `oauth2.refresh.expires` aligned with the `auth-gen-token` lifetime of your OpenVPN server configuration. |
| 623 |
|
| 624 |
</details> |
| 625 |
|
| 626 |
## Ping Identity |
| 627 |
|
| 628 |
Contributions for Ping Identity are welcome. Please open an issue, or a pull request if you want to add documentation for Ping Identity. |
| 629 |
|
| 630 |
## OneLogin |
| 631 |
|
| 632 |
Contributions for OneLogin are welcome. Please open an issue, or a pull request if you want to add documentation for OneLogin. |