Skip to content

Commit

Permalink
Implement updates of the Native Auth API (#2261)
Browse files Browse the repository at this point in the history
Summary of changes:

- Update error parsing based on the updated error codes and sub error
property returned by the API
- Convert all "flow" tokens to continuation token
- Use continuation token for sign in after sign up instead of SLT
  • Loading branch information
GBakolas authored Jan 12, 2024
1 parent 9eeddcb commit 209ee7f
Show file tree
Hide file tree
Showing 71 changed files with 1,089 additions and 1,503 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
V.Next
---------
- [MINOR] Implement updates of the native auth web API (#2261)

V.17.0.0
---------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,37 +23,37 @@
package com.microsoft.identity.common.nativeauth.internal.commands

import com.microsoft.identity.common.nativeauth.internal.controllers.NativeAuthMsalController
import com.microsoft.identity.common.java.nativeauth.commands.parameters.SignInWithSLTCommandParameters
import com.microsoft.identity.common.java.nativeauth.controllers.results.SignInWithSLTCommandResult
import com.microsoft.identity.common.java.nativeauth.commands.parameters.SignInWithContinuationTokenCommandParameters
import com.microsoft.identity.common.java.nativeauth.controllers.results.SignInWithContinuationTokenCommandResult
import com.microsoft.identity.common.java.logging.LogSession
import com.microsoft.identity.common.java.logging.Logger

/**
* Command class to call controllers to use short live token generated from sign in/self-service-password-reset flow to get the user authenticated.
* Command class to call controllers to use continuation token generated from sign in/self-service-password-reset flow to get the user authenticated.
* {@see com.microsoft.identity.common.java.controllers.CommandDispatcher}.
*/
class SignInWithSLTCommand(
private val parameters: SignInWithSLTCommandParameters,
class SignInWithContinuationTokenCommand(
private val parameters: SignInWithContinuationTokenCommandParameters,
private val controller: NativeAuthMsalController,
publicApiId: String
) : BaseNativeAuthCommand<SignInWithSLTCommandResult>(
) : BaseNativeAuthCommand<SignInWithContinuationTokenCommandResult>(
parameters,
controller,
publicApiId
) {

companion object {
private val TAG = SignInWithSLTCommand::class.java.simpleName
private val TAG = SignInWithContinuationTokenCommand::class.java.simpleName
}

/**
* The execution part of the command, to be run on the background thread.
* It calls the signInWithSLT method of the native auth MSAL controller with the given parameters.
* It calls the signInWithContinuationToken method of the native auth MSAL controller with the given parameters.
*/
override fun execute(): SignInWithSLTCommandResult {
override fun execute(): SignInWithContinuationTokenCommandResult {
LogSession.logMethodCall(TAG, "${TAG}.execute")

val result = controller.signInWithSLT(
val result = controller.signInWithContinuationToken(
parameters = parameters
)

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import com.microsoft.identity.common.java.nativeauth.commands.parameters.SignInStartUsingPasswordCommandParameters;
import com.microsoft.identity.common.java.nativeauth.commands.parameters.SignInSubmitCodeCommandParameters;
import com.microsoft.identity.common.java.nativeauth.commands.parameters.SignInSubmitPasswordCommandParameters;
import com.microsoft.identity.common.java.nativeauth.commands.parameters.SignInWithSLTCommandParameters;
import com.microsoft.identity.common.java.nativeauth.commands.parameters.SignInWithContinuationTokenCommandParameters;
import com.microsoft.identity.common.java.request.SdkType;

import java.util.List;
Expand Down Expand Up @@ -55,14 +55,14 @@ public static SignInStartUsingPasswordCommandParameters createSignInStartCommand
}

/**
* Adds scopes to [SignInWithSLTCommandParameters] object and returns a new
* [SignInWithSLTCommandParameters] object.
* Adds scopes to [SignInWithContinuationTokenCommandParameters] object and returns a new
* [SignInWithContinuationTokenCommandParameters] object.
* @param parameters input command parameter
* @param defaultScopes scopes to be added
* @return [SignInWithSLTCommandParameters] object with scopes
* @return [SignInWithContinuationTokenCommandParameters] object with scopes
*/
public static SignInWithSLTCommandParameters createSignInWithSLTCommandParametersWithScopes(
SignInWithSLTCommandParameters parameters,
public static SignInWithContinuationTokenCommandParameters createSignInWithContinuationTokenCommandParametersWithScopes(
SignInWithContinuationTokenCommandParameters parameters,
List<String> defaultScopes
) {
return parameters.toBuilder()
Expand Down Expand Up @@ -103,15 +103,15 @@ public static SignInSubmitPasswordCommandParameters createSignInSubmitPasswordCo
}

/**
* Adds credential token to [SignInStartUsingPasswordCommandParameters] object and returns a new
* Adds continuation token to [SignInStartUsingPasswordCommandParameters] object and returns a new
* [SignInSubmitPasswordCommandParameters] object.
* @param parameters input command parameter
* @param credentialToken credential token to be added
* @return [SignInStartUsingPasswordCommandParameters] object with credential token
* @param continuationToken continuation token to be added
* @return [SignInStartUsingPasswordCommandParameters] object with continuation token
*/
public static SignInSubmitPasswordCommandParameters createSignInSubmitPasswordCommandParameters(
SignInStartUsingPasswordCommandParameters parameters,
String credentialToken
String continuationToken
) {
final SignInSubmitPasswordCommandParameters commandParameters =
SignInSubmitPasswordCommandParameters.builder()
Expand All @@ -127,7 +127,7 @@ public static SignInSubmitPasswordCommandParameters createSignInSubmitPasswordCo
.sdkVersion(parameters.getSdkVersion())
.powerOptCheckEnabled(parameters.isPowerOptCheckEnabled())
.authority(parameters.getAuthority())
.credentialToken(credentialToken)
.continuationToken(continuationToken)
.password(parameters.getPassword())
.scopes(parameters.getScopes())
.challengeType(parameters.getChallengeType())
Expand Down
Loading

0 comments on commit 209ee7f

Please sign in to comment.