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

SignIn code for Native Auth #1919

Merged
merged 13 commits into from
Nov 9, 2023
2 changes: 1 addition & 1 deletion common
Submodule common updated 72 files
+22 −0 changelog.txt
+1 −0 common/build.gradle
+16 −20 common/src/main/java/com/microsoft/identity/common/internal/activebrokerdiscovery/BrokerDiscoveryClient.kt
+38 −19 .../src/main/java/com/microsoft/identity/common/internal/activebrokerdiscovery/BrokerDiscoveryClientFactory.kt
+7 −1 common/src/main/java/com/microsoft/identity/common/internal/broker/BrokerActivity.java
+7 −1 common/src/main/java/com/microsoft/identity/common/internal/broker/InstallCertActivityLauncher.java
+66 −0 common/src/main/java/com/microsoft/identity/common/internal/commands/SignInResendCodeCommand.kt
+65 −0 common/src/main/java/com/microsoft/identity/common/internal/commands/SignInStartCommand.kt
+65 −0 common/src/main/java/com/microsoft/identity/common/internal/commands/SignInSubmitCodeCommand.kt
+66 −0 common/src/main/java/com/microsoft/identity/common/internal/commands/SignInSubmitPasswordCommand.kt
+66 −0 common/src/main/java/com/microsoft/identity/common/internal/commands/SignInWithSLTCommand.kt
+783 −3 common/src/main/java/com/microsoft/identity/common/internal/controllers/NativeAuthMsalController.kt
+37 −0 common/src/main/java/com/microsoft/identity/common/internal/fido/AbstractFidoChallengeHandler.kt
+171 −0 common/src/main/java/com/microsoft/identity/common/internal/util/CommandUtil.java
+0 −2 common/src/test/java/com/microsoft/identity/common/MicrosoftStsAccountCredentialAdapterTest.java
+53 −0 ...on/src/test/java/com/microsoft/identity/common/internal/activebrokerdiscovery/BrokerDiscoveryClientTests.kt
+23 −0 ...n/src/test/java/com/microsoft/identity/common/internal/providers/microsoft/nativeauth/utils/ApiConstants.kt
+438 −0 ...t/java/com/microsoft/identity/common/internal/providers/microsoft/nativeauth/utils/CommandResultUtilTest.kt
+75 −6 ...crosoft/identity/common/java/commands/parameters/nativeauth/AcquireTokenNoFixedScopesCommandParameters.java
+6 −0 ...main/com/microsoft/identity/common/java/commands/parameters/nativeauth/BaseNativeAuthCommandParameters.java
+50 −0 ...ain/com/microsoft/identity/common/java/commands/parameters/nativeauth/BaseSignInTokenCommandParameters.java
+45 −0 ...in/com/microsoft/identity/common/java/commands/parameters/nativeauth/SignInResendCodeCommandParameters.java
+45 −0 ...rc/main/com/microsoft/identity/common/java/commands/parameters/nativeauth/SignInStartCommandParameters.java
+45 −0 ...icrosoft/identity/common/java/commands/parameters/nativeauth/SignInStartUsingPasswordCommandParameters.java
+51 −0 ...in/com/microsoft/identity/common/java/commands/parameters/nativeauth/SignInSubmitCodeCommandParameters.java
+51 −0 ...om/microsoft/identity/common/java/commands/parameters/nativeauth/SignInSubmitPasswordCommandParameters.java
+20 −15 .../main/com/microsoft/identity/common/java/commands/parameters/nativeauth/SignInWithSLTCommandParameters.java
+48 −0 common4j/src/main/com/microsoft/identity/common/java/constants/FidoConstants.kt
+8 −0 common4j/src/main/com/microsoft/identity/common/java/controllers/BaseController.java
+25 −0 common4j/src/main/com/microsoft/identity/common/java/controllers/ExceptionAdapter.java
+60 −0 common4j/src/main/com/microsoft/identity/common/java/controllers/results/INativeAuthCommandResult.kt
+71 −0 common4j/src/main/com/microsoft/identity/common/java/controllers/results/ResetPasswordCommandResult.kt
+65 −0 common4j/src/main/com/microsoft/identity/common/java/controllers/results/SignInCommandResult.kt
+24 −2 common4j/src/main/com/microsoft/identity/common/java/eststelemetry/PublicApiId.java
+1 −1 common4j/src/main/com/microsoft/identity/common/java/exception/ClientException.java
+11 −0 common4j/src/main/com/microsoft/identity/common/java/exception/ErrorStrings.java
+39 −0 common4j/src/main/com/microsoft/identity/common/java/exception/RefreshTokenNotFoundException.kt
+0 −1 common4j/src/main/com/microsoft/identity/common/java/logging/DiagnosticContext.java
+10 −1 common4j/src/main/com/microsoft/identity/common/java/opentelemetry/AttributeName.java
+2 −1 common4j/src/main/com/microsoft/identity/common/java/opentelemetry/SpanName.java
+9 −0 common4j/src/main/com/microsoft/identity/common/java/providers/nativeauth/NativeAuthConstants.kt
+157 −2 common4j/src/main/com/microsoft/identity/common/java/providers/nativeauth/NativeAuthOAuth2Configuration.kt
+53 −1 common4j/src/main/com/microsoft/identity/common/java/providers/nativeauth/NativeAuthOAuth2Strategy.kt
+7 −1 common4j/src/main/com/microsoft/identity/common/java/providers/nativeauth/NativeAuthOAuth2StrategyFactory.kt
+169 −0 common4j/src/main/com/microsoft/identity/common/java/providers/nativeauth/NativeAuthRequestProvider.kt
+185 −0 common4j/src/main/com/microsoft/identity/common/java/providers/nativeauth/NativeAuthResponseHandler.kt
+165 −0 common4j/src/main/com/microsoft/identity/common/java/providers/nativeauth/interactors/SignInInteractor.kt
+79 −0 .../src/main/com/microsoft/identity/common/java/providers/nativeauth/requests/signin/SignInChallengeRequest.kt
+79 −0 ...j/src/main/com/microsoft/identity/common/java/providers/nativeauth/requests/signin/SignInInitiateRequest.kt
+177 −0 ...on4j/src/main/com/microsoft/identity/common/java/providers/nativeauth/requests/signin/SignInTokenRequest.kt
+2 −1 common4j/src/main/com/microsoft/identity/common/java/providers/nativeauth/responses/ApiErrorResult.kt
+171 −0 ...main/com/microsoft/identity/common/java/providers/nativeauth/responses/signin/SignInChallengeApiResponse.kt
+53 −0 ...c/main/com/microsoft/identity/common/java/providers/nativeauth/responses/signin/SignInChallengeApiResult.kt
+132 −0 .../main/com/microsoft/identity/common/java/providers/nativeauth/responses/signin/SignInInitiateApiResponse.kt
+56 −0 ...rc/main/com/microsoft/identity/common/java/providers/nativeauth/responses/signin/SignInInitiateApiResult.kt
+166 −0 ...src/main/com/microsoft/identity/common/java/providers/nativeauth/responses/signin/SignInTokenApiResponse.kt
+95 −0 ...j/src/main/com/microsoft/identity/common/java/providers/nativeauth/responses/signin/SignInTokenApiResult.kt
+5 −3 common4j/src/main/com/microsoft/identity/common/java/providers/oauth2/OAuth2Strategy.java
+1 −1 common4j/src/main/com/microsoft/identity/common/java/providers/oauth2/OpenIdProviderConfigurationClient.java
+154 −0 common4j/src/main/com/microsoft/identity/common/java/util/ApiErrorResponseUtil.kt
+46 −0 common4j/src/main/com/microsoft/identity/common/java/util/ArgUtils.kt
+19 −0 common4j/src/main/com/microsoft/identity/common/java/util/CharArrayJsonAdapter.java
+4 −4 common4j/src/main/com/microsoft/identity/common/java/util/CommandResultUtil.kt
+11 −0 common4j/src/main/com/microsoft/identity/common/java/util/StringUtil.java
+12 −4 common4j/src/main/com/microsoft/identity/common/java/util/UrlUtil.java
+1 −1 common4j/versioning/version.properties
+2 −2 gradle/versions.gradle
+3 −0 testutils/build.gradle
+24 −2 testutils/src/main/java/com/microsoft/identity/internal/nativeauth/MockApiUtils.kt
+15 −0 uiautomationutilities/src/main/java/com/microsoft/identity/client/ui/automation/app/MsalTestApp.java
+3 −1 uiautomationutilities/src/main/java/com/microsoft/identity/client/ui/automation/app/OneAuthTestApp.java
+1 −1 versioning/version.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@
// THE SOFTWARE.
package com.microsoft.identity.client

import com.microsoft.identity.client.exception.MsalClientException
import com.microsoft.identity.client.exception.MsalException
import com.microsoft.identity.client.statemachine.results.SignInResult
import com.microsoft.identity.client.statemachine.results.SignInUsingPasswordResult
import com.microsoft.identity.client.statemachine.states.AccountResult

/**
* INativeAuthPublicClientApplication provides top level interface that is used by dpp developers
* INativeAuthPublicClientApplication provides top level interface that is used by app developers
* to use Native Auth methods.
*/
interface INativeAuthPublicClientApplication : IPublicClientApplication {
fadidurah marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -43,4 +47,62 @@ interface INativeAuthPublicClientApplication : IPublicClientApplication {
*/
fun onError(exception: MsalException)
}

/**
* Retrieve the current signed in account from cache; Kotlin coroutines variant.
*
* @return [com.microsoft.identity.client.statemachine.states.AccountResult] if there is a signed in account, null otherwise.
*/
suspend fun getCurrentAccount(): AccountResult?

/**
* Retrieve the current signed in account from cache; Kotlin coroutines variant.
*
* @return [com.microsoft.identity.client.statemachine.states.AccountResult] if there is a signed in account, null otherwise.
*/
fun getCurrentAccount(callback: NativeAuthPublicClientApplication.GetCurrentAccountCallback)

/**
* Sign in a user with a given username; Kotlin coroutines variant.
*
* @param username username of the account to sign in.
* @param scopes (Optional) scopes to request during the sign in.
* @return [com.microsoft.identity.client.statemachine.results.SignInResult] see detailed possible return state under the object.
* @throws [MsalException] if an account is already signed in.
*/
suspend fun signIn(username: String, scopes: List<String>? = null): SignInResult

/**
* Sign in a user with a given username; callback variant.
*
* @param username username of the account to sign in.
* @param scopes (Optional) scopes to request during the sign in.
* @param callback [com.microsoft.identity.client.NativeAuthPublicClientApplication.SignInCallback] to receive the result.
* @return [com.microsoft.identity.client.statemachine.results.SignInResult] see detailed possible return state under the object.
* @throws [MsalException] if an account is already signed in.
*/
fun signIn(username: String, scopes: List<String>? = null, callback: NativeAuthPublicClientApplication.SignInCallback)

/**
* Sign in the account using username and password; Kotlin coroutines variant.
*
* @param username username of the account to sign in.
* @param password password of the account to sign in.
* @param scopes (Optional) list of scopes to request.
* @return [com.microsoft.identity.client.statemachine.results.SignInUsingPasswordResult] see detailed possible return state under the object.
* @throws MsalClientException if an account is already signed in.
*/
suspend fun signInUsingPassword(username: String, password: CharArray, scopes: List<String>? = null): SignInUsingPasswordResult

/**
* Sign in the account using username and password; callback variant.
*
* @param username username of the account to sign in.
* @param password password of the account to sign in.
* @param scopes (Optional) list of scopes to request.
* @param callback [com.microsoft.identity.client.NativeAuthPublicClientApplication.SignInUsingPasswordCallback] to receive the result.
* @return [com.microsoft.identity.client.statemachine.results.SignInUsingPasswordResult] see detailed possible return state under the object.
* @throws MsalClientException if an account is already signed in.
*/
fun signInUsingPassword(username: String, password: CharArray, scopes: List<String>? = null, callback: NativeAuthPublicClientApplication.SignInUsingPasswordCallback)
}
Loading
Loading