-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathoidc_idp.conf
177 lines (141 loc) · 6.39 KB
/
oidc_idp.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# ---------------------------------------------------------------------------- #
# #
# IDP Configuration for OpenID Connect #
# (within http block) | #
# | #
# http { | #
# : | #
# +--------------------------+ | #
# | include "oidc_idp.conf"; | <--+ #
# +--------------------------+ #
# : #
# server { #
# : #
# } #
# : #
# } #
# #
# - This file is to configure IDP related info to handle OIDC workflow. #
# - Each map block allows multi values so that multiple IdPs can be supported. #
# #
# ---------------------------------------------------------------------------- #
# ---------------------------------------------------------------------------- #
# 1. OpenID Provider(IDP) Metadata Configuration via Well-Known Endpoints #
# ---------------------------------------------------------------------------- #
map $x_client_id $oidc_app_identifier {
#
# This OIDC app identifier should be unique for every IdP app.
# It doesn't have to be same as the name of IdP's application.
# This is to support multiple IdP apps per each host.
#
default "{edit-your-idp-app-name}";
"{edit-unique-client-id-azure-ad-app-01}" "oidc-app-01-pkce-azure-ad";
"{edit-unique-client-id-azure-ad-app-02}" "oidc-app-02-auth-azure-ad";
}
# curl https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration | python -m json.tool
map $oidc_app_identifier $idp_region {
default "{{edit-IdP-Region}}"; # use for Amazon (e.g., "us-east-2")
}
map $oidc_app_identifier $idp_domain {
default "login.microsoftonline.com"; # "{{Edit-IdP-Domain}}";
}
map $oidc_app_identifier $idp_user_pool_id {
default "{{edit-User-Pool-ID}}"; # use for Amazon Cognito
}
map $oidc_app_identifier $idp_tenant_id {
default "{{edit-Directory (tenant) ID}}"; # use for Azure AD
}
map $oidc_app_identifier $oidc_authz_endpoint {
default "https://$idp_domain/$idp_tenant_id/oauth2/v2.0/authorize";
}
map $oidc_app_identifier $oidc_jwt_keyfile {
default "https://$idp_domain/$idp_tenant_id/discovery/keys";
}
map $oidc_app_identifier $oidc_end_session_endpoint {
default "https://$idp_domain/$idp_tenant_id/oauth2/v2.0/logout";
}
map $oidc_app_identifier $oidc_token_endpoint {
default "https://$idp_domain/$idp_tenant_id/oauth2/v2.0/token";
}
# https://learn.microsoft.com/en-us/azure/active-directory/develop/userinfo
map $oidc_app_identifier $oidc_userinfo_endpoint {
default "https://graph.microsoft.com/oidc/userinfo";
}
map $oidc_app_identifier $oidc_scopes {
# work for access token validation for resource server, doesn't work for userinfo endpoint
# 'nonce' is excluded in the access token so we can validate the signature by /jwks_uri.
# default "openid+profile+email+offline_access+478bbf72-65c1-4878-9f5f-26c6af843a4f/.default";
# work for userinfo endpoint, doesn't work for acess token validation w/ jwks_uri
# because 'nonce' is included in the access token.
# default "openid+profile+email+offline_access+user.read";
default "openid+profile+email+offline_access";
}
# ---------------------------------------------------------------------------- #
# 2. Custom Configuration for Well-Known OIDC Endpoints #
# ---------------------------------------------------------------------------- #
map $oidc_app_identifier $oidc_authz_path_params_enable {
default 0;
}
map $oidc_app_identifier $oidc_authz_path_params {
default "";
}
map $oidc_app_identifier $oidc_authz_query_params_enable {
default 1;
}
map $oidc_app_identifier $oidc_authz_query_params {
default '{
"audience": "https://$idp_domain/$idp_tenant_id"
}';
# TODO: Test and find the right audience for /jwks_uri and /userinfo
# e.g., "AzureADMyOrg"
# "$oidc_client"
# "https://$idp_domain/$idp_tenant_id"
}
map $oidc_app_identifier $oidc_logout_path_params_enable {
default 0;
}
map $oidc_app_identifier $oidc_logout_path_params {
default "";
}
map $oidc_app_identifier $oidc_logout_query_params_enable {
default 0; # 0: OIDC RP-initiated logout, 1: custom logout
}
map $oidc_app_identifier $oidc_logout_query_params {
default '';
}
map $oidc_app_identifier $oidc_token_path_params_enable {
default 0;
}
map $oidc_app_identifier $oidc_token_path_params {
default "";
}
map $oidc_app_identifier $oidc_token_query_params_enable {
default 1;
}
map $oidc_app_identifier $oidc_token_query_params {
default '{
"Accept-Encoding": "gzip"
}';
}
# ---------------------------------------------------------------------------- #
# 3. Advanced OIDC Configuration #
# ---------------------------------------------------------------------------- #
map $oidc_app_identifier $oidc_client {
default "{{edit-your-client-ID}}";
}
map $oidc_app_identifier $oidc_pkce_enable {
default 0;
}
map $oidc_app_identifier $oidc_client_secret {
default "{edit-your-client-secret-unless-pkce-enabled}";
}
map $oidc_app_identifier $oidc_logout_redirect {
default "/_logout"; # This is called by IdP after successful logout.
}
map $oidc_app_identifier $oidc_hmac_key {
default "ChangeMe"; # This should be unique for every NGINX instance/cluster
}
map $oidc_app_identifier $oidc_app_name {
default "{edit-your-idp-app-name}";
}
# vim: syntax=nginx