Skip to content

Commit 796fa5f

Browse files
Fix issue with oauth2+basic_auth where
the user logged in via basic auth and on page reload, the credentials were deleted.
1 parent 4b59c19 commit 796fa5f

3 files changed

Lines changed: 42 additions & 16 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ 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) return oauth;
102+
if (!oauth.enabled || has_auth_credentials()) return oauth;
103103
switch (state) {
104104
case 'login-callback':
105105
oauth_completeLogin(); break;

selenium/test/oauth/with-basic-auth/happy-login.js

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { By, Key, until, Builder } = require('selenium-webdriver')
22
require('chromedriver')
33
const assert = require('assert')
4-
const { buildDriver, goToHome, captureScreensFor, teardown, idpLoginPage } = require('../../utils')
4+
const { buildDriver, goToHome, captureScreensFor, teardown, idpLoginPage, log } = require('../../utils')
55

66
const SSOHomePage = require('../../pageobjects/SSOHomePage')
77
const OverviewPage = require('../../pageobjects/OverviewPage')
@@ -40,6 +40,46 @@ describe('An user with administrator tag', function () {
4040
await overview.logout()
4141
})
4242

43+
describe("And logged in via OAuth 2.0", async function() {
44+
before(async function() {
45+
await homePage.clickToLogin()
46+
await idpLogin.login('rabbit_admin', 'rabbit_admin')
47+
if (!await overview.isLoaded()) {
48+
throw new Error('Failed to login via OAuth 2.0')
49+
}
50+
})
51+
it ('can reload page without being logged out', async function() {
52+
log("About to refresh page")
53+
overview.refresh()
54+
if (!await overview.isLoaded()) {
55+
throw new Error('Failed to keep session opened')
56+
}
57+
})
58+
after(async function () {
59+
await overview.logout()
60+
})
61+
})
62+
63+
describe("An logged in via Basic Auth", async function() {
64+
before(async function() {
65+
await homePage.toggleBasicAuthSection()
66+
await homePage.basicAuthLogin('guest', 'guest')
67+
if (!await overview.isLoaded()) {
68+
throw new Error('Failed to login')
69+
}
70+
})
71+
it ('can reload page without being logged out', async function() {
72+
log("About to refresh page")
73+
overview.refresh()
74+
if (!await overview.isLoaded()) {
75+
throw new Error('Failed to keep session opened')
76+
}
77+
})
78+
after(async function () {
79+
await overview.logout()
80+
})
81+
})
82+
4383
after(async function () {
4484
await teardown(driver, this, captureScreen)
4585
})

selenium/test/oauth/with-basic-auth/unauthorized.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,6 @@ describe('An user without management tag', function () {
4040
assert.ok(!await homePage.isOAuth2SectionVisible())
4141
})
4242

43-
describe("After clicking on logout button", function() {
44-
45-
before(async function () {
46-
await homePage.clickToLogout()
47-
})
48-
49-
it('should get redirected to home page again without error message', async function(){
50-
const visible = await homePage.isWarningVisible()
51-
assert.ok(!visible)
52-
})
53-
54-
})
55-
56-
5743
after(async function () {
5844
await teardown(driver, this, captureScreen)
5945
})

0 commit comments

Comments
 (0)