Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
nginx
GitHub Repository: nginx/nginx.org
Path: blob/main/xml/en/docs/http/ngx_http_oidc_module.xml
1 views
1
<?xml version="1.0"?>
2
3
<!--
4
Copyright (C) Nginx, Inc.
5
-->
6
7
<!DOCTYPE module SYSTEM "../../../../dtd/module.dtd">
8
9
<module name="Module ngx_http_oidc_module"
10
link="/en/docs/http/ngx_http_oidc_module.html"
11
lang="en"
12
rev="1">
13
14
<section id="summary">
15
16
<para>
17
The <literal>ngx_http_oidc_module</literal> module (1.27.4)
18
implements authentication as a Relying Party in OpenID Connect using the
19
<link url="https://openid.net/specs/openid-connect-core-1_0.html#CodeFlowAuth">
20
Authorization Code Flow</link>.
21
</para>
22
23
<para>
24
The module expects the OpenID Provider's configuration to be available via
25
<link url="https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfig">
26
metadata</link> and requires dynamic
27
<link doc="ngx_http_core_module.xml" id="resolver">resolver</link>.
28
</para>
29
30
<para>
31
The module can be combined with other access modules
32
via the <link doc="ngx_http_core_module.xml" id="satisfy"/> directive.
33
Note that the module may still block requests even with
34
<literal>satisfy any;</literal>
35
as an OpenID Provider might not redirect the user back to nginx.
36
</para>
37
38
<para>
39
<note>
40
This module is available as part of our
41
<commercial_version>commercial subscription</commercial_version>.
42
</note>
43
</para>
44
45
</section>
46
47
48
<section id="example" name="Example Configuration">
49
50
<para>
51
<example>
52
http {
53
resolver 10.0.0.1;
54
55
oidc_provider my_idp {
56
issuer "https://provider.domain";
57
client_id "unique_id";
58
client_secret "unique_secret";
59
}
60
61
server {
62
location / {
63
auth_oidc my_idp;
64
65
proxy_set_header username $oidc_claim_sub;
66
proxy_pass http://backend;
67
}
68
}
69
}
70
</example>
71
The example assumes that the
72
<literal>https://&lt;nginx-host&gt;/oidc_callback</literal>
73
Redirection URI is configured on the OpenID Provider's side.
74
The path can be customized with the <link id="redirect_uri"/> directive.
75
</para>
76
77
</section>
78
79
80
<section id="directives" name="Directives">
81
82
<directive name="oidc_provider">
83
<syntax block="yes"><value>name</value></syntax>
84
<default/>
85
<context>http</context>
86
87
<para>
88
Defines an OpenID Provider for use with the <link id="auth_oidc"/> directive.
89
</para>
90
91
</directive>
92
93
94
<directive name="auth_oidc">
95
<syntax><value>name</value> | <literal>off</literal></syntax>
96
<default>off</default>
97
<context>http</context>
98
<context>server</context>
99
<context>location</context>
100
101
<para>
102
Enables end user authentication with the
103
<link id="oidc_provider">specified</link> OpenID Provider.
104
</para>
105
106
<para>
107
Parameter value can contain variables (1.29.0).
108
</para>
109
110
<para>
111
The special value <literal>off</literal> cancels the effect
112
of the <literal>auth_oidc</literal> directive
113
inherited from the previous configuration level.
114
</para>
115
116
</directive>
117
118
119
<directive name="issuer">
120
<syntax><value>URL</value></syntax>
121
<default/>
122
<context>oidc_provider</context>
123
124
<para>
125
Sets the Issuer Identifier URL of the OpenID Provider;
126
required directive.
127
The URL must exactly match the value of “<literal>issuer</literal>
128
in the OpenID Provider metadata
129
and requires the “<literal>https</literal>” scheme.
130
</para>
131
132
</directive>
133
134
135
<directive name="client_id">
136
<syntax><value>string</value></syntax>
137
<default/>
138
<context>oidc_provider</context>
139
140
<para>
141
Specifies the client ID of the Relying Party;
142
required directive.
143
</para>
144
145
</directive>
146
147
148
<directive name="client_secret">
149
<syntax><value>string</value></syntax>
150
<default/>
151
<context>oidc_provider</context>
152
153
<para>
154
Specifies a secret value
155
used to authenticate the Relying Party with the OpenID Provider.
156
The supported
157
<link url="https://openid.net/specs/openid-connect-core-1_0.html#ClientAuthentication">authentication
158
methods</link> are
159
<literal>client_secret_basic</literal> and
160
<literal>client_secret_post</literal> (1.29.3).
161
The method is selected based on the OpenID Provider metadata
162
with a preference to <literal>client_secret_basic</literal>.
163
</para>
164
165
</directive>
166
167
168
<directive name="config_url">
169
<syntax><value>URL</value></syntax>
170
<default>&lt;issuer&gt;/.well-known/openid-configuration</default>
171
<context>oidc_provider</context>
172
173
<para>
174
Sets a custom URL to retrieve the OpenID Provider metadata.
175
</para>
176
177
</directive>
178
179
180
<directive name="cookie_name">
181
<syntax><value>name</value></syntax>
182
<default>NGX_OIDC_SESSION</default>
183
<context>oidc_provider</context>
184
185
<para>
186
Sets the name of a session cookie.
187
</para>
188
189
</directive>
190
191
192
<directive name="extra_auth_args">
193
<syntax><value>string</value></syntax>
194
<default/>
195
<context>oidc_provider</context>
196
197
<para>
198
Sets additional query arguments for the
199
<link url="https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest">authentication
200
request</link> URL.
201
<example>
202
extra_auth_args "display=page&amp;prompt=login";
203
</example>
204
</para>
205
206
</directive>
207
208
209
<directive name="frontchannel_logout_uri">
210
<syntax><value>uri</value></syntax>
211
<default/>
212
<context>oidc_provider</context>
213
<appeared-in>1.29.3</appeared-in>
214
215
<para>
216
Defines the URI path for triggering
217
<link url="https://openid.net/specs/openid-connect-frontchannel-1_0.html">front-channel
218
logout</link>.
219
For the logout request to be associated with a user session,
220
it must either include the module session cookie or provide
221
both the “<literal>iss</literal>” and “<literal>sid</literal>” arguments.
222
It is recommended to configure the OpenID Provider to set the
223
<literal>iss</literal>” and “<literal>sid</literal>” arguments
224
when invoking this endpoint.
225
</para>
226
227
</directive>
228
229
230
<directive name="pkce">
231
<syntax><literal>on</literal> | <literal>off</literal></syntax>
232
<default/>
233
<context>oidc_provider</context>
234
<appeared-in>1.29.3</appeared-in>
235
236
<para>
237
Explicitly enables or disables PKCE.
238
By default, PKCE is automatically enabled
239
based on OpenID Provider metadata.
240
</para>
241
242
</directive>
243
244
245
<directive name="redirect_uri">
246
<syntax><value>uri</value></syntax>
247
<default>/oidc_callback</default>
248
<context>oidc_provider</context>
249
250
<para>
251
Defines the Redirection URI path for post-authentication redirects
252
expected by the module from the OpenID Provider.
253
The <value>uri</value> must match the configuration on the Provider's side.
254
</para>
255
256
<para>
257
Absolute “<literal>https</literal>” URIs are supported since 1.29.0.
258
</para>
259
260
</directive>
261
262
263
<directive name="logout_uri">
264
<syntax><value>uri</value></syntax>
265
<default/>
266
<context>oidc_provider</context>
267
<appeared-in>1.29.0</appeared-in>
268
269
<para>
270
Defines the URI path for initiating session logout.
271
Upon session termination, the user is redirected to
272
<link url="https://openid.net/specs/openid-connect-rpinitiated-1_0.html#OPMetadata">Provider's
273
Logout Endpoint</link>
274
or to the <link id="post_logout_uri">post logout page</link>.
275
If neither is configured, the built-in post logout page is displayed.
276
</para>
277
278
</directive>
279
280
281
<directive name="post_logout_uri">
282
<syntax><value>uri</value></syntax>
283
<default/>
284
<context>oidc_provider</context>
285
<appeared-in>1.29.0</appeared-in>
286
287
<para>
288
Defines the path or absolute URI
289
to redirect the user to after the logout.
290
The <value>uri</value> must match the configuration on the Provider's side.
291
If the post logout page is served by NGINX,
292
the OIDC module shouldn't be enabled for this location:
293
<example>
294
http {
295
oidc_provider my_idp {
296
...
297
298
logout_uri /logout;
299
post_logout_uri /logged_out_page.html;
300
}
301
302
server {
303
auth_oidc my_idp;
304
305
location /logged_out_page.html {
306
auth_oidc off;
307
}
308
}
309
}
310
</example>
311
</para>
312
313
</directive>
314
315
<directive name="logout_token_hint">
316
<syntax><literal>on</literal> | <literal>off</literal></syntax>
317
<default>off</default>
318
<context>oidc_provider</context>
319
<appeared-in>1.29.0</appeared-in>
320
321
<para>
322
Adds the
323
<link url="https://openid.net/specs/openid-connect-rpinitiated-1_0.html#RPLogout"><literal>id_token_hint</literal></link>
324
argument to the
325
<link url="https://openid.net/specs/openid-connect-rpinitiated-1_0.html#OPMetadata">Provider's
326
Logout Endpoint</link>
327
when redirecting user during logout.
328
This argument can be required by some OpenID Providers.
329
</para>
330
331
</directive>
332
333
334
<directive name="scope">
335
<syntax><value>scope</value> ...</syntax>
336
<default>openid</default>
337
<context>oidc_provider</context>
338
339
<para>
340
Sets requested scopes.
341
The <literal>openid</literal> scope is always required by OIDC.
342
</para>
343
344
</directive>
345
346
347
<directive name="session_store">
348
<syntax><value>name</value></syntax>
349
<default/>
350
<context>oidc_provider</context>
351
352
<para>
353
Specifies a custom
354
<link doc="ngx_http_keyval_module.xml" id="keyval_zone">key-value database</link>
355
that stores session data.
356
By default, an 8-megabyte key-value database named
357
<literal>oidc_default_store_&lt;provider name&gt;</literal>
358
is created automatically.
359
<note>
360
A separate key-value database should be configured for each Provider
361
to prevent session reuse across providers.
362
</note>
363
</para>
364
365
</directive>
366
367
368
<directive name="session_timeout">
369
<syntax><value>time</value></syntax>
370
<default>8h</default>
371
<context>oidc_provider</context>
372
373
<para>
374
Sets a timeout after which the session is deleted, unless it was
375
<link url="https://openid.net/specs/openid-connect-core-1_0.html#RefreshTokens">refreshed</link>.
376
</para>
377
378
</directive>
379
380
381
<directive name="ssl_crl">
382
<syntax><value>file</value></syntax>
383
<default/>
384
<context>oidc_provider</context>
385
386
<para>
387
Specifies a <value>file</value> with revoked certificates (CRL)
388
in the PEM format used to verify
389
the certificates of the OpenID Provider endpoints.
390
When using intermediate certificates, their CRLs should be
391
specified in the same file.
392
</para>
393
394
</directive>
395
396
397
<directive name="ssl_trusted_certificate">
398
<syntax><value>file</value></syntax>
399
<default>system CA bundle</default>
400
<context>oidc_provider</context>
401
402
<para>
403
Specifies a <value>file</value> with trusted CA certificates in the PEM format
404
used to verify
405
the certificates of the OpenID Provider endpoints.
406
</para>
407
408
</directive>
409
410
411
<directive name="userinfo">
412
<syntax><literal>on</literal> | <literal>off</literal></syntax>
413
<default>off</default>
414
<context>oidc_provider</context>
415
<appeared-in>1.29.0</appeared-in>
416
417
<para>
418
Enables downloading of the
419
<link url="https://openid.net/specs/openid-connect-core-1_0.html#UserInfo">UserInfo</link>
420
data and makes UserInfo claims available via the
421
<link id="var_oidc_claim_">$oidc_claim_<literal>name</literal></link> variables.
422
</para>
423
424
</directive>
425
426
</section>
427
428
429
<section id="variables" name="Embedded Variables">
430
431
<para>
432
The <literal>ngx_http_oidc_module</literal> module supports embedded variables:
433
</para>
434
435
<para>
436
<list type="tag" compact="yes">
437
438
<tag-name id="var_oidc_id_token"><var>$oidc_id_token</var></tag-name>
439
<tag-desc>
440
ID token
441
</tag-desc>
442
443
<tag-name id="var_oidc_access_token"><var>$oidc_access_token</var></tag-name>
444
<tag-desc>
445
access token
446
</tag-desc>
447
448
<tag-name id="var_oidc_claim_"><var>$oidc_claim_</var><value>name</value></tag-name>
449
<tag-desc>
450
top-level ID token or UserInfo claim
451
<para>
452
Nested claims can be fetched with the
453
<link doc="ngx_http_auth_jwt_module.xml">auth_jwt</link> module:
454
<example>
455
http {
456
auth_jwt_claim_set $postal_code address postal_code;
457
458
server {
459
location / {
460
auth_oidc my_idp;
461
auth_jwt off token=$oidc_id_token;
462
463
proxy_set_header x-postal_code $postal_code;
464
proxy_pass http://backend;
465
}
466
}
467
}
468
</example>
469
</para>
470
471
</tag-desc>
472
473
<tag-name id="var_oidc_userinfo"><var>$oidc_userinfo</var></tag-name>
474
<tag-desc>
475
UserInfo data in the JSON format (1.29.0)
476
</tag-desc>
477
478
</list>
479
</para>
480
481
</section>
482
483
</module>
484
485