mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-29 09:42:25 +00:00
Backport of Fixed Oauth redirect not working on Android Chrome into release/1.14.x (#24714)
* backport of commit 7ffad66b0b
* fix ent test
---------
Co-authored-by: prajnamohan1 <36304276+prajnamohan1@users.noreply.github.com>
Co-authored-by: Chelsea Shaw <cshaw@hashicorp.com>
This commit is contained in:
committed by
GitHub
parent
9bb416fe4e
commit
da2b2cb967
3
changelog/18513.txt
Normal file
3
changelog/18513.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
```release-note:improvement
|
||||||
|
ui: latest version of chrome does not automatically redirect back to the app after authentication unless triggered by the user, hence added a link to redirect back to the app.
|
||||||
|
```
|
||||||
@@ -94,17 +94,17 @@ export default class VaultClusterOidcProviderRoute extends Route {
|
|||||||
_handleSuccess(response, baseUrl, state) {
|
_handleSuccess(response, baseUrl, state) {
|
||||||
const { code } = response;
|
const { code } = response;
|
||||||
const redirectUrl = this._buildUrl(baseUrl, { code, state });
|
const redirectUrl = this._buildUrl(baseUrl, { code, state });
|
||||||
if (Ember.testing) {
|
if (!Ember.testing) {
|
||||||
return { redirectUrl };
|
this.win.location.replace(redirectUrl);
|
||||||
}
|
}
|
||||||
this.win.location.replace(redirectUrl);
|
return { redirectUrl };
|
||||||
}
|
}
|
||||||
_handleError(errorResp, baseUrl) {
|
_handleError(errorResp, baseUrl) {
|
||||||
const redirectUrl = this._buildUrl(baseUrl, { ...errorResp });
|
const redirectUrl = this._buildUrl(baseUrl, { ...errorResp });
|
||||||
if (Ember.testing) {
|
if (!Ember.testing) {
|
||||||
return { redirectUrl };
|
this.win.location.replace(redirectUrl);
|
||||||
}
|
}
|
||||||
this.win.location.replace(redirectUrl);
|
return { redirectUrl };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -19,7 +19,9 @@
|
|||||||
@onSuccess={{this._handleSuccess}}
|
@onSuccess={{this._handleSuccess}}
|
||||||
/>
|
/>
|
||||||
{{else if this.model.redirectUrl}}
|
{{else if this.model.redirectUrl}}
|
||||||
<div data-test-oidc-redirect>{{this.model.redirectUrl}}</div>
|
<VaultLogoSpinner />
|
||||||
|
<p>If you are not automatically redirected,
|
||||||
|
<a href={{this.model.redirectUrl}} data-test-oidc-redirect>click here to go back to app.</a></p>
|
||||||
{{else}}
|
{{else}}
|
||||||
<VaultLogoSpinner />
|
<VaultLogoSpinner />
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|||||||
@@ -4,7 +4,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* eslint qunit/no-conditional-assertions: "warn" */
|
/* eslint qunit/no-conditional-assertions: "warn" */
|
||||||
import { click, fillIn, settled, visit, triggerKeyEvent, find, waitUntil } from '@ember/test-helpers';
|
import {
|
||||||
|
click,
|
||||||
|
fillIn,
|
||||||
|
settled,
|
||||||
|
visit,
|
||||||
|
triggerKeyEvent,
|
||||||
|
find,
|
||||||
|
waitUntil,
|
||||||
|
currentURL,
|
||||||
|
} from '@ember/test-helpers';
|
||||||
import { module, test } from 'qunit';
|
import { module, test } from 'qunit';
|
||||||
import { setupApplicationTest } from 'ember-qunit';
|
import { setupApplicationTest } from 'ember-qunit';
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
|||||||
@@ -164,10 +164,11 @@ module('Acceptance | oidc provider', function (hooks) {
|
|||||||
await authFormComponent.login();
|
await authFormComponent.login();
|
||||||
await settled();
|
await settled();
|
||||||
assert.strictEqual(currentURL(), url, 'URL is as expected after login');
|
assert.strictEqual(currentURL(), url, 'URL is as expected after login');
|
||||||
assert.dom('[data-test-oidc-redirect]').exists('redirect text exists');
|
|
||||||
assert
|
assert
|
||||||
.dom('[data-test-oidc-redirect]')
|
.dom('[data-test-oidc-redirect]')
|
||||||
.hasTextContaining(`${callback}?code=`, 'Successful redirect to callback');
|
.hasTextContaining(`click here to go back to app`, 'Shows link back to app');
|
||||||
|
const link = document.querySelector('[data-test-oidc-redirect]').getAttribute('href');
|
||||||
|
assert.ok(link.includes('/callback?code='), 'Redirects to correct url');
|
||||||
|
|
||||||
//* clean up test state
|
//* clean up test state
|
||||||
await clearRecord(this.store, 'oidc/client', 'my-webapp');
|
await clearRecord(this.store, 'oidc/client', 'my-webapp');
|
||||||
@@ -192,7 +193,9 @@ module('Acceptance | oidc provider', function (hooks) {
|
|||||||
await settled();
|
await settled();
|
||||||
assert
|
assert
|
||||||
.dom('[data-test-oidc-redirect]')
|
.dom('[data-test-oidc-redirect]')
|
||||||
.hasTextContaining(`${callback}?code=`, 'Successful redirect to callback');
|
.hasTextContaining(`click here to go back to app`, 'Shows link back to app');
|
||||||
|
const link = document.querySelector('[data-test-oidc-redirect]').getAttribute('href');
|
||||||
|
assert.ok(link.includes('/callback?code='), 'Redirects to correct url');
|
||||||
|
|
||||||
//* clean up test state
|
//* clean up test state
|
||||||
await clearRecord(this.store, 'oidc/client', 'my-webapp');
|
await clearRecord(this.store, 'oidc/client', 'my-webapp');
|
||||||
|
|||||||
Reference in New Issue
Block a user