Skip to content

Commit 08c47da

Browse files
authored
Native auth: Add support for claims request in getAccessToken and signIn after signUp/SSPR, Fixes AB#3188133 (#2622)
Adding support on native authentication for claims request for getAccessToken and signIn after signUp/SSPR flows. MSAL Android PR: AzureAD/microsoft-authentication-library-for-android#2278 [AB#3188133](https://identitydivision.visualstudio.com/Engineering/_workitems/edit/3188133)
1 parent 79a10e7 commit 08c47da

10 files changed

Lines changed: 18 additions & 35 deletions

File tree

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Version 21.0.0
1212
- [PATCH] Track MAM flow in telemetry (#2608)
1313
- [PATCH] Fix multiple prompts issue in cross cloud request (#2599)
1414
- [PATCH] Corrected error handling in cross cloud scenario (#2602)
15+
- [MINOR] Native auth: Add claimsRequest also to getAccessToken and signIn after signUp/SSPR flows (#2622)
1516

1617
Version 20.1.1
1718
----------

common4j/src/main/com/microsoft/identity/common/java/nativeauth/commands/parameters/BaseSignInTokenCommandParameters.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

2727
import java.util.List;
2828

29+
import javax.annotation.Nullable;
30+
2931
import lombok.EqualsAndHashCode;
3032
import lombok.Getter;
3133
import lombok.experimental.SuperBuilder;
@@ -44,5 +46,11 @@ public abstract class BaseSignInTokenCommandParameters extends BaseNativeAuthCom
4446
*/
4547
public final List<String> scopes;
4648

49+
/**
50+
* Claims to send to the token endpoint.
51+
*/
52+
@Nullable
53+
public final String claimsRequestJson;
54+
4755
private final AbstractAuthenticationScheme authenticationScheme;
4856
}

common4j/src/main/com/microsoft/identity/common/java/nativeauth/commands/parameters/MFADefaultChallengeCommandParameters.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,6 @@ public class MFADefaultChallengeCommandParameters extends BaseSignInTokenCommand
4747
@NonNull
4848
public final String continuationToken;
4949

50-
/**
51-
* Claims to send to the token endpoint.
52-
*/
53-
@Nullable
54-
public final String claimsRequestJson;
55-
5650
@NonNull
5751
@Override
5852
public String toUnsanitizedString() {

common4j/src/main/com/microsoft/identity/common/java/nativeauth/commands/parameters/MFASubmitChallengeCommandParameters.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,6 @@ public class MFASubmitChallengeCommandParameters extends BaseSignInTokenCommandP
5151
@NonNull
5252
public final String continuationToken;
5353

54-
/**
55-
* Claims to send to the token endpoint.
56-
*/
57-
@Nullable
58-
public final String claimsRequestJson;
59-
6054
@NonNull
6155
@Override
6256
public String toUnsanitizedString() {

common4j/src/main/com/microsoft/identity/common/java/nativeauth/commands/parameters/SignInStartCommandParameters.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,6 @@ public class SignInStartCommandParameters extends BaseSignInTokenCommandParamete
5454
@Nullable
5555
public final char[] password;
5656

57-
/**
58-
* Claims to send to the token endpoint.
59-
*/
60-
@Nullable
61-
public final String claimsRequestJson;
62-
6357
@NonNull
6458
@Override
6559
public String toUnsanitizedString() {

common4j/src/main/com/microsoft/identity/common/java/nativeauth/commands/parameters/SignInSubmitCodeCommandParameters.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,6 @@ public class SignInSubmitCodeCommandParameters extends BaseSignInTokenCommandPar
5151
@NonNull
5252
public final String continuationToken;
5353

54-
/**
55-
* Claims to send to the token endpoint.
56-
*/
57-
@Nullable
58-
public final String claimsRequestJson;
59-
6054
@NonNull
6155
@Override
6256
public String toUnsanitizedString() {

common4j/src/main/com/microsoft/identity/common/java/nativeauth/commands/parameters/SignInSubmitPasswordCommandParameters.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,6 @@ public class SignInSubmitPasswordCommandParameters extends BaseSignInTokenComman
5353
@NonNull
5454
public final String continuationToken;
5555

56-
/**
57-
* Claims to send to the token endpoint.
58-
*/
59-
@Nullable
60-
public final String claimsRequestJson;
61-
6256
@NonNull
6357
@Override
6458
public String toUnsanitizedString() {

common4j/src/main/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestProvider.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ class NativeAuthRequestProvider(private val config: NativeAuthOAuth2Configuratio
181181
username = commandParameters.username,
182182
challengeType = config.challengeType,
183183
requestUrl = signInTokenEndpoint,
184-
headers = getRequestHeaders(commandParameters.getCorrelationId())
184+
headers = getRequestHeaders(commandParameters.getCorrelationId()),
185+
claimsRequestJson = commandParameters.claimsRequestJson
185186
)
186187
}
187188

common4j/src/main/com/microsoft/identity/common/java/nativeauth/providers/requests/signin/SignInTokenRequest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ data class SignInTokenRequest private constructor(
139139
scopes: List<String>? = null,
140140
challengeType: String? = null,
141141
requestUrl: String,
142-
headers: Map<String, String?>
142+
headers: Map<String, String?>,
143+
claimsRequestJson: String?
143144
): SignInTokenRequest {
144145
// Check for empty Strings and empty Maps
145146
ArgUtils.validateNonNullArg(continuationToken, "continuationToken")
@@ -157,7 +158,7 @@ data class SignInTokenRequest private constructor(
157158
grantType = NativeAuthConstants.GrantType.CONTINUATION_TOKEN,
158159
challengeType = challengeType,
159160
scope = scopes?.joinToString(" "),
160-
claimsRequestJson = null
161+
claimsRequestJson = claimsRequestJson
161162
),
162163
requestUrl = URL(requestUrl),
163164
headers = headers

common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestProviderTest.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -823,17 +823,19 @@ class NativeAuthRequestProviderTest {
823823
fun testSignInTokenContinuationShouldContainsCorrectParams() {
824824
val scopes = arrayListOf("OOB", "PASSWORD")
825825
val headers = mapOf("key" to "value")
826+
val claims = "claims"
826827
val request = SignInTokenRequest.createContinuationTokenRequest(
827828
continuationToken,
828829
clientId,
829830
username,
830831
scopes,
831832
challengeType,
832833
ApiConstants.MockApi.signInTokenRequestUrl.toString(),
833-
headers
834+
headers,
835+
claimsRequestJson = claims
834836
)
835837
assertNull(request.parameters.password)
836-
assertNull(request.parameters.claimsRequestJson)
838+
assertEquals(request.parameters.claimsRequestJson, claims)
837839
assertEquals(request.parameters.scope, "OOB PASSWORD")
838840
assertEquals(request.parameters.continuationToken, continuationToken)
839841
assertEquals(request.parameters.challengeType, challengeType)

0 commit comments

Comments
 (0)