Skip to content

Commit 7839e20

Browse files
Explain how to configure extra params for authorize and token endpoints
1 parent 6062d05 commit 7839e20

File tree

8 files changed

+103
-139
lines changed

8 files changed

+103
-139
lines changed

docs/management/index.md

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,10 @@ Given above configuration, when a user visits the management UI, the following t
414414
If you used to configure `management.oauth_metadata_url` because your provider did not use the standard OpenId Discovery endpoint's path, since RabbitMQ 4.1 you should instead configure the correct path as it is explained [here](./oauth2#discovery-endpoint-params).
415415
:::
416416

417+
:::tip
418+
If you used to configure `auth_oauth2.metadata_url` because your provider used a slightly different OpenId Discovery endpoint url, since RabbitMQ 4.1 you should instead configure the correct path and/or include any additional parameters. Please read [this section of the documentation](./oauth2#discovery-endpoint-params) where it is explained how to do it. `auth_oauth2.metadata_url` may be deprecated in future versions.
419+
:::
420+
417421
2. RabbitMQ displays a button with the label "Click here to login". When the user clicks on the button, the management UI initiates the OAuth 2.0 Authorization Code Flow, which redirects the user to the identity provider to authenticate and get a token.
418422

419423
### Configure client secret {#configure-client-secret}
@@ -510,29 +514,18 @@ RabbitMQ 3.13.1 and earlier versions require the [OpenId Connect Discovery endpo
510514
There are other two additional scenarios which can trigger a logout. One scenario occurs when the OAuth Token expires. Although RabbitMQ renews the token in the background before it expires, if the token expires, the user is logged out.
511515
The second scenario is when the management UI session exceeds the maximum allowed time configured on the [Login Session Timeout](#login-session-timeout).
512516

513-
### Configure Extra URI Parameters for Authorization and Token Endpoints {#extra-endpoint-params}
517+
### Configure extra parameters for authorization and token endpoints {#extra-endpoint-params}
514518

515-
Some OAuth 2.0 providers require additional URI parameters to be included into the request sent to the **authorization endpoint** and/or to the **token endpoint**.
516-
These parameters are vendor- or IDP installation-specific. The Management UI already sends all the parameters required by the OAuth 2.0 Authorization Code flow.
519+
There are some OAuth 2.0 providers which require extra parameters in the request sent to the **authorization endpoint** and/or to the **token endpoint**. These parameters are custom parameters. The Management UI already sends all the parameters required by the OAuth 2.0 Authorization Code flow.
517520

518-
In the followingexample an extra URI parameter called `audience` is added for both the **authorization** and **token** endpoints:
521+
Here is an example of setting an extra parameter called `audience` for both endpoints, the **authorization** and **token** endpoint:
519522

520523
```ini
521524
management.oauth_authorization_endpoint_params.audience = some-audience-id
522-
523-
management.oauth_token_endpoint_params.audience = some-audience-id
524-
```
525-
526-
Multiple parameters can be configured like so:
527-
528-
```ini
529-
management.oauth_authorization_endpoint_params.audience = some-audience-id
530-
management.oauth_authorization_endpoint_params.example = example-value
531-
532525
management.oauth_token_endpoint_params.audience = some-audience-id
533-
management.oauth_token_endpoint_params.other = other-value
534526
```
535527

528+
You can configure as many parameters as you need.
536529

537530
### Special attention to CSP header `connect-src` {#csp-header}
538531

@@ -629,12 +622,11 @@ the following settings:
629622
- `resource` : `rabbit_prod`
630623
- `scopes` : `openid rabbitmq.tag:management rabbitmq.read:*/*`
631624

632-
### Configure Extra URI Parameters for Authorization and Token Endpoints {#extra-endpoint-params}
625+
#### Configure extra parameters for authorization and token endpoints
633626

634-
Some OAuth 2.0 providers require additional URI parameters to be included into the request sent to the **authorization endpoint** and/or to the **token endpoint**.
635-
These parameters are vendor- or IDP installation-specific. The Management UI already sends all the parameters required by the OAuth 2.0 Authorization Code flow.
627+
There are some OAuth 2.0 providers which require extra parameters in the request sent to the **authorization endpoint** and/or to the **token endpoint**. These parameters are custom parameters and specified per resource. The Management UI already sends all the parameters required by the OAuth 2.0 Authorization Code flow.
636628

637-
The following example sets an extra URI parameter called `audience` for both endpoints for the resource `some-resource-id`:
629+
Here is an example of setting an extra parameter called `audience` for both endpoints for the resource `some-resource-id`:
638630

639631
```ini
640632
management.oauth_resource_servers.2.id = some-resource-id

docs/oauth2-examples-auth0.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ To configure RabbitMQ you need to gather the following information from Auth0:
9999
4. And take note of the *Domain* value
100100
5. Use the last values in *Client ID* and *Domain* fields in the RabbitMQ configuration file
101101

102-
Copy [conf/auth0/rabbitmq.conf.tmpl](https://github.com/rabbitmq/rabbitmq-oauth2-tutorial/blob/main/conf/auth0/rabbitmq.conf.tmpl) as `rabbitmq.conf`.
103-
It must be in same folder as `rabbitmq.conf.tmpl`.
102+
Clone the configuration file [conf/auth0/rabbitmq.conf.tmpl](https://github.com/rabbitmq/rabbitmq-oauth2-tutorial/blob/main/conf/auth0/rabbitmq.conf.tmpl) as `rabbitmq.conf` (in the same folder as `rabbitmq.conf.tmpl`).
104103

105104
Edit `rabbitmq.conf` and proceed as follows:
106105

docs/oauth2-examples-entra-id/index.md

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,16 @@ and Microsoft Entra ID as Authorization Server using the following flows:
2828
* Access the management UI via a browser using v2.0 api version
2929

3030
=======
31-
* Access the management UI via a browser.
32-
>>>>>>> Modify Entra example so that it uses v2.0
31+
* Access the management UI via a browser using v2.0 api version
32+
33+
>>>>>>> Explain how to configure extra params for authorize and token endpoints
3334
3435
## Prerequisites to follow this guide
3536

3637
* Have an account in https://portal.azure.com.
37-
<<<<<<< HEAD
3838
* Docker
3939
* Openssl
4040
* A local clone of a [GitHub repository](https://github.com/rabbitmq/rabbitmq-oauth2-tutorial) that contains all the configuration files and scripts used on this example
41-
=======
42-
* Docker.
43-
* Openssl.
44-
* `git clone https://github.com/rabbitmq/rabbitmq-oauth2-tutorial`. This github repository
45-
contains all the configuration files and scripts used on this example.
46-
>>>>>>> Modify Entra example so that it uses v2.0
4741

4842
## Register your app
4943

@@ -77,13 +71,8 @@ When using **Entra ID as OAuth 2.0 server**, your client app (in our case Rabbit
7771

7872
Note the following values, as you will need it later to configure the `rabbitmq_auth_backend_oauth2` on RabbitMQ side:
7973

80-
<<<<<<< HEAD
8174
* **Directory (tenant ID)**
8275
* **Application (client) ID**
83-
=======
84-
* Directory (tenant ID)
85-
* Application (client) ID
86-
>>>>>>> Modify Entra example so that it uses v2.0
8776

8877

8978
## Create OAuth 2.0 roles for your app
@@ -162,14 +151,11 @@ Now that some roles have been created for your application, you still need to as
162151

163152
9. Repeat the operations for all the roles you want to assign.
164153

165-
<<<<<<< HEAD
166-
## Create a Scope for Management UI Access
167-
=======
168-
## Create scope required by Management ui during authorization
154+
## Create scope required by Management UI during authorization
169155

170-
So far we have created the roles and granted the roles to the user who is going to
171-
access the management UI. When this user logs into RabbitMQ management UI, its token
172-
contains the granted roles.
156+
There is one last configuration step required. Without this step, the `access_token` returned
157+
by **Entra ID** is invalid. RabbitMQ cannot validate its signature because the `access_token` is meant for Microsoft resources.
158+
First, you need to create a scope associated to the application you registered for RabbitMQ management UI as follows:
173159

174160
1. Go to **App registrations**.
175161
2. Click on your application.
@@ -178,10 +164,9 @@ contains the granted roles.
178164
5. Enter a name, eg. `management-ui`. Enter the same name for **Admin consent display name** and a description and save it.
179165
7. The scope is named `api://{Application (client) ID}/{scope_name}`.
180166

181-
RabbitMQ management ui must provide this scope in `management.oauth_scopes` along with `openid profiles` scopes.
167+
Check out the last section to see how this scope is used to configure RabbitMQ.
182168

183169
## Configure Custom Signing Keys
184-
>>>>>>> Modify Entra example so that it uses v2.0
185170

186171
There is one last configuration step required. Without this step, the `access_token` returned
187172
by **Entra ID** won't be useable with RabbitMQ. More specifically, RabbitMQ will not be able to validate its signature because the `access_token` is meant for Microsoft resources
@@ -208,18 +193,19 @@ In the following example, replace `{Application(client) ID}` with the actual *Ap
208193
auth_oauth2.discovery_endpoint_params.appid = {Application(client) ID}
209194
```
210195

211-
Without this bit of configuration, the standard `jwks_uri` endpoint will not include the custom signing key
212-
and therefore RabbitMQ will not find the necessary signing key to validate the token's signature.
196+
It is optional to create a signing key for your application. If you create one though, you must add the following RabbitMQ configuration. You need to replace `{Application(client) ID}` with your *Application(client) ID*. Without this configuration, the standard jwks_uri endpoint will not include the custom signing key and RabbitMQ will not find the signing key to validate the token's signature.
213197

214-
For more information, check out Microsoft Entra documentation about [configuring custom signing keys](https://learn.microsoft.com/en-us/entra/identity-platform/jwt-claims-customization#validate-token-signing-key).
198+
```ini
199+
auth_oauth2.discovery_endpoint_params.appid = {Application(client) ID}
200+
```
215201

202+
For more information, check out Microsoft Entra documentation about [configuring custom signing keys](https://learn.microsoft.com/en-us/entra/identity-platform/jwt-claims-customization#validate-token-signing-key).
216203

217204
## Configure RabbitMQ to Use Entra ID as OAuth 2.0 Authentication Backend
218205

219206
The configuration on **Entra ID** side is done. Next, configure RabbitMQ to use these resources.
220207

221-
Clone [rabbitmq.conf.tmpl](https://github.com/rabbitmq/rabbitmq-oauth2-tutorial/tree/main/conf/entra/rabbitmq.conf.tmpl) from the tutorial repository
222-
to `rabbitmq.conf`. It must be in the same directory as `rabbitmq.conf.tmpl`.
208+
Clone the file called [rabbitmq.conf.tmpl](https://github.com/rabbitmq/rabbitmq-oauth2-tutorial/tree/main/conf/entra/rabbitmq.conf.tmpl) as `rabbitmq.conf` (in the same folder as `rabbitmq.conf.tmpl`).
223209

224210
Edit the new `rabbitmq.conf` file and proceed as follows:
225211

@@ -241,6 +227,7 @@ auth_oauth2.issuer = https://login.microsoftonline.com/{Directory (tenant) ID}/v
241227
#...
242228
```
243229

230+
244231
## Start RabbitMQ
245232

246233
Run the following commands to run RabbitMQ docker image:
@@ -251,7 +238,7 @@ make start-rabbitmq
251238
```
252239

253240
This starts a Docker container named `rabbitmq`, with RabbitMQ Management UI/API with HTTPS enabled, and configured to use your Entra ID as OAuth 2.0 authentication backend,
254-
based on the values set in `rabbitmq.conf` in the previous steps of this tutorial.
241+
based on the information you provided in `rabbitmq.conf` in the previous steps of this tutorial.
255242

256243
## Automatic generation of a TLS Certificate and Key Pair
257244

docs/oauth2-examples-okta.md

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -171,35 +171,29 @@ Once you've added the user to the appropriate groups and apps, they should have
171171

172172
This step is necessary otherwise the tokens do not carry any of the scopes granted to the users.
173173

174-
1. [Create an access policy](https://developer.okta.com/docs/guides/customize-authz-server/main/#create-access-policies)
175-
2. [Create a rule](https://developer.okta.com/docs/guides/customize-authz-server/main/#create-rules-for-each-access-policy) for the access policy
174+
1. Create access policy following these [instructions](https://developer.okta.com/docs/guides/customize-authz-server/main/#create-access-policies).
175+
2. Create rule for the access policy following these [instructions](https://developer.okta.com/docs/guides/customize-authz-server/main/#create-rules-for-each-access-policy).
176176

177-
## [Optional] Test the Tokens Issued by Okta
177+
## [Optional] Test the tokens issued by Okta
178178

179-
This step is optional but highly recommended.
179+
This is totally optional but it can save you time.
180180

181-
1. Go to the **default Authorization Server**
182-
2. Click on **Token Preview** tab
183-
3. Fill in all the fields. For **grant type** choose `Authorization Code`
184-
4. Click on **Preview Token** button
185-
5. Check the claim `role` to see if it contains the roles assigned earlier in this guide
181+
1. Go to the **default Authorization Server**.
182+
2. Click on **Token Preview** tab.
183+
3. Fill in all the fields. For **grant type** choose `Authorization Code`.
184+
4. Click on **Preview Token** button.
185+
5. Check the claim `role` to see if it contains the roles you assigned to your user.
186186

187187

188188
## Configure RabbitMQ to use Okta as OAuth 2.0 Authentication Backend
189189

190-
The configuration on the Okta side is done. Next, configure RabbitMQ to use the resources created above.
190+
The configuration on Okta side is done. You now have to configure RabbitMQ to use the resources you just created. You took note of the following values:
191191

192-
For that, you will need the following values from the previous steps:
192+
- **okta_client_app_ID** associated to the okta app that you registered in okta for rabbitMQ.
193+
- **okta-Issuer** associated to the **default Authorization server**.
194+
- **okta-Metadata-URI** associated to the **default Authorization server**.
193195

194-
* **okta_client_app_ID**: the ID of the app registered in Okta to be used with RabbitMQ
195-
* **okta-Issuer**: the **default Authorization server**
196-
* **okta-Metadata-URI**: the **default Authorization server**
197-
198-
Copy [rabbitmq.conf.tmpl](https://github.com/rabbitmq/rabbitmq-oauth2-tutorial/tree/main/conf/okta/rabbitmq.conf.tmpl) from the tutorial repository
199-
to `rabbitmq.conf`. It must be in the same directory as `rabbitmq.conf.tmpl`.
200-
201-
There is a second configuration file, [advanced.config](https://github.com/rabbitmq/rabbitmq-oauth2-tutorial/tree/main/conf/okta/advanced.config),
202-
that will not need any modifications. This is the RabbitMQ [advanced configuration file](./configure/) where RabbitMQ scopes are mapped to the permissions previously configured in Okta.
196+
Clone [rabbitmq.conf.tmpl](https://github.com/rabbitmq/rabbitmq-oauth2-tutorial/tree/main/conf/okta/rabbitmq.conf.tmpl) as `rabbitmq.conf` (in the same folder as `rabbitmq.conf.tmpl`). There is a second configuration file, [advanced.config](https://github.com/rabbitmq/rabbitmq-oauth2-tutorial/tree/main/conf/okta/advanced.config), that you keep it as it is. This is the RabbitMQ advanced configuration that maps RabbitMQ scopes to the permissions previously configured in Okta.
203197

204198
Edit `rabbitmq.conf` and proceed as follows:
205199

@@ -211,21 +205,14 @@ or `{okta-issuer}/.well-known/openid-configuration`
211205
`auth_oauth2.discovery_endpoint_path` accordingly. For instance, if **okta-Metadata-URI** is `{okta-issuer}/some-other-endpoint`, you update `auth_oauth2.discovery_endpoint_path` with the value `some-other-endpoint`.
212206

213207

214-
### About the OpenId Discovery Endpoint
215-
216-
RabbitMQ uses the standard OpenId discovery endpoint path `.well-known/openid-configuration`. Okta supports this path in addition to `.well-known/oauth-authorization-server`.
217-
The only difference observed between the two endpoints is that the latter returns more values in the `claims_supported` JSON field.
208+
### About OpenId Discovery Endpoint
218209

219-
The RabbitMQ's template configuration provided in the snippet below has this line.
220-
This means that RabbitMQ will use the standard path.
210+
RabbitMQ uses the standard OpenId discovery endpoint path `.well-known/openid-configuration`. Okta supports this path in addition to `.well-known/oauth-authorization-server`. The only difference observed at the time of writing this guide is that the latter returns more values in the json attribute `claims_supported`.
221211

222-
If the default does not work as expected, try uncommenting this line to use
223-
the alternative path.
224-
225-
``` ini
226-
## Uncomment to use '.well-known/oauth-authorization-server' as the discovery
227-
## endpoint path
228-
# auth_oauth2.discovery_endpoint_path = .well-known/oauth-authorization-server
212+
The RabbitMQ's template configuration provided in this example has this line commented out meaning that
213+
RabbitMQ will use the standard path. If you find any problems, try uncommenting this line.
214+
```
215+
#auth_oauth2.discovery_endpoint_path = .well-known/oauth-authorization-server
229216
```
230217

231218
## Start RabbitMQ

docs/oauth2-examples/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ which hosts all the scripts required to deploy the examples demonstrated on the
4646

4747
### Using [JWT tokens in several protocols](#access-other-protocols) to access RabbitMQ
4848

49-
* [Management HTTP API](#management-http-api)
49+
* [Management REST API](#management-rest-api)
5050
* [AMQP 0-9-1](#amqp-protocol) (and [scopes for topic exchanges](#using-topic-exchanges) in a separate section)
5151
* [AMQP 1.0](#amqp10-protocol)
5252
* [JMS](#jms-clients)
@@ -192,7 +192,7 @@ It is only when the user clicks **Click here to login** , the user is redirected
192192

193193
The following subsections demonstrate how to use access tokens with any messaging protocol and also to access the management HTTP API.
194194

195-
### Management HTTP API {#management-http-api}
195+
### Management REST api {#management-rest-api}
196196

197197
In this scenario a monitoring agent uses RabbitMQ HTTP API to collect monitoring information.
198198
Because it is not an end user, or human, you refer to it as a *service account*.

0 commit comments

Comments
 (0)