backport of commit 7ffad66b0b

This commit is contained in:
prajnamohan1
2024-01-08 19:22:03 +00:00
committed by GitHub
parent e3f09b8c6d
commit b3c94de04b
4 changed files with 18 additions and 10 deletions

3
changelog/18513.txt Normal file
View 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.
```

View File

@@ -94,17 +94,17 @@ export default class VaultClusterOidcProviderRoute extends Route {
_handleSuccess(response, baseUrl, state) {
const { code } = response;
const redirectUrl = this._buildUrl(baseUrl, { code, state });
if (Ember.testing) {
return { redirectUrl };
if (!Ember.testing) {
this.win.location.replace(redirectUrl);
}
this.win.location.replace(redirectUrl);
return { redirectUrl };
}
_handleError(errorResp, baseUrl) {
const redirectUrl = this._buildUrl(baseUrl, { ...errorResp });
if (Ember.testing) {
return { redirectUrl };
if (!Ember.testing) {
this.win.location.replace(redirectUrl);
}
this.win.location.replace(redirectUrl);
return { redirectUrl };
}
/**

View File

@@ -19,7 +19,9 @@
@onSuccess={{this._handleSuccess}}
/>
{{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}}
<VaultLogoSpinner />
{{/if}}

View File

@@ -161,10 +161,11 @@ module('Acceptance | oidc provider', function (hooks) {
await authFormComponent.login();
await settled();
assert.strictEqual(currentURL(), url, 'URL is as expected after login');
assert.dom('[data-test-oidc-redirect]').exists('redirect text exists');
assert
.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
await clearRecord(this.store, 'oidc/client', 'my-webapp');
@@ -189,7 +190,9 @@ module('Acceptance | oidc provider', function (hooks) {
await settled();
assert
.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
await clearRecord(this.store, 'oidc/client', 'my-webapp');