Skip to content

Commit 49ddc8a

Browse files
MarcialRosalesmichaelklishin
authored andcommitted
Modify Entra example so that it uses v2.0
Conflicts: docs/oauth2-examples-entra-id/index.md
1 parent 19e677c commit 49ddc8a

File tree

1 file changed

+34
-10
lines changed

1 file changed

+34
-10
lines changed

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

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ limitations under the License.
2424
This guide explains how to set up OAuth 2.0 for RabbitMQ
2525
and Microsoft Entra ID as Authorization Server using the following flows:
2626

27-
* Access the management UI via a browser using v2.0 api version
27+
* Access the management UI via a browser using Entra ID (API version 2.0)
2828

2929

3030
## Prerequisites to follow this guide
3131

3232
* Have an account in https://portal.azure.com.
3333
* Docker
3434
* Openssl
35-
* A local clone of a [GitHub repository](https://github.com/rabbitmq/rabbitmq-oauth2-tutorial/tree/next) for branch `next` that contains all the configuration files and scripts used on this example.
35+
* A local clone of a [GitHub repository](https://github.com/rabbitmq/rabbitmq-oauth2-tutorial/tree/next) (the `next` branch) that contains all the configuration files and scripts used on this example.
3636

3737
## Register your app
3838

@@ -66,8 +66,8 @@ When using **Entra ID as OAuth 2.0 server**, your client app (in our case Rabbit
6666

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

69-
* **Directory (tenant ID)**
70-
* **Application (client) ID**
69+
* Directory (tenant ID)
70+
* Application (client) ID
7171

7272

7373
## Create OAuth 2.0 roles for your app
@@ -148,6 +148,21 @@ Now that some roles have been created for your application, you still need to as
148148

149149
## Create a Scope for Management UI Access
150150

151+
So far we have created the roles and granted the roles to the user who is going to
152+
access the management UI. When this user logs into RabbitMQ management UI, its token
153+
contains the granted roles.
154+
155+
1. Go to **App registrations**.
156+
2. Click on your application.
157+
3. Go to **Manage** option on the left menu and choose the option **Expose an API**.
158+
4. Click on **Add a scope**.
159+
5. Enter a name, eg. `management-ui`. Enter the same name for **Admin consent display name** and a description and save it.
160+
7. The scope is named `api://{Application (client) ID}/{scope_name}`.
161+
162+
RabbitMQ management ui must provide this scope in `management.oauth_scopes` along with `openid profiles` scopes.
163+
164+
## Configure Custom Signing Keys
165+
151166
There is one last configuration step required. Without this step, the `access_token` returned
152167
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
153168

@@ -167,15 +182,15 @@ This scope will be used further below in this guide.
167182
## Configure Custom Signing Keys
168183

169184
Creating a signing key for the application is optional. If a custom key is created, RabbitMQ must be configured accordingly.
170-
In the example below, replace `{Application(client) ID}` with the actual *Application(client) ID*.
171-
172-
Without this bit of configuration, the standard `jwks_uri` endpoint will not include the custom signing key
173-
and therefore RabbitMQ will not find the necessary signing key to validate the token's signature.
185+
In the following example, replace `{Application(client) ID}` with the actual *Application(client) ID*.
174186

175187
```ini
176188
auth_oauth2.discovery_endpoint_params.appid = {Application(client) ID}
177189
```
178190

191+
Without this bit of configuration, the standard `jwks_uri` endpoint will not include the custom signing key
192+
and therefore RabbitMQ will not find the necessary signing key to validate the token's signature.
193+
179194
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).
180195

181196

@@ -193,9 +208,18 @@ Edit the new `rabbitmq.conf` file and proceed as follows:
193208
3. If you decide to configure your application with custom signing(s), you need to uncomment the following configuration line. This is required otherwise the `jwks_uri` endpoint announced by the OpenID Discovery endpoint does not contain applications' custom signing keys.
194209

195210
```ini
196-
#auth_oauth2.discovery_endpoint_params.appid = {Application(client) ID}
197-
```
211+
#...
198212

213+
management.oauth_enabled = true
214+
management.oauth_client_id = {Application(client) ID}
215+
management.oauth_scopes = openid profile api://{Application(client) ID}/rabbitmq
216+
217+
auth_oauth2.resource_server_id = {Application(client) ID}
218+
auth_oauth2.additional_scopes_key = roles
219+
auth_oauth2.issuer = https://login.microsoftonline.com/{Directory (tenant) ID}/v2.0
220+
221+
#...
222+
```
199223

200224
## Start RabbitMQ
201225

0 commit comments

Comments
 (0)