Skip to content

Commit ea33b63

Browse files
Modify Entra example so that it uses v2.0
1 parent 5cc3499 commit ea33b63

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

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

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ limitations under the License.
2424
Demonstrate how to authenticate using the OAuth 2.0 protocol
2525
and Microsoft Entra ID as Authorization Server using the following flows:
2626

27-
* Access the management UI via a browser
27+
* Access the management UI via a browser.
2828

2929
## Prerequisites to follow this guide
3030

3131
* Have an account in https://portal.azure.com.
32-
* Docker
33-
* Openssl
32+
* Docker.
33+
* Openssl.
3434
* `git clone https://github.com/rabbitmq/rabbitmq-oauth2-tutorial`. This github repository
3535
contains all the configuration files and scripts used on this example.
3636

@@ -69,14 +69,6 @@ When using **Entra ID as OAuth 2.0 server**, your client app (in our case Rabbit
6969
* Directory (tenant ID)
7070
* Application (client) ID
7171

72-
6. Click on the **Endpoints** tab if it is visible.
73-
7. On the right pane that has just opened, copy the value of **OpenID Connect metadata document** (ex: `https://login.microsoftonline.com/{TENANT_ID}/v2.0/.well-known/openid-configuration`) and open it in your browser.
74-
75-
Note the value of the `jwks_uri` key (ex: `https://login.microsoftonline.com/{TENANT_ID}/discovery/v2.0/keys`), as you will also need it later to configure the `rabbitmq_auth_backend_oauth2` on RabbitMQ side.
76-
77-
![Entra ID JWKS URI](./entra-id-jwks-uri.png)
78-
8. If the **Endpoints** tab is not visible,
79-
8072

8173
## Create OAuth 2.0 roles for your app
8274

@@ -160,6 +152,21 @@ Now that some roles have been created for your application, you still need to as
160152

161153
9. Repeat the operations for all the roles you want to assign.
162154

155+
## Create scope required by Management ui during authorization
156+
157+
So far we have created the roles and granted the roles to the user who is going to
158+
access the management UI. When this user logs into RabbitMQ management UI, its token
159+
contains the granted roles.
160+
161+
1. Go to **App registrations**.
162+
2. Click on your application.
163+
3. Go to **Manage** option on the left menu and choose the option **Expose an API**.
164+
4. Click on **Add a scope**.
165+
5. Enter a name, eg. `management-ui`. Enter the same name for **Admin consent display name** and a description and save it.
166+
7. The scope is named `api://{Application (client) ID}/{scope_name}`.
167+
168+
RabbitMQ management ui must provide this scope in `management.oauth_scopes` along with `openid profiles` scopes.
169+
163170
## Configure Custom Signing Keys
164171

165172
It is optional to create a signing key for your application. If you create one though, you must append an `appid` query parameter containing the *app ID* to the `jwks_uri`. Otherwise, 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.
@@ -181,15 +188,15 @@ Update it with the following values:
181188

182189
```ini
183190
auth_backends.1 = rabbit_auth_backend_oauth2
184-
auth_backends.2 = rabbit_auth_backend_internal
185191

186192
management.oauth_enabled = true
187-
management.oauth_client_id = {PUT YOUR AZURE AD APPLICATION ID}
188-
management.oauth_provider_url = https://login.microsoftonline.com/{YOUR_ENTRA_ID_TENANT_ID}
193+
management.oauth_client_id = {Application(client) ID}
194+
management.oauth_scopes = openid profile api://{Application(client) ID}/rabbitmq
189195

190-
auth_oauth2.resource_server_id = {PUT YOUR AZURE AD APPLICATION ID}
196+
auth_oauth2.resource_server_id = {Application(client) ID}
191197
auth_oauth2.additional_scopes_key = roles
192-
auth_oauth2.jwks_url = {PUT YOUR ENTRA ID JWKS URI VALUE}
198+
auth_oauth2.issuer = https://login.microsoftonline.com/{Directory (tenant) ID}
199+
193200
```
194201

195202
## Start RabbitMQ

0 commit comments

Comments
 (0)