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(auth): Fix for when alias is used to sign in and deviceKey is stored with the entered username instead of retrieved username #2614

Merged
merged 5 commits into from
Oct 24, 2023

Conversation

gpanshu
Copy link
Contributor

@gpanshu gpanshu commented Oct 23, 2023

  • PR title and description conform to Pull Request guidelines.

Issue #, if available: #2609

Description of changes:

When a user signs in with their alias instead of a username and the userpool is not configured to sign in with username, cognito assigns a username to that user (generally a generated UUID). However this breaks the current flow in a way that device ID gets generated each time as there is no stored device information for the new generated username for when we have to do respondToAuthChallenge we use the username returned from the service and not the username that was entered by the user.
This PR will fix that flow for Custom Auth (with/without SRP and SRP).

Important to note:

This fix does not fix device tracking for when AuthFlow is USER_PASSWORD_AUTH as InitiateAuth in user_password_auth does not have access to deviceTracking.

How did you test these changes?
(Please add a line here how the changes were tested)

Documentation update required?

  • No
  • Yes (Please include a PR link for the documentation update)

General Checklist

  • Added Unit Tests
  • Added Integration Tests
  • Security oriented best practices and standards are followed (e.g. using input sanitization, principle of least privilege, etc)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@codecov-commenter
Copy link

codecov-commenter commented Oct 23, 2023

Codecov Report

Merging #2614 (0b39eab) into main (e273ba8) will decrease coverage by 0.01%.
The diff coverage is 4.16%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

@@            Coverage Diff             @@
##             main    #2614      +/-   ##
==========================================
- Coverage   41.71%   41.71%   -0.01%     
==========================================
  Files         900      900              
  Lines       28852    28865      +13     
  Branches     4098     4104       +6     
==========================================
+ Hits        12037    12040       +3     
- Misses      15491    15497       +6     
- Partials     1324     1328       +4     

Copy link
Contributor

@tylerjroach tylerjroach left a comment

Choose a reason for hiding this comment

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

1 comment suggestion but otherwise good.

Copy link
Contributor

@tylerjroach tylerjroach left a comment

Choose a reason for hiding this comment

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

See comment on deviceMetadata

Copy link

@israx israx left a comment

Choose a reason for hiding this comment

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

LGTM!

@gpanshu gpanshu enabled auto-merge (squash) October 24, 2023 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment