Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e99b5d5

Browse files
Explain preferred username claim usage
1 parent 3afbc7e commit e99b5d5

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ If you want to understand the details of how to configure RabbitMQ with Oauth2 g
2727
- [Use custom scope field](#use-custom-scope-field)
2828
- [Use multiple asymmetrical signing keys](#use-multiple-asymmetrical-signing-keys)
2929
- [Use custom scopes](#use-custom-scopes)
30+
- [Preferred username claims](#preferred-username-claims)
3031
- [Use Rich Authorization Request Tokens](#use-rich-authorization-request-tokens)
3132
- Use different OAuth 2.0 servers
3233
- [KeyCloak](use-cases/keycloak.md)
@@ -556,6 +557,23 @@ make stop-perftest-producer PRODUCER=producer_with_roles
556557
make stop-perftest-consumer CONSUMER=consumer_with_roles
557558
```
558559

560+
### <a id="preferred-username-claims" class="anchor" href="#preferred-username-claims">Preferred username claims</a>
561+
562+
RabbitMQ needs to figure out the username associated to the token so that it can display it in the management ui.
563+
By default, RabbitMQ will first look for the `sub` claim and if it is not found it uses the `client_id`.
564+
565+
Most authorization servers return the user's GUID in the `sub` claim rather than the actual user's username or email address, anything the user can relate to. When the `sub` claim does not carry a *user-friendly username*, you can configure one or several claims to extract the username from the token.
566+
567+
Given this configuration;
568+
```
569+
...
570+
{rabbitmq_auth_backend_oauth2, [
571+
{resource_server_id, <<"rabbitmq">>},
572+
{preferred_username_claims, [<<"user_name">>,<<"email">>]},
573+
...
574+
```
575+
RabbitMQ would first look for the `user_name` claim and if it is not found it looks for `email`. Else it uses its default lookup mechanism which first looks for `sub` and then `client_id`.
576+
559577

560578
### Use Rich Authorization Request Tokens
561579

0 commit comments

Comments
 (0)