Skip to content

Commit 9885608

Browse files
Update oauth2 plugin with the new variables
1 parent a64a54d commit 9885608

File tree

1 file changed

+44
-15
lines changed

1 file changed

+44
-15
lines changed

docs/oauth2.md

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ There's also a companion [troubleshooting guide for OAuth 2-specific problems](.
4545
* [Configure signing keys](#configure-signing-keys)
4646
* [Use a different token field for the scope](#use-different-token-field)
4747
* [Preferred username claims](#preferred-username-claims)
48+
* [Discovery Endpoint params](#discovery-endpoint-params)
4849
* [Rich Authorization Request](#rich-authorization-request)
4950

5051
### [Advanced usage](#advanced-usage)
@@ -107,6 +108,12 @@ Also, the `https://my-oauth2-provider.com/realm/rabbitmq/.well-known/openid-conf
107108
*.well-known/openid-configuration* is the OpenID standard path for the OpenID Provider Configuration endpoint
108109
:::
109110

111+
If your provider exposes a different path and/or requires some extra http parameters for the OpenId discovery endpoint, you can configure them as follows:
112+
```ini
113+
auth_oauth2.discovery_endpoint_path = my/custom/path
114+
auth_oauth2.discovery_endpoint_params.appid = some-app-id
115+
```
116+
110117
More detail is included in the next section about what happens during the authentication and how to configure OAuth 2.0 beyond the basic configuration shown previously.
111118

112119
### Authorization Flow {#authorization-flow}
@@ -118,7 +125,7 @@ Tokens must be digitally signed otherwise they are not accepted. RabbitMQ must h
118125
- **JWKS endpoint** - this is the HTTP endpoint that returns the signing keys used to digitally sign the tokens.
119126
- **OpenID Provider Configuration endpoint** - this is the endpoint that returns the provider's configuration including all its endpoints, such as the **JWKS endpoint**.
120127

121-
When you configure RabbitMQ with one of two previous endpoints, RabbitMQ must make a HTTP request (or two, if we specify the latter endpoint) to download the signing keys. This is an operation that occurs once for any signing key not downloaded yet. When the OAuth 2.0 provider rotates the signing keys, newer tokens refer to a new signing key which RabbitMQ does not have yet which triggers another download of the newer signing keys.
128+
When you configure RabbitMQ with one of two previous endpoints, RabbitMQ must make a HTTP request (or two, if you specify the latter endpoint) to download the signing keys. This is an operation that occurs once for any signing key not downloaded yet. When the OAuth 2.0 provider rotates the signing keys, newer tokens refer to a new signing key which RabbitMQ does not have yet which triggers another download of the newer signing keys.
122129

123130
The token can be any [JWT token](https://jwt.io/introduction/) which contains the `scope` and `aud` fields.
124131

@@ -143,8 +150,10 @@ In chronological order, here is the sequence of events that occur when a client
143150
| `auth_oauth2.default_key` | ID of the default signing key.
144151
| `auth_oauth2.signing_keys` | Paths to the [signing key files](#signing-key-files).
145152
| `auth_oauth2.issuer` | The [issuer URL](#configure-issuer) of the authorization server that is used to discover endpoints such as `jwk_uri` and others (https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata).
146-
| `auth_oauth2.jwks_url` | The URL of the [JWKS endpoint](#jwks-endpoint). According to the [JWT Specification](https://datatracker.ietf.org/doc/html/rfc7515#section-4.1.2), the endpoint URL must be https.
147-
| `auth_oauth2.token_endpoint` | The URL of the OAuth 2.0 token endpoint.
153+
| `auth_oauth2.discovery_endpoint_path` | The path used for the OpenId discovery endpoint. Default value is `.well-known/openid-configuration`
154+
| `auth_oauth2.discovery_endpoint_params` | [List of HTTP parameters](#discovery-endpoint-params) sent to the OpenId discovery endpoint.
155+
| `auth_oauth2.jwks_url` | The URL of the [JWKS endpoint](#jwks-endpoint). According to the [JWT Specification](https://datatracker.ietf.org/doc/html/rfc7515#section-4.1.2), the endpoint URL must be https. Optional if you set `auth_oauth2.issuer`.
156+
| `auth_oauth2.token_endpoint` | The URL of the OAuth 2.0 token endpoint. Optional if you set `auth_oauth2.issuer`.
148157
| `auth_oauth2.https.cacertfile` | Path to a file containing PEM-encoded CA certificates. The CA certificates are used to connect to any of these endpoints: `jwks_url`, `token_endpoint`, or the `issuer`.
149158
| `auth_oauth2.https.depth` | The maximum number of non-self-issued intermediate certificates that may follow the peer certificate in a valid [certification path](ssl#peer-verification-depth). The default value is 10.
150159
| `auth_oauth2.https.peer_verification` | Configures [peer verification](ssl#peer-verification). Available values: `verify_none`, `verify_peer`. The default value is `verify_peer` if there are trusted CA installed in the OS or `auth_oauth2.https.cacertfile` is set. <p/> **Deprecated**: This variable will be soon replaced by `auth_oauth2.https.verify`. Users should stop using this variable.
@@ -206,7 +215,7 @@ auth_oauth2.algorithms.2 = RS256
206215

207216
#### JWKS endpoint {#jwks-endpoint}
208217

209-
The followibng configuration sets the JWKS endpoint from which RabbitMQ downloads the signing keys using the configured CA certificate and TLS variables.
218+
The following configuration sets the JWKS endpoint from which RabbitMQ downloads the signing keys using the configured CA certificate and TLS variables.
210219

211220
```ini
212221
auth_oauth2.resource_server_id = new_resource_server_id
@@ -220,6 +229,7 @@ auth_oauth2.algorithms.1 = HS256
220229
auth_oauth2.algorithms.2 = RS256
221230
```
222231

232+
223233
#### Multiple Resource Servers configuration {#multiple-resource-servers-configuration}
224234

225235
Each `auth_oauth2.resource_servers.<id/index>.` entry has the following variables shown in the table below. Except for the variables `id` and `oauth_provider_id`, if a resource does not configure a variable, RabbitMQ uses the variable configured at the root level. For instance, if the resource `auth_oauth2.resource_servers.prod` does not configure `preferred_username_claims` variable, RabbitMQ uses the value configured in `auth_oauth2.preferred_username_claims` for the resource `prod`.
@@ -254,18 +264,20 @@ Each `auth_oauth2.oauth_providers.{id/index}` entry has the following sub-keys.
254264

255265
| Key | Documentation
256266
|------------------------------|-----------
257-
| `issuer` | URL of OAuth Provider. RabbitMQ uses this URL to build the OpenId Connect Discovery endpoint by appending the path `.well-known/openid-configuration` to this URL
258-
| `token_endpoint` | The URL of the OAuth 2.0 token endpoint.
259-
| `jwks_uri` | The URL of the [JWKS endpoint](#jwks-endpoint). According to the [JWT Specification](https://datatracker.ietf.org/doc/html/rfc7515#section-4.1.2), the endpoint URL must be https. <p/>**Warning**: RabbitMQ uses for each OAuth Provider the variable name `jwks_uri` used by the OpenId Connect Discovery Specification rather than `jwks_url`.
260-
| `https.cacertfile` | Path to a file containing PEM-encoded CA certificates used to connect `issuer` and/or `jwks_uri` URLs
267+
| `issuer` | URL of OAuth Provider. RabbitMQ uses this URL to build the OpenId Connect Discovery endpoint by appending the path `.well-known/openid-configuration` to this URL.
268+
| `discovery_endpoint_path` | The path used for the OpenId discovery endpoint. Default value is `.well-known/openid-configuration`
269+
| `discovery_endpoint_params` | [List of HTTP parameters](#discovery-endpoint-params) sent to the OpenId discovery endpoint.
270+
| `token_endpoint` | The URL of the OAuth 2.0 token endpoint. Optional if you configured `issuer`.
271+
| `jwks_uri` | The URL of the [JWKS endpoint](#jwks-endpoint). According to the [JWT Specification](https://datatracker.ietf.org/doc/html/rfc7515#section-4.1.2), the endpoint URL must be https. <p/>**Warning**: RabbitMQ uses for each OAuth Provider the variable name `jwks_uri` used by the OpenId Connect Discovery Specification rather than `jwks_url`. This variable is optional if you set `issuer`.
272+
| `https.cacertfile` | Path to a file containing PEM-encoded CA certificates used to connect `issuer` and/or `jwks_uri` URLs.
261273
| `https.depth` | The maximum number of non-self-issued intermediate certificates that may follow the peer certificate in a valid [certification path](ssl#peer-verification-depth). The default value is 10.
262274
| `https.verify` | Configures [peer verification](ssl#peer-verification). Available values: `verify_none`, `verify_peer`. The default value is `verify_peer` if there are trusted CA installed in the OS or `auth_oauth2.https.cacertfile` is set.
263275
| `https.fail_if_no_peer_cert` | Used together with `auth_oauth2.https.peer_verification = verify_peer`. When set to `true`, TLS connection will be rejected if the client fails to provide a certificate. The default value is `false`.
264276
| `https.hostname_verification` | Enable wildcard-aware hostname verification for key server. Available values: `wildcard`, `none`. The default value is `none`.
265277
| `https.crl_check` | [Perform CRL verification](https://www.erlang.org/doc/man/ssl#type-crl_check) (Certificate Revocation List) verification. Default value is false.
266-
| `signing_keys` | Local filesystem paths to the [signing key files](#signing-key-files). The files must exist and be readable
267-
| `default_key` | ID of the default signing key
268-
| `algorithms` | Used to restrict [the list of enabled algorithms](https://github.com/potatosalad/erlang-jose#algorithm-support)
278+
| `signing_keys` | Local filesystem paths to the [signing key files](#signing-key-files). The files must exist and be readable.
279+
| `default_key` | ID of the default signing key.
280+
| `algorithms` | Used to restrict [the list of enabled algorithms](https://github.com/potatosalad/erlang-jose#algorithm-support).
269281

270282
Here is an example which configures two resources (`prod` and `dev`) where each resource is managed by two distinct identity providers:
271283

@@ -417,13 +429,12 @@ auth_oauth2.resource_server_id = my_rabbit_server
417429
auth_oauth2.jwks_url = "https://my-jwt-issuer/jwks.json
418430
```
419431
420-
421432
:::info
422433
If you have both endpoints configured, RabbitMQ uses `jwks_url` because it does not need to discover it via the `issuer` url.
423434
:::
424435
425436
:::info
426-
**Note about TLS variables for the `jwks_url` or the `issuer` url**: TLS variable such as the `cacertfile` are configured as follows regardless which url we are using:
437+
**Note about TLS variables for the `jwks_url` or the `issuer` url**: TLS variable such as the `cacertfile` are configured as follows regardless which url you are using:
427438
:::
428439
429440
```ini
@@ -534,6 +545,26 @@ auth_oauth2.preferred_username_claims.2 = email
534545
535546
In the example configuration, RabbitMQ searches for the `user_name` claim first and if it is not found, RabbitMQ searches for the `email`. If these are not found, RabbitMQ uses its default lookup mechanism which first looks for `sub` and then `client_id`.
536547
548+
549+
### Discovery endpoint parameters {#discovery-endpoint-params}
550+
551+
Some OAuth 2.0 providers requires certain query parameters in the OpenId Discovery endpoint. For instance, Microsoft Entra ID requires a query parameter called `appid` when the application uses custom signing keys. The endpoint returns an OpenId configuration tailored for the application's id specified in the parameter.
552+
For instance, the `jkws_uri` endpoint returned in the OpenId configuration has built-in the query parameter.
553+
554+
Here is an example of setting these parameters.
555+
556+
``` ini
557+
# ...
558+
auth_oauth2.discovery_endpoint_params.param1 = value1
559+
auth_oauth2.preferred_username_claims.param2 = value2
560+
# ...
561+
```
562+
563+
RabbitMQ adds the following query string to the discovery endpoint:
564+
```
565+
?param1=value1&param2=value2
566+
```
567+
537568
### Rich Authorization Request {#rich-authorization-request}
538569
539570
The [Rich Authorization Request](https://oauth.net/2/rich-authorization-requests/) extension provides a way for
@@ -729,8 +760,6 @@ auth_oauth2.oauth_providers.prodkeycloak.issuer = https://prodkeycloak:8080/real
729760
auth_oauth2.oauth_providers.prodkeycloak.end_session_endpoint = https://prodkeycloak:8080/realm/prod/logout
730761
```
731762
732-
733-
734763
### Configure multiple resource servers {#multiple-resource-servers}
735764
736765
Usually, all users that access a RabbitMQ cluster are registered within the same identity provider. Likewise, all tokens targeting the same RabbitMQ cluster also carry the same *audience*. In other words, all users reference a RabbitMQ cluster with the same resource name which must match the value of the `auth_oauth2.resource_server_id` variable.

0 commit comments

Comments
 (0)