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

Reset password for native auth #1950

Merged
merged 6 commits into from
Nov 30, 2023
Merged

Reset password for native auth #1950

merged 6 commits into from
Nov 30, 2023

Conversation

SaurabhMSFT
Copy link
Contributor

@SaurabhMSFT SaurabhMSFT commented Nov 10, 2023

This PR includes the work for self service password reset related features of Native Auth. No new dependencies have been added as part of this PR.

A technical overview of Native Auth is available at https://dev.azure.com/IdentityDivision/DevEx/_git/AuthLibrariesApiReview?path=/%5BAndroid%5D%20Native%20authentication/technical_overview.md&version=GBsammy/native-authentication&_a=preview

A companion PR in MSAL is AzureAD/microsoft-authentication-library-common-for-android#2230

@github-actions github-actions bot added the msal label Nov 10, 2023
SaurabhMSFT added a commit to AzureAD/microsoft-authentication-library-common-for-android that referenced this pull request Nov 28, 2023
This PR includes the work for self service password reset related
features of Native Auth. No new dependencies have been added as part of
this PR.

A technical overview of Native Auth is available at
https://dev.azure.com/IdentityDivision/DevEx/_git/AuthLibrariesApiReview?path=/%5BAndroid%5D%20Native%20authentication/technical_overview.md&version=GBsammy/native-authentication&_a=preview

A companion PR in MSAL is
AzureAD/microsoft-authentication-library-for-android#1950
@@ -151,4 +152,23 @@ interface INativeAuthPublicClientApplication : IPublicClientApplication {
* @throws MsalClientException if an account is already signed in.
*/
fun signUpUsingPassword(username: String, password: CharArray, attributes: UserAttributes? = null, callback: NativeAuthPublicClientApplication.SignUpUsingPasswordCallback)

/**
* Reset password for the account starting from a username; Kotlin coroutines variant.
Copy link
Contributor

Choose a reason for hiding this comment

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

What do we mean by "starting from"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We start the reset password flow with username. Some flows like signup or signin can be started either with username only or with username and password.

*
* @param error [com.microsoft.identity.client.statemachine.Error]
*/
class UnexpectedError(override val error: com.microsoft.identity.client.statemachine.Error) :
Copy link
Contributor

Choose a reason for hiding this comment

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

So the only error expected for a reset password operation is an Unexpected error? (I don't see any other error results here)

Copy link
Contributor

Choose a reason for hiding this comment

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

Are there no expected errors?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a ErrorResult class in the base class Result to denote expected errors.


/**
* UserNotFound ErrorResult, which indicates there was no account found with the provided email.
* The flow should be restarted.
Copy link
Contributor

Choose a reason for hiding this comment

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

So the account will be found upon restart of the flow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its possible the user started this flow with incorrect email address and thats why they got the UserNotFound error. Once the flow is restarted with correct email address then it will be found.

* @param sentTo the email/phone number the code was sent to.
* @param channel channel(email/phone) the code was sent through.
*/
class Success(
Copy link
Contributor

Choose a reason for hiding this comment

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

So you can only get success in this operation? (I don't see any other result types here)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The other result types in the base class Result.

Comment on lines +160 to +178
sealed interface ResetPasswordSubmitPasswordResult : Result {
/**
* InvalidPassword ErrorResult, which indicates the new password provided by the user is not acceptable to the server.
* The password should be re-submitted.
*
* @param error [com.microsoft.identity.client.statemachine.InvalidPasswordError]
*/
class InvalidPassword(
override val error: InvalidPasswordError
) : ResetPasswordSubmitPasswordResult, Result.ErrorResult(error = error)
/**
* PasswordResetFailed ErrorResult, which indicates the password reset flow failed.
*
* @param error [com.microsoft.identity.client.statemachine.GeneralError]
*/
class PasswordResetFailed(
override val error: GeneralError
) : ResetPasswordSubmitPasswordResult, Result.ErrorResult(error = error)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

What about success result? also what about unexpected failures?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The success and error result are in the base class Result. The ResetPasswordSubmitPasswordResult has wrapped classes only for the reset password submit API specific cases.

* Submits a new password to the server; callback variant.
*
* @param password The password to submit.
* @param callback [com.microsoft.identity.client.statemachine.states.ResetPasswordPasswordRequiredState.SubmitPasswordCallback] to receive the result on.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this going to link to the SubmitPasswordCallback file from within the Javadoc? Generally the @link is used to create these links

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this will work. Kotlin allows linking with square brackets. https://kotlinlang.org/docs/kotlin-doc.html#inline-markup

@SaurabhMSFT SaurabhMSFT merged commit 8cfb06e into ciam-feature Nov 30, 2023
9 checks passed
@SaurabhMSFT SaurabhMSFT deleted the saugautam/2642914 branch November 30, 2023 17:26
SaurabhMSFT added a commit that referenced this pull request Dec 6, 2023
This PR is to merge the SignIn, SIgnup and SSPR code into dev branch.
This code was previously reviewed in #1897, #1919, #1949 and #1950 .

A technical overview of Native Auth is available at
https://dev.azure.com/IdentityDivision/DevEx/_git/AuthLibrariesApiReview?path=/%5BAndroid%5D%20Native%20authentication/technical_overview.md&version=GBsammy/native-authentication&_a=preview

A companion PR in common repo is
AzureAD/microsoft-authentication-library-common-for-android#2233

---------

Co-authored-by: melissaahn <[email protected]>
Co-authored-by: iamgusain <[email protected]>
Co-authored-by: Dome Pongmongkol <[email protected]>
Co-authored-by: Sowmya Malayanur <[email protected]>
Co-authored-by: Mohit <[email protected]>
Co-authored-by: tanmaymanolkar1 <[email protected]>
Co-authored-by: amoyixi <[email protected]>
Co-authored-by: yixilin <[email protected]>
Co-authored-by: fadidurah <[email protected]>
Co-authored-by: Dean Xu <[email protected]>
Co-authored-by: Neha Goel <[email protected]>
Co-authored-by: Dome Pongmongkol <[email protected]>
Co-authored-by: pedro romero vargas <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants