Skip to content

Commit 10ad518

Browse files
Add variable expansion
And slighly rename the section that explains step by step how to configure oauth2
1 parent db0bcbb commit 10ad518

File tree

4 files changed

+46
-8
lines changed

4 files changed

+46
-8
lines changed

docs/oauth2.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ There's also a companion [troubleshooting guide for OAuth 2-specific problems](.
3434
### [How to configure it](#how-to-configure-it)
3535

3636
* [Prerequisites](#prerequisites)
37-
* [Configure OAuth 2.0 for identity providers compliant with OpenId Connect](#configure-for-openid-connect)
37+
* [Configure OAuth 2.0 step by step](#configure-for-openid-connect)
3838

3939
### [How it works](#how-it-works)
4040

@@ -98,7 +98,7 @@ example, the following configuration adds OAuth 2.0 as the only authentication b
9898
auth_backends.1 = rabbit_auth_backend_oauth2
9999
```
100100

101-
### Configure OAuth 2.0 for identity providers compliant with OpenId Connect{#configure-for-openid-connect}
101+
### Configure OAuth 2.0 step by step {#configure-for-openid-connect}
102102

103103
Nowadays, the majority of the identity providers are compliant with OpenId Connect. At minimum,
104104
this means that they expose an HTTP endpoint called *Discovery endpoint* mounted at
@@ -760,6 +760,23 @@ If `scope_prefix` is configured then scopes are prefixed as follows: `<scope_pre
760760
For example, if `scope_prefix` is `api://` and the permission is `read:*/*` the scope would be
761761
`api://read:*/*`
762762

763+
#### Variable expansion
764+
765+
OAuth 2.0 authorisation backend supports variable expansion when checking permission on vhosts and resources
766+
such as queues and exchanges.
767+
Variabbles can be any JWT claims whose value is a plain string and/or the `vhost` variable.
768+
769+
For example, a user connected with the token below to the vhost `prod` should have a write
770+
permission on all exchanges starting with `x-prod-`, and any routing key starting with `u-bob-`,
771+
where `bob` comes from the `sub` JWT claim:
772+
773+
```json
774+
{
775+
"sub" : "bob",
776+
"scope" : [ "rabbitmq.write:*/x-{vhost}-*/u-{sub}-*" ]
777+
}
778+
```
779+
763780
### Topic Exchange scopes {#topic-exchange-scopes}
764781

765782
The [previous](#scope-translation) section explained, in detail, how permissions are mapped to
@@ -782,6 +799,8 @@ To publish to a **Topic Exchange**, you need to have the following scope:
782799

783800
> for example `rabbitmq.write:*/*/*`
784801
802+
#### Variable expansion
803+
785804
OAuth 2.0 authorisation backend supports variable expansion when checking permission on topics.
786805
It supports JWT claims whose value is a plain string, plus the `vhost` variable.
787806

versioned_docs/version-3.13/oauth2.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ There's also a companion [troubleshooting guide for OAuth 2-specific problems](.
3232
### [How to configure it](#how-to-configure-it)
3333

3434
* [Prerequisites](#prerequisites)
35-
* [Configure OAuth 2.0 for identity providers compliant with OpenId Connect](#configure-for-openid-connect)
35+
* [Configure OAuth 2.0 step by step](#configure-for-openid-connect)
3636

3737
### [How it works](#how-it-works)
3838

@@ -94,7 +94,7 @@ example, the following configuration adds OAuth 2.0 as the only authentication b
9494
auth_backends.1 = rabbit_auth_backend_oauth2
9595
```
9696

97-
### Configure OAuth 2.0 for identity providers compliant with OpenId Connect{#configure-for-openid-connect}
97+
### Configure OAuth 2.0 step by step {#configure-for-openid-connect}
9898

9999
Nowadays, the majority of the identity providers are compliant with OpenId Connect. At minimum, this
100100
means that they expose an HTTP endpoint called *Discovery endpoint* mounted at

versioned_docs/version-4.0/oauth2.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ There's also a companion [troubleshooting guide for OAuth 2-specific problems](.
3232
### [How to configure it](#how-to-configure-it)
3333

3434
* [Prerequisites](#prerequisites)
35-
* [Configure OAuth 2.0 for identity providers compliant with OpenId Connect](#configure-for-openid-connect)
35+
* [Configure OAuth 2.0 step by step](#configure-for-openid-connect)
3636

3737
### [How it works](#how-it-works)
3838

@@ -94,7 +94,7 @@ example, the following configuration adds OAuth 2.0 as the only authentication b
9494
auth_backends.1 = rabbit_auth_backend_oauth2
9595
```
9696

97-
### Configure OAuth 2.0 for identity providers compliant with OpenId Connect{#configure-for-openid-connect}
97+
### Configure OAuth 2.0 step by step{#configure-for-openid-connect}
9898

9999
Nowadays, the majority of the identity providers are compliant with OpenId Connect. At minimum, this
100100
means that they expose an HTTP endpoint called *Discovery endpoint* mounted at

versioned_docs/version-4.1/oauth2.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ There's also a companion [troubleshooting guide for OAuth 2-specific problems](.
3434
### [How to configure it](#how-to-configure-it)
3535

3636
* [Prerequisites](#prerequisites)
37-
* [Configure OAuth 2.0 for identity providers compliant with OpenId Connect](#configure-for-openid-connect)
37+
* [Configure OAuth 2.0 step by step](#configure-for-openid-connect)
3838

3939
### [How it works](#how-it-works)
4040

@@ -98,7 +98,7 @@ example, the following configuration adds OAuth 2.0 as the only authentication b
9898
auth_backends.1 = rabbit_auth_backend_oauth2
9999
```
100100

101-
### Configure OAuth 2.0 for identity providers compliant with OpenId Connect{#configure-for-openid-connect}
101+
### Configure OAuth 2.0 step by step {#configure-for-openid-connect}
102102

103103
Nowadays, the majority of the identity providers are compliant with OpenId Connect. At minimum,
104104
this means that they expose an HTTP endpoint called *Discovery endpoint* mounted at
@@ -760,6 +760,23 @@ If `scope_prefix` is configured then scopes are prefixed as follows: `<scope_pre
760760
For example, if `scope_prefix` is `api://` and the permission is `read:*/*` the scope would be
761761
`api://read:*/*`
762762

763+
#### Variable expansion
764+
765+
OAuth 2.0 authorisation backend supports variable expansion when checking permission on vhosts and resources
766+
such as queues and exchanges.
767+
Variabbles can be any JWT claims whose value is a plain string and/or the `vhost` variable.
768+
769+
For example, a user connected with the token below to the vhost `prod` should have a write
770+
permission on all exchanges starting with `x-prod-`, and any routing key starting with `u-bob-`,
771+
where `bob` comes from the `sub` JWT claim:
772+
773+
```json
774+
{
775+
"sub" : "bob",
776+
"scope" : [ "rabbitmq.write:*/x-{vhost}-*/u-{sub}-*" ]
777+
}
778+
```
779+
763780
### Topic Exchange scopes {#topic-exchange-scopes}
764781

765782
The [previous](#scope-translation) section explained, in detail, how permissions are mapped to
@@ -782,6 +799,8 @@ To publish to a **Topic Exchange**, you need to have the following scope:
782799

783800
> for example `rabbitmq.write:*/*/*`
784801
802+
#### Variable expansion
803+
785804
OAuth 2.0 authorisation backend supports variable expansion when checking permission on topics.
786805
It supports JWT claims whose value is a plain string, plus the `vhost` variable.
787806

0 commit comments

Comments
 (0)