Skip to content

Commit fa70c93

Browse files
Configure oauth2 client for mgt ui
so that it is possible to test with clients configured with opaque tokens and others with jwt tokens
1 parent 85fa092 commit fa70c93

File tree

7 files changed

+33
-7
lines changed

7 files changed

+33
-7
lines changed

deps/rabbitmq_auth_backend_oauth2/src/rabbit_auth_backend_oauth2.erl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,15 @@ authenticate(_, AuthProps0) ->
154154
Token0 = token_from_context(AuthProps),
155155
TokenResult = case uaa_jwt_jwt:is_jwt_token(Token0) of
156156
true -> {ok, Token0};
157-
false -> oauth2_client:introspect_token(Token0)
157+
false ->
158+
case oauth2_client:introspect_token(Token0) of
159+
{ok, Tk1} ->
160+
rabbit_log:debug("Successfully introspected token : ~p", [Tk1]),
161+
{ok, Tk1};
162+
{error, Err1} ->
163+
rabbit_log:error("Failed to introspected token due to ~p", [Err1]),
164+
{error, Err1}
165+
end
158166
end,
159167
case TokenResult of
160168
{ok, Token} ->

selenium/test/oauth/env.keycloak

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export OAUTH_SERVER_CONFIG_DIR=${OAUTH_SERVER_CONFIG_BASEDIR}/oauth/keycloak
22
export OAUTH_SIGNING_KEY_ID=Gnl2ZlbRh3rAr6Wymc988_5cY7T5GuePd5dpJlXDJUk
33
export OAUTH_SCOPES="openid profile rabbitmq.tag:management"
4+
export OAUTH_CLIENT_ID=rabbitmq_client_code

selenium/test/oauth/env.spring

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export OAUTH_SERVER_CONFIG_DIR=${OAUTH_SERVER_CONFIG_BASEDIR}/oauth/spring
22
export OAUTH_SCOPES="openid profile rabbitmq.tag:management"
3+
export OAUTH_CLIENT_ID=rabbitmq_client_code
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export OAUTH_CLIENT_ID=rabbitmq_client_code_opaque

selenium/test/oauth/rabbitmq.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ log.console.level = debug
44

55
management.login_session_timeout = 1
66
management.oauth_enabled = true
7-
management.oauth_client_id = rabbitmq_client_code
7+
management.oauth_client_id = ${OAUTH_CLIENT_ID}
88
management.oauth_scopes = ${OAUTH_SCOPES}
99
management.cors.allow_origins.1 = *
1010

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
auth_oauth2.access_token_format = opaque
22
auth_oauth2.introspection_client_auth_method = basic
3-
auth_oauth2.introspection_client_id = rabbitmq_client_code_opaque
4-
auth_oauth2.introspection_client_secret = rabbitmq_client_code_opaque
3+
auth_oauth2.introspection_client_id = introspection_client
4+
auth_oauth2.introspection_client_secret = introspection_client

selenium/test/oauth/spring/application.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,22 @@ spring:
3838
client-authentication-methods:
3939
- client_secret_basic
4040
client-name: introspection_client
41+
mgt_api_client_opaque:
42+
registration:
43+
provider: spring
44+
client-id: mgt_api_client_opaque
45+
client-secret: "{noop}mgt_api_client_opaque"
46+
authorization-grant-types:
47+
- client_credentials
48+
client-authentication-methods:
49+
- client_secret_basic
50+
scopes:
51+
- openid
52+
- profile
53+
- rabbitmq.tag:management
54+
client-name: mgt_api_client_opaque
55+
token:
56+
access-token-format: reference
4157
mgt_api_client:
4258
registration:
4359
provider: spring
@@ -51,9 +67,8 @@ spring:
5167
- openid
5268
- profile
5369
- rabbitmq.tag:management
54-
client-name: mgt_api_client
55-
token:
56-
access-token-format: reference
70+
- rabbitmq.tag:administrator
71+
client-name: mgt_api_client
5772
rabbitmq_client_code_opaque:
5873
registration:
5974
provider: spring

0 commit comments

Comments
 (0)