Skip to content

Commit 84a018e

Browse files
authored
Merge pull request #1661 from AzureAD/shahzaibj/fix-ropc
Fix accidental code change that disabled PoP for auth code grant flow
2 parents e607576 + 1f50c3f commit 84a018e

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ V.Next
6464
- [PATCH] Support SSO token api (#1543)
6565
- [MINOR] Add flighting parameters to commmandParameters (#1562)
6666
- [MINOR] Hook telemetry to LocalAuthenticationResult and BaseException (#1636)
67+
- [PATCH] Fix accidental code change that disabled PoP for auth code grant flow (#1661)
6768

6869
Version 3.6.3
6970
----------

common4j/src/main/com/microsoft/identity/common/java/providers/microsoft/microsoftsts/MicrosoftStsOAuth2Strategy.java

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,26 @@ public MicrosoftStsTokenRequest createTokenRequest(@NonNull final MicrosoftStsAu
381381
}
382382

383383
if (PopAuthenticationSchemeInternal.SCHEME_POP.equals(authScheme.getName())) {
384-
throw new UnsupportedOperationException("MSAL Android supports ROPC on Bearer flows only for testing purposes.");
384+
// Add a token_type
385+
tokenRequest.setTokenType(TokenRequest.TokenType.POP);
386+
387+
final IDevicePopManager devicePopManager =
388+
mStrategyParameters.getPlatformComponents().getDefaultDevicePopManager();
389+
390+
// Generate keys if they don't already exist...
391+
if (!devicePopManager.asymmetricKeyExists()) {
392+
final String thumbprint = devicePopManager.generateAsymmetricKey();
393+
394+
Logger.verbosePII(
395+
TAG,
396+
"Generated new PoP asymmetric key with thumbprint: "
397+
+ thumbprint
398+
);
399+
}
400+
401+
final String reqCnf = devicePopManager.getRequestConfirmation();
402+
// Set the req_cnf
403+
tokenRequest.setRequestConfirmation(reqCnf);
385404
}
386405

387406
return tokenRequest;
@@ -453,16 +472,7 @@ public MicrosoftStsTokenRequest createRopcTokenRequest(@NonNull final RopcTokenC
453472
setTokenRequestCorrelationId(request);
454473

455474
if (PopAuthenticationSchemeInternal.SCHEME_POP.equals(parameters.getAuthenticationScheme().getName())) {
456-
request.setTokenType(TokenRequest.TokenType.POP);
457-
458-
final IDevicePopManager devicePopManager =
459-
mStrategyParameters.getPlatformComponents().getDefaultDevicePopManager();
460-
461-
if (!devicePopManager.asymmetricKeyExists()) {
462-
devicePopManager.generateAsymmetricKey();
463-
}
464-
465-
request.setRequestConfirmation(devicePopManager.getRequestConfirmation());
475+
throw new UnsupportedOperationException("MSAL Android supports ROPC on Bearer flows only for testing purposes.");
466476
}
467477

468478
return request;

0 commit comments

Comments
 (0)