Update NativeAuth imports and added UI Automation intent based initialisation#59
Update NativeAuth imports and added UI Automation intent based initialisation#59spetrescu84 wants to merge 4 commits into
Conversation
| import com.azuresamples.msalnativeauthandroidkotlinsampleapp.databinding.FragmentEmailPasswordBinding | ||
| import com.microsoft.identity.client.PublicClientApplication | ||
| import com.microsoft.identity.common.java.nativeauth.providers.NativeAuthRequestInterceptor | ||
| import com.microsoft.identity.nativeauth.NativeAuthRequestInterceptor; |
| import com.microsoft.identity.client.PublicClientApplication | ||
| import com.microsoft.identity.common.java.nativeauth.providers.NativeAuthRequestInterceptor | ||
| import com.microsoft.identity.nativeauth.NativeAuthRequestInterceptor; | ||
| import com.microsoft.identity.common.java.util.StringUtil |
There was a problem hiding this comment.
can we also remove this one? com.microsoft.identity.common.java.util.StringUtil
There was a problem hiding this comment.
Removed and from mfafragment.kt
-Removed adding flat ussername as it's not yet merged into MSAL so build fails -update to attributeName as that's the correct value
| val username = binding.usernameText.text.toString() | ||
|
|
||
| val attributes = UserAttributes.Builder() | ||
| .flatUsername(username) |
There was a problem hiding this comment.
Added comment to description also - Reverted changes to flatUsername to prevent building error as PR for alias is not yet merged - AzureAD/microsoft-authentication-library-for-android#2513
Will add back once that PR is merged, but currently Sample App doesn't compile as .flatUsername is not in the MSAL package/nor this branch.
| parameters.password = password | ||
| val actionResult: SignInResult = authClient.signIn(parameters) | ||
| binding.passwordText.text?.clear() | ||
| StringUtil.overwriteWithNull(password) |
There was a problem hiding this comment.
Can we wrap the StringUtil in our StringUtil (new) class for eliminating hard-coded values? Also, the other classes still call StringUtil.overwriteWithNull(password).
There was a problem hiding this comment.
Not sure what you mean exactly. The only StringUtil class I see is in common and as @antrix1989 said we shouldn't use that. Indeed, I see now that it still existed in a few places in this sample app so I've done a commit to remove it completely. Let me know if that works or we should have a new StringUtil in MSAL or something like that.
There was a problem hiding this comment.
We can create StringUtil in our Sample App later, to move hard-coded usages but now not important thing.
| // Custom implementation for Flat Username / Alias | ||
| if (actionResult.requiredAttributes.size == 1 && | ||
| actionResult.requiredAttributes.any { it.name == "flatusername" } | ||
| actionResult.requiredAttributes.any { it.attributeName == "flatusername" } |
There was a problem hiding this comment.
name also works, right?
There was a problem hiding this comment.
in Android Complete and pipeline it doesn't because of how it's imported
Changes
NativeAuthRequestInterceptorto use the new package locationcom.microsoft.identity.nativeauth.NativeAuthRequestInterceptorAuthClientandMainActivitynow acceptclientIdandauthorityUrlvia intent extras, enabling UI automation tests to inject test tenant configuration at runtime without modifying bundled config filesStringUtildependency — replacedStringUtil.overwriteWithNull(password)with Kotlin's built-inpassword.fill('\u0000')to avoid pulling in the common library dependencyContext
These changes support the new NativeAuth UI automation tests in
android-complete(PR #437). The test launches NativeAuthSampleApp viaadbwith intent extras containing the CIAM tenant config, allowing end-to-end sign-in validation in the 1ES weekly pipeline via Firebase Test Lab.