Skip to content

Commit 063a885

Browse files
MarcialRosalesmergify[bot]
authored andcommitted
Run the oauth2 callbacks if state parameter says so
(cherry picked from commit 37cf584)
1 parent 06a1e53 commit 063a885

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

deps/rabbitmq_management/priv/www/js/oidc-oauth/helper.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,19 @@ function get_oauth_settings() {
9999

100100
export function oauth_initialize_if_required(state = "index") {
101101
let oauth = oauth_initialize(get_oauth_settings())
102-
if (!oauth.enabled || has_auth_credentials()) return oauth;
102+
if (!oauth.enabled) return oauth;
103+
103104
switch (state) {
104105
case 'login-callback':
105106
oauth_completeLogin(); break;
106107
case 'logout-callback':
107108
oauth_completeLogout(); break;
108109
default:
109-
oauth = oauth_initiate(oauth);
110+
if (has_auth_credentials(BASIC_AUTH_SCHEME)) {
111+
break;
112+
}else {
113+
oauth = oauth_initiate(oauth);
114+
}
110115
}
111116
return oauth;
112117
}

deps/rabbitmq_management/priv/www/js/prefs.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ const LOGGED_IN = 'loggedIn'
1414
const LOGIN_SESSION_TIMEOUT = "login_session_timeout"
1515
const AUTH_RESOURCE = 'auth_resource'
1616

17+
const BASIC_AUTH_SCHEME = "Basic"
18+
const BEARER_AUTH_SCHEME = "Bearer"
19+
20+
1721
function set_auth_resource(resource) {
1822
store_local_pref(AUTH_RESOURCE, resource)
1923
}
@@ -24,9 +28,11 @@ function get_auth_resource() {
2428
return get_local_pref(AUTH_RESOURCE)
2529
}
2630

27-
function has_auth_credentials() {
28-
return get_local_pref(CREDENTIALS) != undefined && get_local_pref(AUTH_SCHEME) != undefined &&
29-
get_cookie_value(LOGGED_IN) != undefined
31+
function has_auth_credentials(auth_scheme) {
32+
let authenticated =get_local_pref(CREDENTIALS) != undefined && get_local_pref(AUTH_SCHEME) != undefined &&
33+
get_cookie_value(LOGGED_IN) != undefined;
34+
return authenticated && (auth_scheme == undefined
35+
|| auth_scheme == get_auth_scheme());
3036
}
3137
function get_auth_credentials() {
3238
return get_local_pref(CREDENTIALS)
@@ -54,6 +60,7 @@ function set_auth(auth_scheme, credentials, validUntil) {
5460
store_local_pref(AUTH_SCHEME, auth_scheme)
5561
store_cookie_value_with_expiration(LOGGED_IN, "true", validUntil) // session marker
5662
}
63+
5764
function authorization_header() {
5865
if (has_auth_credentials()) {
5966
return get_auth_scheme() + ' ' + get_auth_credentials();

0 commit comments

Comments
 (0)