Skip to content

Commit e32e657

Browse files
final pass
1 parent 082a9b6 commit e32e657

File tree

8 files changed

+33
-123
lines changed

8 files changed

+33
-123
lines changed

lib/idx/remediators/Base/SelectAuthenticator.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,19 @@ export class SelectAuthenticator<T extends SelectAuthenticatorValues = SelectAut
6060
const matchedOption = this.findMatchedOption(authenticators, options!);
6161
if (matchedOption) {
6262

63-
// const isAuthenticatorCurrent = (auth) => {
64-
// return auth && !auth.value?.resend
65-
// && auth.value.id === matchedOption.relatesTo?.id;
66-
// };
67-
68-
// // Don't select current authenticator (OKTA-612939)
69-
// // Follow up: OKTA-646147 - original fix caused different issue
70-
// const isCurrentAuthenticator = isAuthenticatorCurrent(context?.currentAuthenticator); // false
71-
// const isCurrentAuthenticatorEnrollment = isAuthenticatorCurrent(context?.currentAuthenticatorEnrollment); // true
72-
// return !isCurrentAuthenticator && !isCurrentAuthenticatorEnrollment; // false
63+
// fix for OKTA-612939 (below) seems to have caused a bug when trying to re-select authenticators
64+
// with multiple methodTypes. If `options.step` is passed, this remediation is explicitly being
65+
// invoked, therefore do not guard against auto-remediating the selected authenticator (OKTA-646147)
66+
if (this.options.step) {
67+
return true;
68+
}
7369

74-
return true;
70+
// Don't select current authenticator (OKTA-612939)
71+
const isCurrentAuthenticator = context?.currentAuthenticator
72+
&& context?.currentAuthenticator.value.id === matchedOption.relatesTo?.id;
73+
const isCurrentAuthenticatorEnrollment = context?.currentAuthenticatorEnrollment
74+
&& context?.currentAuthenticatorEnrollment.value.id === matchedOption.relatesTo?.id;
75+
return !isCurrentAuthenticator && !isCurrentAuthenticatorEnrollment;
7576
}
7677

7778
return false;
@@ -112,7 +113,6 @@ export class SelectAuthenticator<T extends SelectAuthenticatorValues = SelectAut
112113
.filter(authenticator => {
113114
return compareAuthenticators(authenticator, this.selectedAuthenticator) !== true;
114115
});
115-
// return { ...this.values, authenticators, authenticator: undefined };
116116
return { ...this.values, authenticators };
117117
}
118118

lib/oidc/introspect.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ export async function oidcIntrospect (sdk, kind: TokenKind, token?: Token) {
4444
else {
4545
issuer = (token as any)?.claims?.iss;
4646
}
47-
// issuer ??= sdk.options.issuer;
4847
issuer = issuer || sdk.options.issuer;
4948

5049
if (!clientId) {

samples/test/features/mfa-password-and-email-magic-link.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Feature: Multi-Factor Authentication with Password and Email Magic Link
1616
And she has inserted her password
1717
And her password is correct
1818
When she submits the form
19-
Then she is redirected to the "Verify Email" page
19+
Then she is redirected to the "Verify Email" page # fails here
2020
When she selects "Email" from the list of methods
2121
And she submits the form
2222
And she clicks the Email magic link

samples/test/features/mfa-password-and-email.feature

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Feature: Multi-Factor Authentication with Password and Email
1414
When she fills in her username
1515
And she fills in her correct password
1616
And she submits the form
17+
# fails here
1718
Then she is redirected to the "Verify Email" page
1819
When she selects "Email" from the list of methods
1920
And she submits the form
@@ -30,6 +31,7 @@ Feature: Multi-Factor Authentication with Password and Email
3031
And she has inserted her password
3132
And her password is correct
3233
When she submits the form
34+
# fails here
3335
Then she is redirected to the "Verify Email" page
3436
When she selects "Email" from the list of methods
3537
And she submits the form

samples/test/steps/after.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,17 @@
1212

1313
/* eslint-disable complexity */
1414

15+
// import { After, AfterStep, Status } from '@cucumber/cucumber';
1516
import { After } from '@cucumber/cucumber';
1617
import ActionContext from '../support/context';
1718
import deleteSelfEnrolledUser from '../support/management-api/deleteSelfEnrolledUser';
1819

20+
// NOTE: can be used to debug cucumber tests, just uncomment
21+
// AfterStep(async ({ result }) => {
22+
// if (result.status === Status.FAILED) {
23+
// await browser.debug();
24+
// }
25+
// });
1926

2027
// Comment out this after hook to persist test context
2128
// Extend the hook timeout to fight against org rate limit

samples/test/support/selectors/SelectAuthenticatorMethod.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ class SelectAuthenticatorMethod extends PageWithTitle {
1717
title = 'Select authenticator method';
1818

1919
get pageTitle() {return '#page-title-header';}
20-
// get pageTitle() {return '#select-authenticator-page-title-header';}
2120

2221
get options() { return '#authenticator-method-options'; }
2322
get submit() { return '#verify-form button[type=submit]';}

test/spec/idx/authenticate.ts

Lines changed: 0 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -2524,94 +2524,4 @@ describe('idx/authenticate', () => {
25242524
});
25252525
});
25262526

2527-
describe('clears values.authenticator', () => {
2528-
2529-
beforeEach(() => {
2530-
const selectAuthenticatorResponse = IdxResponseFactory.build({
2531-
neededToProceed: [
2532-
SelectAuthenticatorAuthenticateRemediationFactory.build({
2533-
value: [
2534-
AuthenticatorValueFactory.build({
2535-
options: [
2536-
EmailAuthenticatorOptionFactory.build(),
2537-
]
2538-
})
2539-
]
2540-
})
2541-
],
2542-
});
2543-
const verifyAuthenticatorResponse = IdxResponseFactory.build({
2544-
neededToProceed: [
2545-
VerifyEmailRemediationFactory.build()
2546-
],
2547-
context: IdxContextFactory.build({
2548-
authenticatorEnrollments: {
2549-
type: 'array',
2550-
value: [
2551-
EmailAuthenticatorFactory.build()
2552-
]
2553-
}
2554-
})
2555-
});
2556-
2557-
Object.assign(testContext, {
2558-
selectAuthenticatorResponse,
2559-
verifyAuthenticatorResponse,
2560-
});
2561-
});
2562-
2563-
// OKTA-609234 - specifically confirm these remediation steps
2564-
fit('clears values.authenticator after being consumed to prevent auto-remediating', async () => {
2565-
const {
2566-
authClient,
2567-
selectAuthenticatorResponse,
2568-
verifyAuthenticatorResponse
2569-
} = testContext;
2570-
2571-
chainResponses([
2572-
selectAuthenticatorResponse,
2573-
verifyAuthenticatorResponse
2574-
]);
2575-
2576-
jest.spyOn(selectAuthenticatorResponse, 'proceed');
2577-
jest.spyOn(mocked.introspect, 'introspect').mockResolvedValue(selectAuthenticatorResponse);
2578-
2579-
const res = await authenticate(authClient, {
2580-
username: 'foo',
2581-
authenticator: AuthenticatorKey.OKTA_EMAIL,
2582-
methodType: 'email'
2583-
});
2584-
2585-
expect(selectAuthenticatorResponse.proceed).toHaveBeenCalledWith('select-authenticator-authenticate', {
2586-
authenticator: { id: 'id-email' }
2587-
});
2588-
expect(res.status).toBe(IdxStatus.PENDING);
2589-
expect(res.nextStep).toEqual({
2590-
name: 'challenge-authenticator',
2591-
type: 'email',
2592-
authenticator: {
2593-
displayName: 'Email',
2594-
id: expect.any(String),
2595-
key: 'okta_email',
2596-
methods: [
2597-
{ type: 'email' }
2598-
],
2599-
type: 'email',
2600-
},
2601-
authenticatorEnrollments: [{
2602-
id: expect.any(String),
2603-
displayName: 'Email',
2604-
key: 'okta_email',
2605-
type: 'email',
2606-
methods: [
2607-
{ type: 'email' }
2608-
],
2609-
}],
2610-
inputs: [
2611-
{ name: 'verificationCode', type: 'string', label: 'Enter code', required: true },
2612-
]
2613-
});
2614-
});
2615-
});
2616-
26172527
});

test/spec/idx/remediators/SelectAuthenticator.ts

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('remediators/Base/SelectAuthenticator', () => {
1919
AuthenticatorValueFactory.build({
2020
options: [
2121
PhoneAuthenticatorOptionFactory.params({
22-
// prevent resolving of authenticator by `relatesTo` in purpose
22+
// prevent resolving of authenticator by `relatesTo` on purpose
2323
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2424
_authenticator: 'cant_be_resolved' as any
2525
}).build(),
@@ -39,7 +39,7 @@ describe('remediators/Base/SelectAuthenticator', () => {
3939

4040
describe('remediators/SelectAuthenticatorEnroll', () => {
4141
describe('canRemediate', () => {
42-
xit('retuns false if matched authenticator is already the current one', () => {
42+
it('retuns false if matched authenticator is already the current one', () => {
4343
const currentAuthenticator = EmailAuthenticatorFactory.build();
4444
const remediation = SelectAuthenticatorEnrollRemediationFactory.build({
4545
value: [
@@ -69,7 +69,7 @@ describe('remediators/SelectAuthenticatorEnroll', () => {
6969

7070
describe('remediators/SelectAuthenticatorAuthenticate', () => {
7171
describe('canRemediate', () => {
72-
xit('retuns false if matched authenticator is already the current one', () => {
72+
it('retuns false if matched authenticator is already the current one', () => {
7373
const currentAuthenticatorEnrollment = PhoneAuthenticatorFactory.build();
7474
const remediation = SelectAuthenticatorAuthenticateRemediationFactory.build({
7575
value: [
@@ -95,36 +95,29 @@ describe('remediators/SelectAuthenticatorAuthenticate', () => {
9595
expect(r.canRemediate()).toBe(true);
9696
});
9797

98-
it('returns true if matched authenticator has a resend form', () => {
99-
const phoneAuthenticator = PhoneAuthenticatorFactory.build();
98+
// Fix for OKTA-646147
99+
it('retuns true if `options.step` is explicitly passed', () => {
100+
const currentAuthenticatorEnrollment = PhoneAuthenticatorFactory.build();
100101
const remediation = SelectAuthenticatorAuthenticateRemediationFactory.build({
101102
value: [
102103
AuthenticatorValueFactory.build({
103104
options: [
104105
PhoneAuthenticatorOptionFactory.params({
105-
_authenticator: phoneAuthenticator,
106+
_authenticator: currentAuthenticatorEnrollment,
106107
}).build(),
107108
]
108109
}),
109110
]
110111
});
111112
const context = IdxContextFactory.build({
112113
currentAuthenticatorEnrollment: {
113-
value: {
114-
...phoneAuthenticator,
115-
resend: ResendAuthenticatorFactory.build(),
116-
}
117-
},
118-
authenticatorEnrollments: {
119-
value: [phoneAuthenticator]
120-
},
121-
currentAuthenticator: {}
114+
value: currentAuthenticatorEnrollment
115+
}
122116
});
123-
124117
const authenticators = [
125-
phoneAuthenticator,
118+
currentAuthenticatorEnrollment,
126119
];
127-
const r = new SelectAuthenticatorAuthenticate(remediation, { authenticators });
120+
const r = new SelectAuthenticatorAuthenticate(remediation, { authenticators }, { step: 'select-authenticator-authenticate'});
128121
expect(r.canRemediate(context)).toBe(true);
129122
expect(r.canRemediate()).toBe(true);
130123
});

0 commit comments

Comments
 (0)