Skip to content

Commit 872f31f

Browse files
authored
UI: remove renew self call after login (#28204)
* check for renewAfterEpoch before comparing it * add test coverage for regression * add comment. Fixes VAULT-4630 * throw error * add changelog
1 parent de0c724 commit 872f31f

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

changelog/28204.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
ui: fixes renew-self being called right after login for non-renewable tokens
3+
```

ui/app/components/auth-jwt.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ export default Component.extend({
8787
this.onError(err);
8888
},
8989

90+
// NOTE TO DEVS: Be careful when updating the OIDC flow and ensure the updates
91+
// work with implicit flow. See issue https://github.com/hashicorp/vault-plugin-auth-jwt/pull/192
9092
prepareForOIDC: task(function* (oidcWindow) {
9193
const thisWindow = this.getWindow();
9294
// show the loading animation in the parent

ui/app/services/auth.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ export default Service.extend({
390390
const now = this.now();
391391
this.set('lastFetch', timestamp);
392392
// if expiration was allowed and we're over half the ttl we want to go ahead and renew here
393-
if (this.allowExpiration && now >= this.renewAfterEpoch) {
393+
if (this.allowExpiration && this.renewAfterEpoch && now >= this.renewAfterEpoch) {
394394
this.renew();
395395
}
396396
this.set('allowExpiration', false);

ui/tests/acceptance/auth-test.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@
66
import { module, test } from 'qunit';
77
import { setupApplicationTest } from 'ember-qunit';
88
import { click, currentURL, visit, waitUntil, find, fillIn } from '@ember/test-helpers';
9-
import { allSupportedAuthBackends, supportedAuthBackends } from 'vault/helpers/supported-auth-backends';
109
import { setupMirage } from 'ember-cli-mirage/test-support';
10+
import { allSupportedAuthBackends, supportedAuthBackends } from 'vault/helpers/supported-auth-backends';
11+
import VAULT_KEYS from 'vault/tests/helpers/vault-keys';
1112

1213
const AUTH_FORM = {
1314
method: '[data-test-select=auth-method]',
1415
token: '[data-test-token]',
1516
login: '[data-test-auth-submit]',
1617
};
1718
const ENT_AUTH_METHODS = ['saml'];
19+
const { rootToken } = VAULT_KEYS;
1820

1921
module('Acceptance | auth', function (hooks) {
2022
setupApplicationTest(hooks);
@@ -193,4 +195,17 @@ module('Acceptance | auth', function (hooks) {
193195
await fillIn(AUTH_FORM.method, 'token');
194196
await click('[data-test-auth-submit]');
195197
});
198+
199+
test('it does not call renew-self after successful login with non-renewable token', async function (assert) {
200+
this.server.post(
201+
'/auth/token/renew-self',
202+
() => new Error('should not call renew-self directly after logging in')
203+
);
204+
205+
await visit('/vault/auth');
206+
await fillIn(AUTH_FORM.method, 'token');
207+
await fillIn(AUTH_FORM.token, rootToken);
208+
await click('[data-test-auth-submit]');
209+
assert.strictEqual(currentURL(), '/vault/dashboard');
210+
});
196211
});

0 commit comments

Comments
 (0)