-
Notifications
You must be signed in to change notification settings - Fork 126
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
Conversation
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
This reverts commit fffc834.
@@ -62,14 +63,6 @@ import kotlinx.coroutines.launch | |||
import kotlinx.coroutines.withContext | |||
import java.io.Serializable | |||
|
|||
/** |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) | |||
|
|||
/** |
There was a problem hiding this comment.
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 -> { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?) |
There was a problem hiding this comment.
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 | |||
|
|||
/** |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
Include those commits
![image](https://private-user-images.githubusercontent.com/111055878/287780661-3b0eccec-b362-478c-b7c5-2b05e0f7cd6a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxMDg2MjQsIm5iZiI6MTczOTEwODMyNCwicGF0aCI6Ii8xMTEwNTU4NzgvMjg3NzgwNjYxLTNiMGVjY2VjLWIzNjItNDc4Yy1iN2M1LTJiMDVlMGY3Y2Q2YS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjA5JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIwOVQxMzM4NDRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1mMjRjZjk1ZWEyMThiNzQ3YjI2NzI5MDliMzZjZWExZWI2YzBmYTdmZGI3ZGIzMmUzNmMzNGMzOWU2MTlmMjc0JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.3r86qBHrw5ROh3A48708cnaHEqjyv_qY_x1jCbEymOI)