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

Native auth extensibility #1968

Closed
wants to merge 26 commits into from
Closed

Native auth extensibility #1968

wants to merge 26 commits into from

Conversation

Yuki-YuXin
Copy link
Contributor

Include those commits
image

SaurabhMSFT and others added 13 commits October 3, 2023 19:35
The code in this pull request is for the base work needed to support Signup, SignIn and SSPR features for Native Auth. Any class that is used by at least two of the features has been included in this pull request.

This pull request introduces kotlin co routines libraries as dependencies for msal and its associated test project. Further mockk, mockito libraries have been added as dependencies for test projects.

A companion PR in the MSAL Common repository is
AzureAD/microsoft-authentication-library-common-for-android#2166
ciam-feature will be update to 82f5153 commit of dev branch

---------

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]>
ciam-feature is updated to 991c541
commit from dev branch

---------

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]>
This PR includes the work for SignIn relates features of Native Auth

Companion PR in MSAL Common repo is
AzureAD/microsoft-authentication-library-common-for-android#2207
This PR includes the work for Signup 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 Common is
AzureAD/microsoft-authentication-library-common-for-android#2229
ciam-feature is updated to 9735ed9
commit from dev branch

---------

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]>
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
@Yuki-YuXin Yuki-YuXin requested a review from a team as a code owner December 4, 2023 17:26
@github-actions github-actions bot added the msal label Dec 4, 2023
@Yuki-YuXin Yuki-YuXin changed the base branch from saugautam/2642915 to dev December 6, 2023 10:45
@Yuki-YuXin Yuki-YuXin closed this Dec 7, 2023
@Yuki-YuXin Yuki-YuXin reopened this Dec 7, 2023
@Yuki-YuXin Yuki-YuXin changed the base branch from dev to saugautam/2642915 December 7, 2023 15:16
@@ -62,14 +63,6 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.io.Serializable

/**
Copy link
Contributor

Choose a reason for hiding this comment

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

Why were these comments removed?

)
}
}
}
}
}

/**
* Native Auth uses a state machine to denote state and transitions for a user.
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

@@ -454,14 +425,6 @@ class SignUpPasswordRequiredState internal constructor(
}
}

/**
* Native Auth uses a state machine to denote state and transitions for a user.
Copy link
Contributor

Choose a reason for hiding this comment

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

And here

)
}
}
}
}
}

/**
* Native Auth uses a state machine to denote state and transitions for a user.
Copy link
Contributor

Choose a reason for hiding this comment

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

And herre

import com.microsoft.identity.client.statemachine.states.SignInAfterSignUpState
import com.microsoft.identity.client.statemachine.states.SignUpAttributesRequiredState
import com.microsoft.identity.client.statemachine.states.SignUpCodeRequiredState
import com.microsoft.identity.client.statemachine.states.SignUpPasswordRequiredState

/**
* Sign up result, produced by
* Results for native sign up flows.
* TODO add documentation & links to learn.microsoft.com
Copy link
Contributor

Choose a reason for hiding this comment

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

can you remove this todo?

@@ -109,66 +109,15 @@ interface INativeAuthPublicClientApplication : IPublicClientApplication {
*/
fun signInUsingPassword(username: String, password: CharArray, scopes: List<String>? = null, callback: NativeAuthPublicClientApplication.SignInUsingPasswordCallback)

/**
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you restore deleted comments from this file?

@@ -343,38 +323,53 @@ class NativeAuthPublicClientApplication(
)
)
}
is SignInCommandResult.InvalidCredentials -> {
is SignInCommandResult.Complete -> {
Copy link
Contributor

Choose a reason for hiding this comment

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

We can merge the clauses for Complete, InvalidCredentials and UnknownError into else block. Or at least Complete, InvalidCredentials can be merged into a single else block.

import com.microsoft.identity.client.statemachine.states.ResetPasswordCodeRequiredState
import com.microsoft.identity.client.statemachine.states.ResetPasswordPasswordRequiredState

/**
* Results for native Self-service password reset flows.
* TODO add documentation & links to learn.microsoft.com
Copy link
Contributor

Choose a reason for hiding this comment

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

We should remove this TODO as the link to documentation has been added below.


/**
* BaseState is the base class for various states in the Native Auth state machine.
*/
abstract class BaseState(internal open val flowToken: String?)
abstract class BaseState(internal open val flowToken: String?)
Copy link
Contributor

Choose a reason for hiding this comment

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

New line should be added at the end.

@@ -55,13 +56,6 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.io.Serializable

/**
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you restore this comment

)
}
}
}
}

/**
* ResendCodeCallback receives the result for submit code for Reset Password for Native Auth
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you restore this comment

)
}
}
}
}
}

/**
* Native Auth uses a state machine to denote state and transitions for a user.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you restore this comment?

@@ -258,7 +270,11 @@ public void onError(@NonNull BaseException exception) {
};
application.signInUsingPassword(username, password, null, callback);
// 1a. Server returns invalid password error
assertTrue(signInResult.get(30, TimeUnit.SECONDS) instanceof SignInResult.InvalidCredentials);
SignInUsingPasswordResult result = signInResult.get(30, TimeUnit.SECONDS);
assertTrue(result instanceof SignInUsingPasswordError);
Copy link
Contributor

Choose a reason for hiding this comment

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

We should avoid using assertTrue where we are no comparing a boolean object. If assertTrue fails in this case then we won't know from the test run about the actual class of result. Below shows an example using assertThat

https://stackoverflow.com/questions/12404650/assert-an-object-is-a-specific-type

Base automatically changed from saugautam/2642915 to dev December 13, 2023 16:48
@SaurabhMSFT SaurabhMSFT requested a review from a team as a code owner December 13, 2023 16:48
@Yuki-YuXin Yuki-YuXin closed this Dec 13, 2023
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