Skip to content

Commit 05cb5f8

Browse files
authored
Set correct field for extra scope and improve doc
- Replace additional_rabbitmq_scopes in doc for the correct extra_scopes_source value - Add samples - More details for audiance checkup on token
1 parent ac6b4dd commit 05cb5f8

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

deps/rabbitmq_auth_backend_oauth2/README.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@ To use this plugin
3838
1. UAA should be configured to produce encrypted JWT tokens containing a set of RabbitMQ permission scopes
3939
2. All RabbitMQ nodes must be [configured to use the `rabbit_auth_backend_oauth2` backend](https://www.rabbitmq.com/access-control.html)
4040
3. All RabbitMQ nodes must be configure with a resource service ID (`resource_server_id`) that matches the scope prefix (e.g. `rabbitmq` in `rabbitmq.read:*/*`).
41+
4. The token **must** has a value in`aud` that match `resource_server_id` value.
4142

4243
### Authorization Flow
4344

4445
1. Client authorize with OAuth 2.0 provider, requesting an `access_token` (using any grant type desired)
45-
2. Token scope returned by OAuth 2.0 provider must include RabbitMQ resource scopes that follow a convention used by this plugin: `configure:%2F/foo` means "configure permissions for 'foo' in vhost '/'")
46+
2. Token scope returned by OAuth 2.0 provider must include RabbitMQ resource scopes that follow a convention used by this plugin: `configure:%2F/foo` means "configure permissions for 'foo' in vhost '/'") (`scope` field can be changed using `extra_scopes_source` in **advanced.config** file.
4647
3. Client passes the token as password when connecting to a RabbitMQ node. **The username field is ignored**.
4748
4. The translated permissions are stored as part of the authenticated connection state and used the same
4849
way permissions from RabbitMQ's internal database would be used.
@@ -130,7 +131,7 @@ In that case, the configuration will look like this:
130131
{rabbitmq_auth_backend_oauth2, [
131132
{resource_server_id, <<"my_rabbit_server">>},
132133
{key_config, [
133-
{jwks_url, "https://my-jwt-issuer/jwks.json"}
134+
{jwks_url, <<"https://my-jwt-issuer/jwks.json">>}
134135
]}
135136
]},
136137
].
@@ -191,18 +192,31 @@ be `my_rabbit.read:*/*`.
191192

192193
### Using a different token field for the Scope
193194

194-
By default the plugin will look for the `scope` key in the token, you can configure the plugin to also look in other fields using the `additional_rabbitmq_scopes` setting.
195+
By default the plugin will look for the `scope` key in the token, you can configure the plugin to also look in other fields using the `extra_scopes_source` setting. Values format accepted are scope as **string** or **list**
196+
195197

196198
```erlang
197199
[
198200
{rabbitmq_auth_backend_oauth2, [
199201
{resource_server_id, <<"my_rabbit_server">>},
200-
{additional_rabbitmq_scopes, <<"my_custom_scope_key">>},
202+
{extra_scopes_source, <<"my_custom_scope_key">>},
201203
...
202204
]}
203205
]},
204206
].
205207
```
208+
Token sample:
209+
```
210+
{
211+
"exp": 1618592626,
212+
"iat": 1618578226,
213+
"aud" : ["my_id"],
214+
...
215+
"scope_as_string": "my_id.configure:*/* my_id.read:*/* my_id.write:*/*",
216+
"scope_as_list": ["my_id.configure:*/*", "my_id.read:*/*", my_id.write:*/*"],
217+
...
218+
}
219+
```
206220

207221
### Using Tokens with Clients
208222

0 commit comments

Comments
 (0)