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
+233-2Lines changed: 233 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,10 +18,220 @@ Learn how to configure F5 NGINXaaS for Azure with OpenID Connect (OIDC) authenti
18
18
19
19
2. Enable [Runtime State Sharing]({{< ref "/nginxaas-azure/quickstart/runtime-state-sharing.md" >}}) on the NGINXaaS deployment.
20
20
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.
21
+
These prerequisites are used for both methods of configuring NGINXaaS for Azure with IdP using Native OIDC and NJS.
22
22
23
+
There are currently two methods available for setting up OIDC authentication.
23
24
24
-
## Configure NGINXaaS for Azure with IdP
25
+
1. Using Native OIDC implementation (Introduced from NGINX Plus R35)
26
+
27
+
This method applies to NGINX Plus Release 35 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.
28
+
29
+
2. Using NJS based implementation
30
+
31
+
## Configure NGINXaaS for Azure with IdP using Native OIDC
32
+
33
+
### Prerequisites
34
+
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.
35
+
2. 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.
36
+
37
+
With your IdP configured, you can enable OIDC on NGINXaaS for Azure.
38
+
39
+
1. Ensure that you have the values of the **Client ID**, **Client Secret**, and **Tenant ID** obtained during IdP configuration.
40
+
41
+
2. 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:
42
+
43
+
```nginx
44
+
http {
45
+
resolver 127.0.0.1:49153 ipv4=on valid=300s;
46
+
47
+
# ...
48
+
}
49
+
```
50
+
51
+
3. 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
75
+
- `<client_secret>` is your client secret from Entra ID
76
+
- `<nginxaas_deployment_fqdn>` is your NGINXaaS deployment FQDN
77
+
78
+
{{< 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 >}}
79
+
80
+
4. Configure your server block with OIDC protection. This example uses localhost as the upstream server:
81
+
82
+
```nginx
83
+
server {
84
+
listen 443 ssl;
85
+
server_name <nginxaas_deployment_fqdn>;
86
+
87
+
ssl_certificate /etc/ssl/certs/fullchain.pem;
88
+
ssl_certificate_key /etc/ssl/private/key.pem;
89
+
90
+
location / {
91
+
# Protect this location with OIDC
92
+
auth_oidc entra;
93
+
94
+
# Forward OIDC claims as headers
95
+
proxy_set_header sub $oidc_claim_sub;
96
+
proxy_set_header email $oidc_claim_email;
97
+
proxy_set_header name $oidc_claim_name;
98
+
99
+
proxy_pass http://127.0.0.1:8080;
100
+
}
101
+
102
+
location /post_logout/ {
103
+
return 200 "You have been logged out.\n";
104
+
default_type text/plain;
105
+
}
106
+
}
107
+
108
+
server {
109
+
# Simple test upstream server
110
+
listen 8080;
111
+
location / {
112
+
return 200 "Hello, $http_name!\nEmail: $http_email\nEntra ID sub: $http_sub\n";
113
+
default_type text/plain;
114
+
}
115
+
}
116
+
```
117
+
118
+
5. Add the runtime state sharing configuration to your NGINX configuration as mentioned in the [Prerequisites](#prerequisites). This enables synchronization of OIDC session data across NGINXaaS instances:
6. Upload the NGINX configurations. See [Upload an NGINX configuration]({{< ref "/nginxaas-azure/getting-started/nginx-configuration/" >}}) for more details.
212
+
For more detailed steps on this OIDC configuration, please refer to:
213
+
214
+
- [Single Sign-On with Microsoft Entra ID]({{< ref "/nginx/deployment-guides/single-sign-on/entra-id.md" >}})
215
+
- [Terraform snippets for Native OIDC use case](https://github.com/nginxinc/nginxaas-for-azure-snippets/tree/main/terraform/configurations/native-oidc)
216
+
### Testing
217
+
218
+
1. Open `https://<nginxaas_deployment_fqdn>/` in a browser. You will be automatically redirected to your IdP sign-in page.
219
+
220
+
2. 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:
221
+
222
+
```text
223
+
Hello, [Name]!
224
+
Email: [email]
225
+
Entra ID sub: [subject_id]
226
+
```
227
+
228
+
3. 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.
229
+
230
+
231
+
232
+
## Configure NGINXaaS for Azure with IdP using NJS
233
+
### Prerequisites
234
+
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
235
26
236
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
237
@@ -164,10 +374,31 @@ Configuring NGINXaaS for Azure with OIDC is similar as [Configuring NGINX Plus](
164
374
This is a site protected by OIDC!
165
375
```
166
376
377
+
## Limitations of Native OIDC vs NJS
378
+
379
+
The Native OIDC implementation has the following limitations compared to the NJS-based implementation:
380
+
381
+
- Proof Key for Code Exchange (PKCE) Support
382
+
- Front-Channel Logout
383
+
- Back-Channel Logout
384
+
385
+
These features will be added in future releases.
386
+
387
+
167
388
## Troubleshooting
168
389
169
390
[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
391
171
392
## Monitoring
172
393
173
394
[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