* fix(web): stop redirect loop when vault MFA step-up fails Signed-off-by: Samuel Schumacher <samuel.schumacher@werkspiel.de> Signed-off-by: Samuel Schumacher <schumacher@b1-systems.de> * fix(web): leave vault with a full page load after failed MFA step-up Returning to `/` in-app kept the vault clients and loaded vault spaces with the non-MFA token, which ended on the RUNTIME-BOOTSTRAP-040 crash page. Vault mode is fixed per page load, so reload outside the vault instead and show the MFA error message after the reload. The spaces load error handler no longer routes to the crash page while leaving. Also addresses review feedback: - use $pgettext with translator context for the error message - test that an expired user with a fresh marker is still redirected * fix(web): only treat a vault step-up as failed after the IdP answered it The step-up marker relied on a 5 minute TTL, so a user who went to the IdP, pressed back and opened the vault again got the error without ever seeing the IdP. The step-up request now carries its target as OIDC state; the sign-in callback picks it up and only the navigation right after the callback counts as the answer. The sessionStorage marker and the TTL are gone. Also addresses review feedback: - simplify the auth guard check to `redirect !== undefined` - drop the storage key re-export, the spec imports it from the helper Signed-off-by: Samuel Schumacher <schumacher@b1-systems.de> --------- Signed-off-by: Samuel Schumacher <samuel.schumacher@werkspiel.de> Signed-off-by: Samuel Schumacher <schumacher@b1-systems.de>
28 lines
771 B
TypeScript
28 lines
771 B
TypeScript
import {
|
|
isLeavingVaultAfterFailedStepUp,
|
|
vaultStepUpFailedKey
|
|
} from '../../../src/helpers/vaultStepUp'
|
|
|
|
describe('isLeavingVaultAfterFailedStepUp', () => {
|
|
beforeEach(() => {
|
|
sessionStorage.clear()
|
|
})
|
|
|
|
it('is false without a failed step-up', () => {
|
|
expect(isLeavingVaultAfterFailedStepUp()).toBe(false)
|
|
})
|
|
|
|
it('is true while a failed step-up is pending', () => {
|
|
sessionStorage.setItem(vaultStepUpFailedKey, 'true')
|
|
expect(isLeavingVaultAfterFailedStepUp()).toBe(true)
|
|
})
|
|
|
|
it('is false when sessionStorage is not accessible', () => {
|
|
vi.spyOn(Storage.prototype, 'getItem').mockImplementation(() => {
|
|
throw new Error('denied')
|
|
})
|
|
expect(isLeavingVaultAfterFailedStepUp()).toBe(false)
|
|
vi.restoreAllMocks()
|
|
})
|
|
})
|