File tree Expand file tree Collapse file tree 6 files changed +55
-12
lines changed
terraform/configurations/native-oidc Expand file tree Collapse file tree 6 files changed +55
-12
lines changed Original file line number Diff line number Diff line change @@ -37,13 +37,14 @@ terraform destroy --auto-approve
37
37
## Notes
38
38
39
39
- The deployment uses a self-signed certificate for demonstration. For production, use a certificate issued by a trusted CA.
40
- - OIDC configuration requires NGINX Plus R34 or later.
40
+ - Native OIDC configuration requires NGINX Plus R35 or later.
41
41
- For more details on how to configure the OIDC in NGINXaaS, please refer to the references below
42
42
- https://docs.nginx.com/nginx/deployment-guides/single-sign-on/entra-id/
43
43
- https://docs.nginx.com/nginxaas/azure/quickstart/runtime-state-sharing/
44
44
- https://docs.nginx.com/nginx/releases/#r34
45
45
- https://community.f5.com/kb/technicalarticles/f5-nginx-plus-r34-release-now-available/340300
46
46
- https://nginx.org/en/docs/http/ngx_http_oidc_module.html
47
47
- https://docs.nginx.com/nginxaas/azure/getting-started/ssl-tls-certificates/
48
+ - https://community.f5.com/kb/technicalarticles/f5-nginx-plus-r35-release-now-available/342962
48
49
49
50
Original file line number Diff line number Diff line change @@ -92,10 +92,18 @@ resource "azurerm_role_assignment" "example" {
92
92
93
93
locals {
94
94
nginx_config = templatefile (" ${ path . module } /nginx.conf.tpl" , {
95
- issuer = var.issuer
96
- client_id = var.client_id
97
- client_secret = var.client_secret
98
- resolver = var.resolver
95
+ resolver = var.resolver
96
+ })
97
+
98
+ # Use provided post_logout_uri if specified, otherwise auto-generate using IP address
99
+ effective_post_logout_uri = var. post_logout_uri != " " ? var. post_logout_uri : " https://${ azurerm_nginx_deployment . example . ip_address } /post_logout/"
100
+
101
+ # Protected OIDC provider configuration with sensitive client secret
102
+ oidc_provider_config = templatefile (" ${ path . module } /oidc-secrets.conf.tpl" , {
103
+ issuer = var.issuer
104
+ client_id = var.client_id
105
+ client_secret = var.client_secret
106
+ post_logout_uri = local.effective_post_logout_uri
99
107
})
100
108
}
101
109
@@ -143,6 +151,12 @@ resource "azurerm_nginx_configuration" "example" {
143
151
virtual_path = " /etc/nginx/nginx.conf"
144
152
}
145
153
154
+ # Protected configuration file containing the entire OIDC provider block
155
+ protected_file {
156
+ content = base64encode (local. oidc_provider_config )
157
+ virtual_path = " /etc/nginx/oidc-provider.conf"
158
+ }
159
+
146
160
depends_on = [
147
161
azurerm_nginx_certificate . example
148
162
]
Original file line number Diff line number Diff line change 3
3
resolver ${resolver} ipv4=on ipv6=off valid=300s;
4
4
keyval_zone zone=oidc:8M state=/opt/oidc_id_tokens.json timeout=1h sync;
5
5
6
- oidc_provider entra {
7
- # issuer URL, client_id, client_secret values are obtained from IdP configuration (microsoft entra id in this example)
8
- issuer ${issuer} ;
9
- client_id ${ client_id} ;
10
- client_secret ${ client_secret} ;
11
- session_store oidc;
12
- }
6
+ # Include OIDC provider configuration from protected file
7
+ include /etc/nginx/oidc-provider.conf;
13
8
server {
14
9
listen 443 ssl;
15
10
server_name demo.example.com;
@@ -24,6 +19,14 @@ http {
24
19
25
20
proxy_pass http://127.0.0.1:8080;
26
21
}
22
+
23
+ # Post-logout endpoint - this example uses /post_logout/
24
+ # You can change this path or customize the response as needed
25
+ # Make sure to update the post_logout_uri variable accordingly
26
+ location /post_logout/ {
27
+ return 200 " You have been logged out.\n " ;
28
+ default_type text/plain;
29
+ }
27
30
}
28
31
29
32
server {
Original file line number Diff line number Diff line change
1
+ # OIDC provider configuration with sensitive information
2
+ # This file contains sensitive information and should be protected
3
+
4
+ oidc_provider entra {
5
+ # issuer URL, client_id, client_secret values are obtained from IdP configuration (microsoft entra id in this example)
6
+ issuer ${issuer} ;
7
+ client_id ${ client_id} ;
8
+ client_secret ${ client_secret} ;
9
+ session_store oidc;
10
+ logout_uri /logout;
11
+ post_logout_uri ${ post_logout_uri} ;
12
+ logout_token_hint on;
13
+ userinfo on;
14
+ }
Original file line number Diff line number Diff line change 1
1
output "ip_address" {
2
2
description = " IP address of NGINXaaS deployment."
3
3
value = azurerm_nginx_deployment. example . ip_address
4
+ }
5
+
6
+ output "post_logout_uri" {
7
+ description = " Post logout URI configured in OIDC provider."
8
+ value = local. effective_post_logout_uri
4
9
}
Original file line number Diff line number Diff line change @@ -46,4 +46,10 @@ variable "client_secret" {
46
46
variable "resolver" {
47
47
description = " OIDC resolver"
48
48
type = string
49
+ }
50
+
51
+ variable "post_logout_uri" {
52
+ description = " OIDC post logout uri. If not provided, will default to https://IP_ADDRESS/post_logout/ (matching the example configuration). You can change this to match your custom logout endpoint."
53
+ type = string
54
+ default = " " # Empty string means use auto-generated URI with /post_logout/ path
49
55
}
You can’t perform that action at this time.
0 commit comments