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
RabbitMQ can be configured to use [JWT-encoded OAuth 2.0 access tokens](https://github.com/rabbitmq/rabbitmq-auth-backend-oauth2) to authenticate client applications and management UI users. When doing so, the management UI does
289
289
not automatically redirect users to authenticate
290
290
against the OAuth 2 server, this must be configured separately. Currently,
291
-
RabbitMQ has been tested against the following Authorization servers:
291
+
**Authorization code flow with PKCE** is tested with the following Authorization servers:
**Important**: from the OAuth 2.0 point of view, the RabbitMQ Management UI is a **public app** which
299
+
means it cannot securely store credentials such as the *client_secret*. This means that RabbitMQ does not need to present a client_secret when authenticating users.
300
+
301
+
It is usually possible to configure the OAuth client as a **public app** with the authorization server that you are using.
302
+
If target authorization server only supports a **confidential app** or it requires a *client_secret*,
303
+
then a *client_secret***must** be configured using the `oauth_client_secret` setting.
304
+
298
305
To redirect users to the UAA server to authenticate, use the following configuration:
This is true for all endpoints except `GET /definitions` and `POST /definitions`. Those
349
355
endpoints require the token to be passed in the `token` query string parameter.
350
356
351
-
### Minimum scope required and how the UI determines the username from the token
352
-
353
-
At a minimum, RabbitMQ requires the the `openid` scope because it uses some claims in the *id token* to determine the username and to display this username on the top right corner of the management UI. The *id token* is returned by the Authorization server if the `openid` scope is included in the authorization request.
354
-
355
-
RabbitMQ reads the `user_name` claim from the *id_token*. If the token does not contain the `user_name`, RabbitMQ uses the `sub` claim.
356
-
357
357
### Configure which scopes RabbitMQ requests to the authorization server
358
358
359
359
It is possible to configure which OAuth 2.0 scopes RabbitMQ should claim when redirecting the user to the authorization server.
@@ -373,6 +373,8 @@ such as:
373
373
* <*resource_server_id*>`.tag:administrator`
374
374
* <*resource_server_id*>`.read:*/*/*`
375
375
376
+
The scopes are configured using the `management.oauth_scopes` setting. The value must be a space-separated list of scopes.
377
+
376
378
### Configure OpenID Connect Discovery endpoint
377
379
378
380
By default, RabbitMQ assumes the OpenID Connect Discovery endpoint is at `<management.oauth_provider_url>/.well-known/openid-configuration`. If your endpoint differs, you can set yours via the `management.oauth_metadata_url` setting.
@@ -395,6 +397,28 @@ For instance, if you configured the CSP header with the value `default-src 'self
395
397
396
398
In addition to the `connect-src` CSP header, RabbitMQ also needs the CSP directives `unsafe-eval``unsafe-inline`, otherwise the OAuth 2.0 functionality may not work.
397
399
400
+
### Identity-Provider initiated logon
401
+
402
+
By default, the RabbitMQ Management UI uses the OAuth 2.0 **authorization code flow** to authenticate and authorize users.
403
+
However, there are scenarios where users preferred to be automatically redirected to RabbitMQ without getting
404
+
involved in additional logon flows. This is common in Web Portals where with a single click, users navigate
405
+
straight to a RabbitMQ cluster's management UI with a token obtained under the covers. This is known as
406
+
**Identity-Provider initiated logon**.
407
+
408
+
RabbitMQ exposes a new setting called `management.oauth_initiated_logon_type` whose default value `sp_initiated`.
409
+
To enable an **Identity-Provider initiated logon** you set it to `idp_initiated`.
410
+
411
+
After you set `management.oauth_initiated_logon_type` to `idp_initiated` and
412
+
`oauth_enabled: true` and `oauth_provider_url` are configured, the management UI exposes the HTTP endpoint `/login` which accepts `content-type: application/x-www-form-urlencoded` and it expects the JWT token in the `access_token` form field. This is the endpoint where the web portal would redirect users to access the RabbitMQ Management ui.
413
+
414
+
This is the minimum required configuration for a RabbitMQ cluster configured with `idp_initiated` logon type:
Copy file name to clipboardExpand all lines: site/oauth2-examples-azure.md
-13Lines changed: 0 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -49,17 +49,6 @@ When using **Azure AD as OAuth 2.0 server**, your client app (in our case Rabbit
49
49
50
50

51
51
52
-
## Create a secret for your app
53
-
54
-
Your application needs a **client secret** to prove its identity when requesting a token.
55
-
56
-
1. Still on the **App registrations** page, in the left-hand menu, click on **Certificates & Secrets**, then select the **Client secrets** tab.
57
-
58
-
2. In the **Certificates & Secrets** pane, click on **New Client Secret** and, on the right pane that has just opened, enter a description for the secret and choose an expiration time.
59
-
60
-
3. Click on **Add**.
61
-
62
-
<g-emojiclass="g-emoji"alias="warning"fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/26a0.png">⚠️</g-emoji> **IMPORTANT**: Immediately note the value of the secret (as you won't be able to get it later and you will need it to configure the `rabbitmq_auth_backend_oauth2` on RabbitMQ side).
63
52
64
53
## Create OAuth 2.0 roles for your app
65
54
@@ -138,7 +127,6 @@ The configuration on Azure side is done. You now have to configure RabbitMQ to u
138
127
Update it with the following values (you should have noted these in the previous steps):
139
128
***Tenant ID** associated to the app that you registered in Azure AD
140
129
***Application ID** associated to the app that you registered in Azure AD
141
-
* Value of the **secret** you created for your app in Azure AD
142
130
* Value of the **jwks_uri** key from `https://login.microsoftonline.com/{TENANT_ID}/v2.0/.well-known/openid-configuration`
143
131
144
132
<preclass="lang-bash">
@@ -150,7 +138,6 @@ $ vi rabbitmq.config
150
138
{rabbitmq_management, [
151
139
{oauth_enabled, true},
152
140
{oauth_client_id, "PUT YOUR AZURE AD APPLICATION ID"},
153
-
{oauth_client_secret, "PUT YOUR AZURE AD APPLICATION SECRET"},
Copy file name to clipboardExpand all lines: site/oauth2-examples-oauth0.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -74,7 +74,7 @@ list of users which have this role.
74
74
75
75
1. From Auth0 dashboard, go to **Settings > List of Valid Keys**, and **Copy Signing Certificate** from the **CURRENTLY USED** signing key.
76
76
77
-
2. Create `/tmp/certiicate.pem` and paste the certificate.
77
+
2. Create `/tmp/certificate.pem` and paste the certificate.
78
78
79
79
3. Run `openssl x509 -in /tmp/certificate.pem -pubkey -noout > /tmp/public.pem` to extract the public key from the certificate and paste the public key into `rabbitmq.config`.
@@ -78,20 +80,26 @@ has to be configured to validate any of the two types of digital signatures.
78
80
Given that asymmetrical keys is the most widely used option, you are going to focus on how to
79
81
configure RabbitMQ with them.
80
82
81
-
Run the following 3 commands to get the environment ready to see Oauth 2.0 plugin in action:
83
+
Run the following 2 commands to get the environment ready to see Oauth 2.0 plugin in action:
82
84
83
85
1.`make start-uaa` to get UAA server running
84
-
2.`make setup-uaa-users-and-clients` to install uaac client; connect to UAA server and set ups users, group, clients and permissions
85
-
3.`make start-rabbitmq` to start RabbitMQ server
86
+
2.`make start-rabbitmq` to start RabbitMQ server
86
87
87
88
The last command starts a RabbitMQ server with [this](https://github.com/rabbitmq/rabbitmq-oauth2-tutorial/blob/main/conf/uaa/rabbitmq.config) configuration file.
88
89
90
+
## <aid="access-management-ui"class="anchor"href="#access-management-ui">Access Management UI using OAuth 2.0 tokens</a>
The RabbitMQ Management UI can be configured with one of these two login modes:
91
93
92
-
The following subsections demonstrate how to use access tokens with any messaging protocol and also to access the management ui and rest api.
94
+
*[Service-Provider initiated logon](#service-provider-initiated-logon): this is the default and traditional OAuth 2.0 logon mode.
95
+
When the user visits the RabbitMQ Management UI, it shows a button with the label `Click here to logon`. When the user clicks it,
96
+
the logon process starts by redirecting to the configured **Authorization Server**.
97
+
*[Identity-Provider initiated logon](#identity-provider-initiated-logon): this mode is opposite to the previous mode.
98
+
The user must first access the RabbitMQ Management's `/login` endpoint with a token. If the token is valid, the user is allowed to access the RabbitMQ Management UI.
99
+
This mode is very useful for Web sites which allow users to access the RabbitMQ Management UI with a single click.
100
+
The original Web site get a token on user's behalf and redirects the user to the RabbitMQ Management's `/login` endpoint.
93
101
94
-
### <aid="management-user-accessing-the-management-ui"class="anchor"href="#management-user-accessing-the-management-ui">Management user accessing the Management UI</a>
How it works, firstly, the `rabbit_admin` user navigates to the web portal and clicks on the hyperlink associated with a RabbitMQ
159
+
cluster. Next, the web portal obtains a token and redirects the user to RabbitMQ `/login` endpoint with the token within the HTTP form field `access_token`. Finally,
160
+
RabbitMQ validates the token in the http request and if it is valid, it redirects the user to the overview page.
161
+
162
+
By default, the RabbitMQ Management UI is configured with **service-provider initiated logon**, to configure **Identity-Provider initiated logon**,
163
+
add one entry to `advanced.config`. For example:
164
+
165
+
<preclass="lang-erlang">
166
+
...
167
+
{rabbitmq_management, [
168
+
{oauth_enabled, true},
169
+
{oauth_client_id, "rabbit_client_code"},
170
+
{oauth_provider_url, "http://localhost:8080"},
171
+
{oauth_initiated_logon_type, idp_initiated},
172
+
...
173
+
]},
174
+
</pre>
175
+
176
+
**Important**: when the user logs out, or its RabbitMQ session expired, or the token expired, the user is directed to the
177
+
RabbitMQ Management landing page which has a **Click here to login** button.
178
+
The user is never automatically redirected back to the url configured in the `oauth_provider_url`.
179
+
It is only when the user clicks **Click here to login** , the user is redirected to the configured url in `oauth_provider_url`.
180
+
181
+
## <aid="access-other-protocols"class="anchor"href="#access-other-protocols">Access other protocols using OAuth 2.0 tokens</a>
182
+
183
+
The following subsections demonstrate how to use access tokens with any messaging protocol and also to access the management rest api.
0 commit comments