Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix idx recoverpassword flow - OKTA-452787 #1032

Closed

Conversation

shuowu-okta
Copy link
Contributor

@shuowu-okta shuowu-okta commented Dec 13, 2021

  • Fixes recoverPassword flow when org policy is set as identifier first by auto selecting password authenticator and triggering currentAuthenticatorEnrollment-recover action.
  • Removes flow monitor classes: once values for each remediation can be properly handled/removed, the flowMonitor logic won't be needed any more.
  • Adds unit tests for idx.recoverPassword to cover id first scenario.
  • Updates cucumber tests to better protect recover password flow.
  • Adds bacon task to run cucumber tests against id-first org.

@shuowu-okta shuowu-okta marked this pull request as draft December 13, 2021 20:24
@codecov-commenter
Copy link

codecov-commenter commented Dec 13, 2021

Codecov Report

Merging #1032 (9d1c49e) into master (65a0ba0) will decrease coverage by 0.29%.
The diff coverage is 93.75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1032      +/-   ##
==========================================
- Coverage   92.83%   92.54%   -0.30%     
==========================================
  Files         138      134       -4     
  Lines        3770     3675      -95     
  Branches      784      754      -30     
==========================================
- Hits         3500     3401      -99     
- Misses        270      274       +4     
Impacted Files Coverage Δ
lib/idx/flow/index.ts 100.00% <ø> (ø)
lib/idx/remediators/Identify.ts 100.00% <ø> (+13.04%) ⬆️
lib/idx/run.ts 97.43% <ø> (-0.10%) ⬇️
lib/idx/cancel.ts 50.00% <33.33%> (-16.67%) ⬇️
lib/idx/remediate.ts 94.94% <88.88%> (+1.08%) ⬆️
lib/idx/remediators/Base/Remediator.ts 82.17% <95.65%> (-10.13%) ⬇️
lib/idx/remediators/Base/AuthenticatorData.ts 97.82% <96.29%> (+2.82%) ⬆️
lib/idx/flow/FlowSpecification.ts 100.00% <100.00%> (ø)
lib/idx/remediators/AuthenticatorEnrollmentData.ts 100.00% <100.00%> (ø)
...b/idx/remediators/AuthenticatorVerificationData.ts 88.23% <100.00%> (-11.77%) ⬇️
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 65a0ba0...9d1c49e. Read the comment docs.

@@ -48,29 +48,15 @@ export function getRemediator(

const T = remediators[remediation.name];
remediator = new T(remediation, values);
if (flowMonitor.isRemediatorCandidate(remediator, idxRemediations, values)) {
Copy link
Contributor

@jaredperreault-okta jaredperreault-okta Dec 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how would we filter out remediations that are valid within the idxResponse, but don't match the desired flow?

I had to do this for idx.unlockAccount, when remediations were:

0. identify
1. select-enroll-profile
2. unlock-account

If I called idx.unlockAccount({username: 'foo', authenticator: '...'}), auth-js would attempt to auto-remediate /identify, because username was present. To prevent this, I added:

  isRemediatorCandidate(remediator, remediations?, values?) {
    const prevRemediatorName = this.previousRemediator?.getName();
    const remediatorName = remediator.getName();

    // required to prevent /identify from auto-remediating when 'username' passed
    if (remediatorName === 'identify' && !prevRemediatorName) {
      return false;
    }
....

https://github.com/okta/okta-auth-js/pull/1030/files#diff-f90ddef32a0b8883f13e83cb687f25669055748ac81a9b5355319dbf5475ca9cR21

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was hoping to use isRemediatorCandidate() check for picking next remediation after polling:

- enroll-poll
- select-enrollment-channel <-

Is there a suggested way to pick non-first remediation from the list?

@shuowu-okta shuowu-okta force-pushed the sw-OKTA-452787-fix-idx-recoverpassword-flow branch from 4fe3d22 to ee3bbc3 Compare December 16, 2021 21:15
@shuowu shuowu marked this pull request as ready for review December 22, 2021 16:43
@shuowu-okta shuowu-okta force-pushed the sw-OKTA-452787-fix-idx-recoverpassword-flow branch from e79ca2c to 7f61d95 Compare January 5, 2022 17:26
@@ -92,6 +92,7 @@ export default function App() {
const newTransaction = flowMethod === 'idp'
? await oktaAuth.idx.startTransaction()
: await oktaAuth.idx[flowMethod]();
console.log('Transaction:', newTransaction);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's in test app for debugging purpose, I added it on purpose, but in the future we can add some logging logic for idx flow, and hide it behind the devMode flag.

Copy link
Contributor

@aarongranick-okta aarongranick-okta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

eng-prod-CI-bot-okta pushed a commit that referenced this pull request Jan 5, 2022
OKTA-452787
<<<Jenkins Check-In of Tested SHA: 9d1c49e for eng_productivity_ci_bot_okta@okta.com>>>
Artifact: okta-auth-js
Files changed count: 31
PR Link: "#1032"
shuowu added a commit that referenced this pull request Jan 7, 2022
eng-prod-CI-bot-okta pushed a commit that referenced this pull request Jan 7, 2022
OKTA-458631
<<<Jenkins Check-In of Tested SHA: ba58fe6 for eng_productivity_ci_bot_okta@okta.com>>>
Artifact: okta-auth-js
Files changed count: 1
PR Link: "#1052"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants