-
Notifications
You must be signed in to change notification settings - Fork 48
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
Unable to re-authenticate (not refresh) using the same device key #139
Comments
The issue follows a very similar flow outlined in this other old issue #44 but I am getting a different error at the final step. Another user on the same thread commented with the SAME ERROR message but his remedy did not seem to help me. He is questioning the signature on GenerateDeviceVerifier(). I have tried |
Hi @bhoradc, were you able to reproduce the issue or do you need any additional information? Thanks! |
Hey @96malhar @ashishdhingra, do you know if this repo is being actively maintained or if I should be using a different AWS API for this? |
Hi @alfarok, Apologies for some silence here. I haven't got a chance to work on this one yet. I plan to work on reproducing it during this week. And will get back to you with further update or if any information is needed. Thank you. -->update - I have started working on the repro code for this one, hopefully will complete and have some update soon. Regards, |
Hello @alfarok, Can you check if setting
Regards, |
Thank you @bhoradc, I am able to re-authenticate now without creating a new device entry. I swear I thought I tried that combo but also refactored my logic from my original attempts so could have been a combination of things. Really appreciate your follow-up and assistance. For anyone else that comes across this -> A login attempt where no device key is present must use something similar to this: // Initialize first login
InitiateSrpAuthRequest authRequest = new InitiateSrpAuthRequest() { Password = password};
// Login
AuthFlowResponse authResponse = await User.StartWithSrpAuthAsync(authRequest).ConfigureAwait(true);
// Extract device metadata
var md = authResponse.AuthenticationResult.NewDeviceMetadata;
// Generate a verifier
var deviceVerifier = User.GenerateDeviceVerifier(md.DeviceGroupKey, password, md.DeviceKey);
// Confirm device
var confirmDeviceResponse = await User.ConfirmDeviceAsync(AccessToken, md.DeviceKey, DeviceName, DeviceVerifier.PasswordVerifier, DeviceVerifier.Salt); Attempts where an existing device key is present should use something like this: // Generate a verifier with cached device data
var deviceVerifier = User.GenerateDeviceVerifier(deviceGroup, password, deviceKey);
// Initialize subsequent logins while cache is present
InitiateSrpAuthRequest authRequest = new InitiateSrpAuthRequest()
{
Password = password,
DeviceGroupKey = deviceGroup,
DevicePass = password,
DeviceVerifier = deviceVerifier.Salt
};
// Login
AuthFlowResponse authResponse = await User.StartWithSrpAuthAsync(authRequest).ConfigureAwait(true); |
|
Describe the bug
I am attempting to use the aws-sdk-net-extensions-cognito library for Cognito authentication with device tracking enabled. The cloud formation properties on the User Pool for this configuration are:
I can successfully complete the following steps:
StartWithSrpAuthAsync
(generate a new device key)NewDeviceMetadata
to create aDeviceVerifier
which includesPasswordVerifier
andSalt
ConfirmDeviceAsync
which shows the new device for the user in the Cognito AWS Console dashboardStartWithRefreshTokenAuthAsync
to successfully get refresh tokensMy issue at this point is that signing out and attempting to sign back in fails using the device key from the previous session. I know I need to generate a new token but I shouldn't have to regenerate the device key on the same device. Currently, when I tried to login using the device key from the previous session I get the following error:
Here is my code for attempting to login using a local device key from the previous session:
I have a feeling it's related to the creation of
new InitiateSrpAuthRequest()
and the values I am providing. I was unable to find documentation around these parameter values. I was assumingDevicePass
is thePasswordVerifier
created byGenerateDeviceVerifier
andDeviceVerifier
is theSalt
fromGenerateDeviceVerifier
but the key names are confusing?TLDR: What values are expected for
DevicePass
andDeviceVerifier
or am I doing something else incorrectly?Expected Behavior
I can re-authenticate a user (not refresh) but use the same device key which will not create a new device for that user as long as they are on the same machine.
Current Behavior
"Incorrect username or password."
InitiateSrpAuthRequest()
Password
Password
,DeviceGroupKey
,DevicePass
andDeviceVerifier
which failsAWS .NET SDK and/or Package version used
Amazon.Extensions.CognitoAuthentication 2.5.2
(latest)Targeted .NET Platform
.NET Framework 4.8 & .NET 6.0
Operating System and version
Windows 10/11
The text was updated successfully, but these errors were encountered: