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
36
101
* Add the following entry to `/etc/hosts`:
37
-
```
38
-
localhost keycloak rabbitmq
39
-
```
102
+
103
+
```console
104
+
localhost keycloak rabbitmq
105
+
```
40
106
41
107
## Deploy Keycloak
42
108
43
-
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.
44
110
45
-
2.Run the following command to start **Keycloak** server:
111
+
2.Start the Keycloak server by running:
46
112
47
-
```bash
48
-
make start-keycloak
49
-
```
113
+
```bash
114
+
make start-keycloak
115
+
```
50
116
51
-
There is a dedicated **Keycloak realm** called `Test` configured as follows:
117
+
There is a dedicated Keycloak realm called `Test` configured as follows:
52
118
53
-
* A [rsa](https://keycloak:8443/admin/master/console/#/test/realm-settings/keys) signing key. Use `admin`:`admin`
54
-
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
55
121
* A [rsa provider](https://keycloak:8443/admin/master/console/#/test/realm-settings/keys/providers)
56
-
* Three clients: `rabbitmq-client-code`for the rabbitmq management UI, `mgt_api_client` to access via the
57
-
management api and `producer` to access via AMQP protocol.
58
-
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.
59
124
60
125
## Start RabbitMQ
61
126
62
-
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
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).
70
150
:::
71
151
72
-
## Access Management api
152
+
## Access Management API
73
153
74
-
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
78
161
```
79
162
80
163
## Application authentication and authorization with PerfTest
81
164
82
-
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.
83
167
84
-
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`.
85
170
86
171
```bash
87
172
make start-perftest-producer-with-token PRODUCER=producer TOKEN=$(bin/keycloak/token producer kbOFBXI9tANgKUq8vXHLhT6YhbivgXxn test)
88
173
```
89
174
90
-
**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
+
:::
91
179
92
180
## Application authentication and authorization with Pika
93
181
94
-
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.
95
184
96
-
The sample Python application [can be found on GitHub](https://github.com/rabbitmq/rabbitmq-oauth2-tutorial/tree/next/pika-client).
0 commit comments