Debian Codegraph @

doc/sources/admin/idpopenidconnect.rst

raw
1 OpenID Connect Provider
2 =======================
3
4 Presentation
5 ------------
6
7
8 .. note::
9
10 OpenID Connect is a protocol based on REST, OAuth 2.0 and JOSE
11 stacks. It is described here: http://openid.net/connect/.
12
13 LL::NG can act as an OpenID Connect Provider (OP). It will reply to
14 OpenID Connect requests to give user identity (through ID Token) and
15 information (through UserInfo endpoint).
16
17 As an OP, LL::NG supports many OpenID Connect features:
18
19 - Authorization Code, Implicit and Hybrid flows
20 - `Publication of JSON metadata and JWKS data (Discovery) <https://openid.net/specs/openid-connect-discovery-1_0.html>`__
21 - ``prompt``, ``display``, ``ui_locales``, ``max_age`` parameters
22 - :ref:`Mapping custom scope values to non-standard claims <oidcextraclaims>`
23 - Authentication context Class References (ACR)
24 - Authentication Method References (AMR) (Since ``2.21.0``)
25 - Nonce
26 - `Dynamic registration <https://openid.net/specs/openid-connect-registration-1_0.html>`__
27 - Access Token Hash generation
28 - ID Token signature (HS256/HS384/HS512 and RS256/RS384/RS512/PS256/PS384/PS512 or ES256/ES256K/ES384/ES512/EdDSA depending on the key type)
29 - UserInfo endpoint, as JSON or as JWT
30 - Request and Request URI
31 - `Back Channel Logout <https://openid.net/specs/openid-connect-backchannel-1_0.html>`__
32 (Since ``2.17.0``)
33 - `Front Channel Logout <https://openid.net/specs/openid-connect-frontchannel-1_0.html>`__
34 - `RP-Initiated Logout <https://openid.net/specs/openid-connect-rpinitiated-1_0.html>`__
35 - PKCE (Since ``2.0.4``) - See :rfc:`7636`
36 - Introspection endpoint (Since ``2.0.6``) - See :rfc:`7662`
37 - JWT Introspection response (Since ``2.23.0``) - See :rfc:`9701`
38 - Offline access (Since ``2.0.7``)
39 - Refresh Tokens (Since ``2.0.7``)
40 - Optional JWT Access Tokens (Since ``2.0.12``) - See :rfc:`9068`
41 - `Form Post Response Mode <https://openid.net/specs/oauth-v2-form-post-response-mode-1_0.html>`__ (Since ``2.0.16``)
42 - Encrypted JWT (Since ``2.18.0``) - See :rfc:`7516`
43
44 Configuration
45 -------------
46
47 OpenID Connect Service
48 ~~~~~~~~~~~~~~~~~~~~~~
49
50 See :doc:`OpenID Connect service<openidconnectservice>` configuration
51 chapter.
52
53
54 OpenID Connect Issuer Activation
55 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
56
57 Go in ``General Parameters`` » ``Issuer modules`` » ``OpenID Connect``
58 and configure:
59
60 - **Activation**: Set to ``On``
61 - **Path**: Keep ``^/oauth2/`` unless you need to use another path
62 - **Use rule**: Rule to allow user to use this module, set to ``1``
63 to always allow
64
65
66 .. tip::
67
68 For example, to allow only users with a strong authentication
69 level:
70
71 ::
72
73 $authenticationLevel > 2
74
75
76
77 Configuration of LL::NG in Relying Party
78 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
79
80 Each Relying Party has its own configuration way. LL::NG exposes
81 its OpenID Connect metadata to help clients configuration.
82
83 Metadata can be downloaded at the standard "Well Known" URL:
84 http://auth.example.com/.well-known/openid-configuration
85
86 OIDC metadata example:
87
88 .. code-block:: javascript
89
90 {
91 "end_session_endpoint" : "http://auth.example.com/oauth2/logout",
92 "jwks_uri" : "http://auth.example.com/oauth2/jwks",
93 "token_endpoint_auth_methods_supported" : [
94 "client_secret_post",
95 "client_secret_basic"
96 ],
97 "token_endpoint" : "http://auth.example.com/oauth2/token",
98 "response_types_supported" : [
99 "code",
100 "id_token",
101 "id_token token",
102 "code id_token",
103 "code token",
104 "code id_token token"
105 ],
106 "userinfo_signing_alg_values_supported" : [
107 "none",
108 "HS256",
109 "HS384",
110 "HS512",
111 "RS256",
112 "RS384",
113 "RS512",
114 "PS256",
115 "PS384",
116 "PS512"
117 ],
118 "id_token_signing_alg_values_supported" : [
119 "none",
120 "HS256",
121 "HS384",
122 "HS512",
123 "RS256",
124 "RS384",
125 "RS512",
126 "PS256",
127 "PS384",
128 "PS512"
129 ],
130 "userinfo_endpoint" : "http://auth.example.com/oauth2/userinfo",
131 "request_uri_parameter_supported" : "true",
132 "acr_values_supported" : [
133 "loa-4",
134 "loa-1",
135 "loa-3",
136 "loa-5",
137 "loa-2"
138 ],
139 "request_parameter_supported" : "true",
140 "subject_types_supported" : [
141 "public"
142 ],
143 "issuer" : "http://auth.example.com/",
144 "grant_types_supported" : [
145 "authorization_code",
146 "implicit",
147 "hybrid"
148 ],
149 "authorization_endpoint" : "http://auth.example.com/oauth2/authorize",
150 "scopes_supported" : [
151 "openid",
152 "profile",
153 "email",
154 "address",
155 "phone"
156 ],
157 "require_request_uri_registration" : "false",
158 "registration_endpoint" : "http://auth.example.com/oauth2/register"
159 }
160
161 Configuration of Relying Party in LL::NG
162 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
163
164 Go in Manager and click on ``OpenID Connect Relying Parties``, then
165 click on ``Add OpenID Relying Party``. Set a technical name
166 (without space or special character), like “sample-rp”;
167
168 You can then set this RP configuration.
169
170 .. _oidcexportedattr:
171
172 Basic options
173 ^^^^^^^^^^^^^
174
175 - **Activation** The user can activate and deactivate a RP. By default, RPs are
176 active upon creation.
177 - **Public client** (since version ``2.0.4``): Set this RP as public
178 client, so authentication is not needed on tokens endpoint. Set this for
179 mobile apps or native Javascript apps.
180 - **Client ID**: Client ID for this RP
181 - **Client secret**: Client secret for this RP (can be used for
182 symmetric signature)
183 - **Allowed redirection addresses for login**: Space-separated list of redirect
184 addresses allowed for this RP
185
186 Exported attributes (claims)
187 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
188
189 .. versionchanged:: 2.0.16
190
191 All exported attributes are sent if **Always send exported attributes** option is enabled in **OpenID Connect Service**. In previous versions, you had to declare them in **Options**/**Scope**/**Scope Values content** too.
192
193
194 For each OpenID Connect attribute you want to expose to applications, you can define:
195
196 * **Claim name**: Name of the attribute as it will appear in Userinfo responses
197 * **Variable name**: Name of the LemonLDAP::NG session variable containing the attribute value
198 * **Type**: Attribute data type. By default, it is a string. Choosing integer or boolean will make the attribute appear as the corresponding JSON type.
199 * **Array**: Select how multi-valued attributes are processed
200
201 * **Automatic**: If the session key contains a single value, it will be released as a JSON number, string or boolean, depending on the previously specified type. If the session key contains multiple values, it will be released as an array of numbers, strings or booleans.
202 * **Always**: Return an array even if the attribute only contains one value
203 * **Never**: If the session key contains a single value, it will be released as a JSON number, string or boolean. If the session key contains multiple values, it will be released as a single string with a separator character.
204
205
206 .. attention::
207
208 The specific ``sub`` attribute is not defined here, but in ``User attribute`` parameter (see below).
209
210 Options
211 ^^^^^^^
212
213 - **Advanced**
214
215 - **Bypass consent**: Enable if you never want to display the scope
216 sharing consent screen (consent will be accepted by default).
217 Bypassing the consent is **not** compliant with OpenID Connect
218 standard.
219 - **Force claims to be returned in ID Token**: This options will
220 make user attributes from the requested scope appear as ID Token claims
221 - **Use JWT format for Access Token** (since version ``2.0.12``): When
222 using this option, Access Tokens will use the JWT format, which means they
223 can be verified by external OAuth2.0 resource servers without using the
224 Introspection or UserInfo endpoint.
225 - **Release claims in Access Token** (since version ``2.0.12``): If Access
226 Tokens are in JWT format, this option lets you release the claims defined
227 in the *Extra Claims* section inside the Access Token itself
228 - **Use refresh tokens** (since version ``2.0.7``): If this option
229 is enabled, LL::NG will issue an *online* Refresh Token that can
230 be used to obtain new access tokens as long as the user session
231 is still valid. This token is tied to the SSO session: it becomes
232 invalid when the user logs out or the session expires
233 - **User attribute**: Session field that will be used as main
234 identifier (``sub``). Default value is ``whatToTrace``.
235 - **Additional audiences** (since version ``2.0.8``): You can
236 specify a space-separated list of audiences that will be added to the
237 ID Token audiences, and possibly the access token audiences if the
238 access token format is JWT
239 - **Other RP allowed to exchange access_token** (since version ``2.20.0``):
240 You can specify a space-separated list of Relying-Party allowed to ask
241 for a token exchange. See :doc:`OpenID-Connect Token Exchange<oidctokenexchange>`
242 - **Don't insert typ header**: don't add the type header in JWT
243
244 - **Scope**
245
246 - **Scope values content**: see :ref:`oidcextraclaims` below
247 - **Scope rules**: see :ref:`oidcscoperules` below
248
249 - **Security**
250
251 - **Require PKCE** (since version ``2.0.4``): Controls PKCE validation
252 at the Authorization and Token endpoints (see :rfc:`7636`). Available modes:
253
254 - **Disabled**: PKCE is optional. If provided, it will be validated.
255 For confidential clients, ``client_secret`` is required.
256 For public clients, no authentication is required.
257 - **Required**: PKCE is mandatory. Requests without ``code_challenge``
258 are rejected at the Authorization endpoint. For confidential clients,
259 both PKCE and ``client_secret`` are required.
260 - **PKCE or Secret** (since version ``2.20.0``): For **public clients**,
261 either PKCE or ``client_secret`` is required (at least one). This allows
262 the same ``client_id`` to be used by mobile apps (with PKCE) and backend
263 services (with secret). For confidential clients, this mode behaves
264 like **Disabled** (secret always required, PKCE optional).
265 - **Invalidate refresh tokens after use** (since version ``2.20.0``): Use
266 this option to prevent Refresh Tokens from being re-used. A new refresh
267 token will be generated every time.
268 - **Allow offline access** (since version ``2.0.7``): After enabling
269 this feature, an application may request the **offline_access**
270 scope, and will obtain an *offline* Refresh Token that persists
271 even after the user has logged off. Unlike online refresh tokens,
272 offline tokens are not tied to the SSO session: they remain valid
273 until their own expiration time. See
274 https://openid.net/specs/openid-connect-core-1_0.html#OfflineAccess
275 for details. These offline sessions can be administered through
276 the Session Browser.
277
278 These two options are independent. When both are enabled, the type
279 of refresh token depends on the scope requested by the client:
280
281 - Without ``offline_access`` scope: an *online* refresh token is
282 issued (tied to the SSO session)
283 - With ``offline_access`` scope: an *offline* refresh token is
284 issued (survives logout)
285
286 If only **Allow offline access** is enabled (without **Use refresh
287 tokens**), applications will only receive a refresh token when
288 they explicitly request the ``offline_access`` scope. Without
289 that scope, no refresh token is issued.
290 - **Allow Native SSO for Mobile Apps** (since version ``2.21.0``): Allow
291 relying party to request a **device_secret**. See
292 https://openid.net/specs/openid-connect-native-sso-1_0.html for details.
293 - **Allow OAuth2.0 Password Grant** (since version ``2.0.8``): Allow the use of
294 the :ref:`Resource Owner Password Credentials Grant <resource-owner-password-grant>` by this client.
295 This feature only works if you have configured a form-based authentication module.
296 - **Allow OAuth2.0 Client Credentials Grant** (since version ``2.0.11``): Allow the use of the
297 :ref:`Client Credentials Grant <client-credentials-grant>` by this client.
298 - **Allowed URLs for fetching Request Object**: (since version ``2.17.1``):
299 which URLs may be called by the portal to fetch the request object (see
300 `request_uri
301 <https://openid.net/specs/openid-connect-core-1_0.html#RequestUriParameter>`__
302 in OIDC specifications). These URLs may use wildcards (``https://app.example.com/*``).
303 - **Required authentication level**: Required authentication level to
304 access this application. Since ``2.21.0`` this can be a Perl expression.
305 - **Access rule**: Lets you specify a :doc:`Perl rule<rules_examples>` to restrict access to this client
306 - **Token endpoint authentication method**: Fix method to use to connect to "token" endpoint
307 - **Require JWS for authorization requests**: Require a signed JWS for code authorization requests. If **Token endpoint authentication method** is set, it will require the same algorithm
308 - **Require "state" in authorization request**: Require
309 - **Require "nonce" in authorization request**: Require
310 - **userinfo endpoint authentication using header only**:
311
312
313 - **Algorithms**
314
315 - **Access Token signature algorithm** (since version ``2.0.12``): Select
316 one of the available public key signature algorithms
317 - **Access Token Encryption key management algorithm**: If Relying-Party require access_token encryption, set here the key management algorithm
318 - **Access Token Encryption content encryption algorithm**: If Relying-Party require access_token encryption, set here the content encryption algorithm
319 - **ID Token signature algorithm**: Select one of the available public key
320 (RSXXX) or HMAC (HSXXX) based signature algorithms
321 - **ID Token Encryption key management algorithm**: If Relying-Party require id_token encryption, set here the key management algorithm
322 - **ID Token Encryption content encryption algorithm**: If Relying-Party require id_token encryption, set here the content encryption algorithm
323 - **UserInfo response format** (since version ``2.0.12``): By default,
324 UserInfo is returned as a simple JSON object. You can also choose to
325 return it as a JWT, using one of the available signature algorithms.
326 - **User_info Encryption key management algorithm**: If Relying-Party require user_info response encryption, set here the key management algorithm
327 - **User_info Encryption content encryption algorithm**: If Relying-Party require user_info response encryption, set here the content encryption algorithm
328 - **Introspection response format** (since version ``2.23.0``): By default,
329 Introspection is returned as a simple JSON object (RFC 7662). You can also choose to
330 return it as a JWT, using one of the available signature algorithms (RFC 9701).
331 - **Introspection Encryption key management algorithm**: If Relying-Party require introspection response encryption, set here the key management algorithm (RFC 9701)
332 - **Introspection Encryption content encryption algorithm**: If Relying-Party require introspection response encryption, set here the content encryption algorithm (RFC 9701)
333 - **Logout Encryption key management algorithm**: If Relying-Party require back-channel-logout token encryption, set here the key management algorithm
334 - **Logout Encryption content encryption algorithm**: If Relying-Party require back-channel-logout token encryption, set here the content encryption algorithm
335
336 - **Keys**
337
338 - **JWKS URI**: When Relying-Party require encryption, set here the relying-party endpoint where keys are published
339 - **JWKS Data**: Alternative, fix here the relying-party JWKS document
340 - **Signing key name**: Since ``2.22.0``, lets you use a
341 :doc:`different key <keys>` for signing tokens. If you specify multiple
342 values separated by a comma, the first key will be used for signing, and the
343 others will be published in metadata if you use the
344 ``/oauth2/jwks?client_id=<clientid>`` endpoint
345
346 .. important::
347
348 JWKS URI MUST be reachable by Portal to fetch JWKS document
349
350 - **Timeouts**
351
352 - **Authorization Codes** *(default: one minute)*: Expiration time of
353 Authorization Codes, when using the Authorization Code flow.
354 - **ID Tokens** *(default: one hour)*: Expiration time of ID Tokens.
355 - **Access Tokens** *(default: one hour)*: Expiration time
356 of Access Tokens.
357 - **Offline sessions** *(default: one month)*: Lifetime of the
358 refresh token obtained with the **offline_access** scope.
359 This parameter only applies if offline sessions are enabled.
360 - **refresh_token activity timeout** *(default: none)*: Expiration time
361 of inactives refresh tokens. if no value is set, activity isn't tracked.
362
363 .. important::
364
365 When enabling **refresh_token activity timeout**, a refresh_token created
366 with a version of LLNG previous to 2.22.0 and never used after update
367 is considered as active *(because it has no activity field)*.
368 Such totally inactive refresh_token will be purged normally at their
369 normal end-of-life. Any use of a refresh_token updates the activity field.
370
371 - **Logout**
372
373 - **Bypass confirm**: Bypass logout confirmation when logout is initiated
374 by relying party
375 - **Session required**: Whether to send the Session ID *(sid)* in the logout
376 request *(Front and Back Channel)*
377 - **Type**: Type of logout to perform
378 - **URL**: Specify the relying party's logout URL
379 - **Allowed redirection addresses for logout**: A space-separated list of
380 URLs that this client can redirect the user to once the logout is done
381 (through ``post_logout_redirect_uri``)
382
383 - **Activation** The user can activate and deactivate a RP. By default, RPs are
384 active upon creation.
385 - **Comment**: set a comment
386
387 Macros
388 ^^^^^^
389
390 You can define here macros that will be only evaluated for this service,
391 and not registered in the user's session.
392
393
394 Display
395 ^^^^^^^
396
397 - **Name**: Name of the RP application
398 - **Logo**: Logo of the RP application
399
400 .. |beta| image:: /documentation/beta.png
401
402 .. _oidcextraclaims:
403
404 Scope values content
405 ^^^^^^^^^^^^^^^^^^^^
406
407 When the **Always send exported attributes** option is disabled in **OpenID Connect Service**,
408 attributes can only be released if they are part of a scope.
409
410 By default, LL::NG will grant all requested scopes except if **Only allow declared scopes** option
411 is enabled in **OpenID Connect Service**.
412
413 In this case, only `standard OpenID Connect claims
414 <http://openid.net/specs/openid-connect-core-1_0.html#StandardClaims>`__ are
415 exposed to applications. If you want to add non-standard attributes, you have
416 to create a new scope in the *Scope values content* section and your
417 application must request that scope.
418
419 By default, the following scope-to-attributes are already mapped by LL::NG:
420
421 .. csv-table::
422 :header: "Scope value", "Attribute list"
423 :delim: ,
424 :widths: auto
425
426 profile, name family_name given_name middle_name nickname preferred_username profile picture website gender birthdate zoneinfo locale updated_at
427 email, email email_verified
428 address, street_address locality region postal_code country
429 phone, phone_number phone_number_verified
430
431 If you want to expose custom attributes to OpenID Connect clients,
432 you have to declare them in a new scope in this section.
433
434 Add your additional scope as **Key**, and a space-separated list of
435 attributes as **Value**:
436
437 - `employment_info` => `position company`
438
439 In this example, an OpenID Connect client (RP) requesting for the ``employment_info`` scope will
440 be able to read the ``company`` and ``position`` attributes from the UserInfo endpoint.
441
442 .. important::
443
444 Any attribute defined in this section must be mapped to a
445 LL::NG session variable in **Exported Attributes** section
446
447 .. important::
448
449 Your custom attributes will only be visible if the application requests the
450 corresponding scope value, or if you use a Scope Rule to always enable that scope.
451
452
453 .. _oidcscoperules:
454
455 Scope rules
456 ^^^^^^^^^^^
457
458 .. versionadded:: 2.0.12
459
460 |beta| This feature may change in a future version in a way that breaks
461 compatibility with existing configuration.
462
463 By default, LL::NG grants all scopes requested by the application, as
464 long as the user consents to them.
465
466 This configuration screen allows you to change that behavior by attaching
467 :ref:`a rule<rules>` to a particular scope.
468
469 * If the rule evaluates to true, the scope is added to the current request,
470 even if it was not requested by the application
471 * If the rule evaluates to false, the scope is removed from the current request
472 * Scopes which are not declared in the "Scope rules" list are left untouched
473
474 When writing scope rules, you can use the special ``$requested`` variable. This
475 variables evaluates to `true` within a scope rule when the corresponding scope
476 has been requested by the application. You can use this variable in a dynamic
477 rule when you only want to add a scope when the application requested it.
478
479 Examples:
480
481 * ``read``: ``inGroup('readers')``
482
483 * the ``read`` scope will be granted if the user is a member of the ``readers`` group even if the application did not request it.
484
485 * ``write``: ``$requested and inGroup('writers')``
486
487 * the ``write`` scope will be granted if the user is a member of the ``writers`` group, but only if the application requested it.
488
489 Access rule extra variables
490 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
491
492 When writing your access rules, you can additionally use the following variables:
493
494 * ``$_oidc_grant_type`` (since version ``2.0.14``): the grant type being used to
495 access this service. Possible values: ``authorizationcode``,
496 ``implicit``, ``hybrid``, ``clientcredentials``, ``password``
497
498 The following attributes are made available in the created session:
499
500 * The ``_whatToTrace`` attribute (main session identifier), is set to the
501 relying party's Client ID
502 * The ``_scope`` attribute is set to the requested scopes
503 * The ``_clientId`` attribute is set to the Client ID that obtained the access
504 token.
505 * The ``_clientConfKey`` attribute is set to the LemonLDAP::NG configuration
506 key for the client that obtained the access token.
507
508 The **Access Rule**, if defined, will have access to those variables, as well as
509 the `@ENV` array. You can use it to restrict the use of this grant to
510 pre-determined scopes, a particular IP address, etc.
511
512 These session attributes will be released on the UserInfo endpoint if they are
513 mapped to **Exported Attributes** and **Extra Claims**.
514
515 .. _resource-owner-password-grant:
516
517 Resource Owner Password Credentials Grant
518 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
519
520 The Resource Owner Password Credentials Grant allows you to exchange a user's login and password for an access token. This must be considered a legacy form of authentication, since the Authorization Code web-based flow is prefered for all applications that support it. It can however be useful in some scenarios involving technical accounts that cannot implement a web-based authentication flow.
521
522 .. versionchanged:: 2.0.12
523
524 When using the :doc:`Choice <authchoice>` authentication module, the *Choice used for password authentication* setting can be used for selecting which authentication choice is used by the Resource Owner Password Credentials Grant. Naturally, the selected choice must be a password-based authentication method (LDAP, DBI, REST, etc.).
525
526 .. seealso::
527
528 Specification for the Resource Owner Password Credentials Grant: :rfc:`6749#section-4.3`
529
530 .. _client-credentials-grant:
531
532 Client Credentials Grant
533 ^^^^^^^^^^^^^^^^^^^^^^^^
534
535 The Client Credentials Grant allows you to obtain an Access Token using only a Relying Party's Client ID and Client Secret.
536
537 .. seealso::
538
539 Specification for the Client Credentials Grant: :rfc:`6749#section-4.4`