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: content/nginxaas-azure/quickstart/security-controls/oidc.md
+241-2Lines changed: 241 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,16 +12,232 @@ type:
12
12
13
13
Learn how to configure F5 NGINXaaS for Azure with OpenID Connect (OIDC) authentication.
14
14
15
+
There are currently two methods available for setting up OIDC authentication.
16
+
17
+
1. Using Native OIDC implementation (Introduced from NGINX Plus R34)
18
+
19
+
2. Using NJS based implementation
20
+
15
21
## Prerequisites
16
22
23
+
These prerequisites are used for both methods of configuring NGINXaaS for Azure with IdP using Native OIDC and NJS.
24
+
17
25
1. Configure an NGINXaaS deployment with [SSL/TLS certificates]({{< ref "/nginxaas-azure/getting-started/ssl-tls-certificates/" >}}).
18
26
19
27
2. Enable [Runtime State Sharing]({{< ref "/nginxaas-azure/quickstart/runtime-state-sharing.md" >}}) on the NGINXaaS deployment.
20
28
21
-
3.[Configure the IdP](https://github.com/nginxinc/nginx-openid-connect/blob/main/README.md#configuring-your-idp). For example, you can [register a Microsoft Entra Web application](https://learn.microsoft.com/en-us/entra/identity-platform/quickstart-register-app) as the IdP.
29
+
30
+
## Configure NGINXaaS for Azure with IdP using Native OIDC
31
+
32
+
This method applies to NGINX Plus Release 34 and later. In earlier versions, NGINX Plus relied on an njs-based solution, which required NGINX JavaScript files, key-value stores, and advanced OpenID Connect logic. In the latest NGINX Plus version, the new [OpenID Connect module](https://nginx.org/en/docs/http/ngx_http_oidc_module.html) simplifies this process to just a few directives.
33
+
34
+
### Prerequisites
35
+
36
+
1. Configure the IdP. For example, you can [register a Microsoft Entra Web application]({{< ref "/nginx/deployment-guides/single-sign-on/entra-id/#entra-setup" >}}) as the IdP.
37
+
1. A domain name pointing to your NGINXaaS deployment, for example, `demo.example.com`. This will be referred to as `<nginxaas_deployment_fqdn>` throughout this guide.
38
+
39
+
With your IdP configured, you can enable OIDC on NGINXaaS for Azure.
40
+
41
+
1. Ensure that you have the values of the **Client ID**, **Client Secret**, and **Tenant ID** obtained during IdP configuration.
42
+
43
+
1. In your NGINX configuration file, add a public DNS resolver with the [`resolver`](https://nginx.org/en/docs/http/ngx_http_core_module.html#resolver) directive in the [`http {}`](https://nginx.org/en/docs/http/ngx_http_core_module.html#http) context:
44
+
45
+
```nginx
46
+
http {
47
+
resolver 127.0.0.1:49153 ipv4=on valid=300s;
48
+
49
+
# ...
50
+
}
51
+
```
52
+
53
+
1. In the [`http {}`](https://nginx.org/en/docs/http/ngx_http_core_module.html#http) context, define your IdP provider by specifying the [`oidc_provider {}`](https://nginx.org/en/docs/http/ngx_http_oidc_module.html#oidc_provider) context. The `session_store` directive stores the session data and we need `keyval_zone` to sync this data in a clustered environment. Include the `state` parameter to persist session data across NGINX restarts. For example, for Microsoft Entra ID:
- `<client_id>` is your Application (client) ID from Entra ID
77
+
- `<client_secret>` is your client secret from Entra ID
78
+
- `<nginxaas_deployment_fqdn>` is your NGINXaaS deployment FQDN
79
+
80
+
{{< call-out "note" >}} The `state=/opt/oidc_sessions.json` parameter enables persistence of OIDC session data across NGINX restarts. The state file path must be placed in a directory accessible to the NGINX worker processes, following [NGINX Filesystem Restrictions]({{< ref "/nginxaas-azure/getting-started/nginx-configuration/overview/#nginx-filesystem-restrictions" >}}).{{< /call-out >}}
81
+
82
+
1. Configure your server block with OIDC protection. The following example uses localhost as the upstream server:
83
+
84
+
```nginx
85
+
server {
86
+
listen 443 ssl;
87
+
server_name <nginxaas_deployment_fqdn>;
88
+
89
+
ssl_certificate /etc/ssl/certs/fullchain.pem;
90
+
ssl_certificate_key /etc/ssl/private/key.pem;
91
+
92
+
location / {
93
+
# Protect this location with OIDC
94
+
auth_oidc entra;
95
+
96
+
# Forward OIDC claims as headers
97
+
proxy_set_header sub $oidc_claim_sub;
98
+
proxy_set_header email $oidc_claim_email;
99
+
proxy_set_header name $oidc_claim_name;
100
+
101
+
proxy_pass http://127.0.0.1:8080;
102
+
}
103
+
104
+
location /post_logout/ {
105
+
return 200 "You have been logged out.\n";
106
+
default_type text/plain;
107
+
}
108
+
}
109
+
110
+
server {
111
+
# Simple test upstream server
112
+
listen 8080;
113
+
location / {
114
+
return 200 "Hello, $http_name!\nEmail: $http_email\nEntra ID sub: $http_sub\n";
115
+
default_type text/plain;
116
+
}
117
+
}
118
+
```
119
+
120
+
1. Add the runtime state sharing configuration to your NGINX configuration as mentioned in the [Prerequisites]({{< ref "/nginxaas-azure/quickstart/security-controls/oidc.md#prerequisites" >}}). This enables synchronization of OIDC session data across NGINXaaS instances:
1. Upload the NGINX configurations. See [Upload an NGINX configuration]({{< ref "/nginxaas-azure/getting-started/nginx-configuration/" >}}) for more details.
214
+
215
+
For more detailed steps on this OIDC configuration, please refer to:
216
+
217
+
- [Single Sign-On with Microsoft Entra ID]({{< ref "/nginx/deployment-guides/single-sign-on/entra-id.md" >}})
218
+
- [Terraform snippets for Native OIDC use case](https://github.com/nginxinc/nginxaas-for-azure-snippets/tree/main/terraform/configurations/native-oidc)
219
+
220
+
### Testing
221
+
222
+
1. Open `https://<nginxaas_deployment_fqdn>/` in a browser. You will be automatically redirected to your IdP sign-in page.
223
+
224
+
1. Enter valid IdP credentials. Upon successful sign-in, you will be redirected back to NGINXaaS and see your protected application. Using the example configuration, you will see a message displaying the authenticated user's information in the browser:
225
+
226
+
```text
227
+
Hello, [Name]!
228
+
Email: [email]
229
+
Entra ID sub: [subject_id]
230
+
```
231
+
232
+
1. To test logout, navigate to `https://<nginxaas_deployment_fqdn>/logout`. NGINXaaS initiates an RP-initiated logout, and your IdP ends the session and redirects back to the post-logout page.
22
233
23
234
24
-
## Configure NGINXaaS for Azure with IdP
235
+
236
+
## Configure NGINXaaS for Azure with IdP using NJS
237
+
238
+
### Prerequisites
239
+
240
+
1. [Configure the IdP](https://github.com/nginxinc/nginx-openid-connect/blob/main/README.md#configuring-your-idp). For example, you can [register a Microsoft Entra Web application](https://learn.microsoft.com/en-us/entra/identity-platform/quickstart-register-app) as the IdP.
25
241
26
242
Configuring NGINXaaS for Azure with OIDC is similar as [Configuring NGINX Plus](https://github.com/nginxinc/nginx-openid-connect/blob/main/README.md#configuring-nginx-plus) in [nginx-openid-connect](https://github.com/nginxinc/nginx-openid-connect) but it also has its own specific configurations that must be completed to work normally.
27
243
@@ -164,10 +380,33 @@ Configuring NGINXaaS for Azure with OIDC is similar as [Configuring NGINX Plus](
164
380
This is a site protected by OIDC!
165
381
```
166
382
383
+
## Limitations of Native OIDC vs NJS
384
+
385
+
The Native OIDC implementation has the following limitations compared to the NJS-based implementation:
386
+
387
+
- Proof Key for Code Exchange (PKCE) Support
388
+
- Front-Channel Logout
389
+
- Back-Channel Logout
390
+
391
+
These features will be added in future releases.
392
+
393
+
167
394
## Troubleshooting
168
395
169
396
[Enable NGINX logs]({{< ref "/nginxaas-azure/monitoring/enable-logging/" >}}) and [Troubleshooting](https://github.com/nginxinc/nginx-openid-connect/tree/main?tab=readme-ov-file#troubleshooting) the OIDC issues.
170
397
171
398
## Monitoring
172
399
173
400
[Enable monitoring]({{< ref "/nginxaas-azure/monitoring/enable-monitoring.md" >}}), check [real time monitoring](https://github.com/nginxinc/nginx-openid-connect/blob/main/README.md#real-time-monitoring) to see how OIDC metrics are collected, and use "plus.http.*" metrics filtered with location_zone dimension in [NGINX requests and response statistics]({{< ref "/nginxaas-azure/monitoring/metrics-catalog.md#nginx-requests-and-response-statistics" >}}) to check the OIDC metrics.
0 commit comments