You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* 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
98
+
* A local clone of a
99
+
[GitHub repository](https://github.com/rabbitmq/rabbitmq-oauth2-tutorial/tree/next) for branch
100
+
`next` that contains all the configuration files and scripts used on this example
100
101
* Add the following entry to `/etc/hosts`:
101
-
```
102
-
localhost keycloak rabbitmq
103
-
```
102
+
103
+
```console
104
+
localhost keycloak rabbitmq
105
+
```
104
106
105
107
## Deploy Keycloak
106
108
107
-
1. First, deploy **Keycloak**. It comes preconfigured with all the required scopes, users and clients.
109
+
1. First, deploy Keycloak. It comes preconfigured with all the required scopes, users, and clients.
108
110
109
-
2.Run the following command to start **Keycloak** server:
111
+
2.Start the Keycloak server by running:
110
112
111
-
```bash
112
-
make start-keycloak
113
-
```
113
+
```bash
114
+
make start-keycloak
115
+
```
114
116
115
-
There is a dedicated **Keycloak realm** called `Test` configured as follows:
117
+
There is a dedicated Keycloak realm called `Test` configured as follows:
116
118
117
-
* A [rsa](https://keycloak:8443/admin/master/console/#/test/realm-settings/keys) signing key. Use `admin`:`admin`
118
-
when prompted for credentials to access the Keycloak Administration page
119
+
* A [rsa](https://keycloak:8443/admin/master/console/#/test/realm-settings/keys) signing key. Use
120
+
`admin`:`admin`when prompted for credentials to access the Keycloak Administration page
119
121
* A [rsa provider](https://keycloak:8443/admin/master/console/#/test/realm-settings/keys/providers)
120
-
* Three clients: `rabbitmq-client-code`for the rabbitmq management UI, `mgt_api_client` to access via the
121
-
management api and `producer` to access via AMQP protocol.
122
-
122
+
* Three clients: `rabbitmq-client-code` for the RabbitMQ management UI, `mgt_api_client` to access
123
+
via the management API and `producer` to access via the AMQP protocol.
123
124
124
125
## Start RabbitMQ
125
126
126
-
Run the command below to start RabbitMQ configured with the **Keycloak** server we started in the previous section: This is the [rabbitmq.conf](https://github.com/rabbitmq/rabbitmq-oauth2-tutorial/blob/next/conf/keycloak/rabbitmq.conf) used for**Keycloak**.
127
+
Run the command below to start RabbitMQ configured with the `Keycloak` server we started in the
RabbitMQ is deployed with TLS enabled and Keycloak is configured with the corresponding `redirect_url` which uses https.
138
+
RabbitMQ is deployed with TLS enabled and Keycloak is configured with the corresponding `redirect_url`
139
+
which uses HTTPS.
134
140
:::
135
141
136
-
:::important
137
-
RabbitMQ is configured to read the scopes from the custom claim [extra_scope](https://github.com/rabbitmq/rabbitmq-oauth2-tutorial/blob/next/conf/keycloak/rabbitmq.conf#L11) and
138
-
by default from the standard claim `scope`.
139
-
However, if your scopes are deep in a map/list structure like `authorization.permissions.scopes`
140
-
or under `realm_access.roles` or `resource_access.account.roles`, you can configure
141
-
RabbitMQ to use those locations instead. See the section [Use a different token field for the scope](./oauth2#use-different-token-field) for more information.
142
+
:::important
143
+
RabbitMQ is configured to read the scopes from the custom claim
However, if your scopes are deep in a map/list structure such as `authorization.permissions.scopes`,
147
+
or under `realm_access.roles` or `resource_access.account.roles`, you can configure RabbitMQ to use
148
+
those locations instead. For more information, see the section
149
+
[Use a different token field for the scope](./oauth2#use-different-token-field).
142
150
:::
143
151
144
-
## Access Management api
152
+
## Access Management API
145
153
146
-
To access the management api run the following command. It uses the client [mgt_api_client](https://keycloak:8443/admin/master/console/#/test/clients/c5be3c24-0c88-4672-a77a-79002fcc9a9d/settings) which has the scope [rabbitmq.tag:administrator](https://keycloak:8443/admin/master/console/#/test/client-scopes/f6e6dd62-22bf-4421-910e-e6070908764c/settings).
154
+
To access the management api run the following command. It uses the client
make curl-keycloak url=https://localhost:15671/api/overview client_id=mgt_api_client secret=LWOuYqJ8gjKg3D2U8CJZDuID3KiRZVDa realm=test
150
161
```
151
162
152
163
## Application authentication and authorization with PerfTest
153
164
154
-
To test OAuth 2.0 authentication with AMQP protocol you are going to use RabbitMQ PerfTest tool which uses RabbitMQ Java Client.
165
+
To test OAuth 2.0 authentication with the AMQP protocol you use the RabbitMQ PerfTest tool, which
166
+
uses RabbitMQ Java Client.
155
167
156
-
First you obtain the token and pass it as a parameter to the make target `start-perftest-producer-with-token`.
168
+
First you obtain the token and pass it as a parameter to the make target
169
+
`start-perftest-producer-with-token`.
157
170
158
171
```bash
159
172
make start-perftest-producer-with-token PRODUCER=producer TOKEN=$(bin/keycloak/token producer kbOFBXI9tANgKUq8vXHLhT6YhbivgXxn test)
160
173
```
161
174
162
-
**NOTE**: Initializing an application with a token has one drawback: the application cannot use the connection beyond the lifespan of the token. See the next section where you demonstrate how to refresh the token.
175
+
:::info
176
+
Initializing an application with a token has one drawback: the application cannot use the connection
177
+
beyond the lifespan of the token. See the next section where you demonstrate how to refresh the token.
178
+
:::
163
179
164
180
## Application authentication and authorization with Pika
165
181
166
-
In the following information, OAuth 2.0 authentication is tested with the AMQP protocol and the Pika library. These tests specifically demonstrate how to refresh a token on a live AMQP connection.
182
+
In the following information, OAuth 2.0 authentication is tested with the AMQP protocol and the Pika
183
+
library. These tests specifically demonstrate how to refresh a token on a live AMQP connection.
167
184
168
-
The sample Python application [can be found on GitHub](https://github.com/rabbitmq/rabbitmq-oauth2-tutorial/tree/next/pika-client).
0 commit comments