-
Notifications
You must be signed in to change notification settings - Fork 45
Edge TB: changes related to GetToken, Fixes AB#3317102 #2803
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
base: dev
Are you sure you want to change the base?
Conversation
|
❌ Work item link check failed. Description does not contain AB#{ID}. Click here to Learn more. |
...n/src/main/java/com/microsoft/identity/common/internal/controllers/BrokerMsalController.java
Outdated
Show resolved
Hide resolved
| * String for broker webapps get contracts result. | ||
| */ | ||
| public static final String BROKER_WEBAPPS_GET_CONTRACTS_RESULT = "contracts"; | ||
| public static final String BROKER_WEBAPPS_GET_CONTRACTS_RESULT = "web_apps_contracts"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just making these values more specific
| */ | ||
| @Nullable | ||
| @SerializedName(SerializedNames.WEB_APPS_STATE) | ||
| private String mWebAppsState; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To allow AccountChooserActivity to return a result as a string we can return directly to the caller (without BrokerMsalController interfering too much), we pass the state webapp parameter so that AccountChooserActivity can include it in the result.
I think this is also the more correct approach vs BrkerMsalController injecting it at the end, as the state parameter should be included at the time when the token result is getting created.
| final String methodTag = TAG + ":acquireToken"; | ||
| final AcquireTokenResult result; | ||
| try { | ||
| final Bundle resultBundle = acquireTokenInternal(parameters); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I factored out logic into acquireTokenInternal in order to allow executeWebAppsRequest to reuse interactive request logic and get the custom webapp result directly from the bundle. The acquireToken method is not changed otherwise.
| @@ -0,0 +1,180 @@ | |||
| // Copyright (c) Microsoft Corporation. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the classes moved from broker to common.
| * Note: This class isn't going to be used until the design for the MATS blob is complete. | ||
| * Once that is complete, we will need to pass this data for each error object and getToken suboperation. | ||
| */ | ||
| data class MatsProperties( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is being created for the future when the design for the MatsProperties schema is complete.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 37 out of 37 changed files in this pull request and generated 19 comments.
...n/src/main/java/com/microsoft/identity/common/internal/controllers/BrokerMsalController.java
Outdated
Show resolved
Hide resolved
...n/src/main/java/com/microsoft/identity/common/internal/controllers/BrokerMsalController.java
Show resolved
Hide resolved
...n/src/main/java/com/microsoft/identity/common/internal/controllers/BrokerMsalController.java
Show resolved
Hide resolved
...n/src/main/java/com/microsoft/identity/common/internal/controllers/BrokerMsalController.java
Show resolved
Hide resolved
...4j/src/main/com/microsoft/identity/common/java/commands/webapps/WebAppsSupportedContracts.kt
Show resolved
Hide resolved
common/src/main/java/com/microsoft/identity/common/internal/result/MsalBrokerResultAdapter.java
Show resolved
Hide resolved
common4j/src/main/com/microsoft/identity/common/java/util/IPlatformUtil.java
Outdated
Show resolved
Hide resolved
...c/main/com/microsoft/identity/common/java/providers/oauth2/OpenIdConnectPromptParameter.java
Show resolved
Hide resolved
common/src/main/java/com/microsoft/identity/common/internal/util/WebAppsUtil.kt
Show resolved
Hide resolved
...in/com/microsoft/identity/common/java/commands/webapps/WebAppsGetTokenSubOperationRequest.kt
Show resolved
Hide resolved
...n/src/main/java/com/microsoft/identity/common/internal/controllers/BrokerMsalController.java
Outdated
Show resolved
Hide resolved
...n/src/main/java/com/microsoft/identity/common/internal/controllers/BrokerMsalController.java
Outdated
Show resolved
Hide resolved
| } | ||
| } else { | ||
| envelope = null; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: just initialize with null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think though since it's being used in an inner method, if I were to get rid of this else clasue and just init in the beginning with no final, that would not be allowed?
| if (resultBundle.containsKey(BROKER_WEB_APPS_ERROR_RESULT) | ||
| && envelope != null) { | ||
| final WebAppsGetTokenSubOperationRequest getTokenRequest = envelope.getRequest(); | ||
| if (canFallbackToInteractiveRequestForWebApp(getTokenRequest, additionalRequiredParams.getCanShowUi())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should all errors fallback to interactive? In normal AT/ATS it's invalid_grant and interaction_required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am double checking with the iOS folks as to how it's being done on their side.
Summary
Broker PR: https://github.com/AzureAD/ad-accounts-for-android/pull/3267
Changes related to WebApps getToken are done in this PR, and it also notably contains refactoring (such as moving some files from broker to common) and some additions to core classes such as AccountChooser and AccountChooserActivity.
To optimize the number of IPCs and repeated code, the sub operations will be completed as follows:
1a. we will form the BrokerInteractiveTokenParameters needed and call the BrokerMsalController.acquireTokenInternal method. The parameters will have the BrokerRequestType set to WEB_APPS, and that will serve as a flag to show that this is a WEB_APP flow.
2a. Eventually, AccountChooserActivity is going to receive these parameters. It is aware that this is a WEB_APP flow because of that flag.
3a. acquireTokenInternal proceeds as usual. Regardless if it is successful or not, AccountChooser will pass back a custom response to BrokerMsalController already in the protocol format.
4a. BrokerMSALController will return this response back as-is.
1b. We will call the methods to get to ExecuteWebAppsRequestOperation, which will assign WebAppsGetTokenSubOperation.
2b. GetTokenSubOperation will preprocess and check for errors. If all is good, it will call SdkOperation.acquireTokenSilent with the necessary parameters.
3b. If successful, it will send back the expected token response string (the same sort of response which will be sent by AccountChooser). If not, it will send back an error response string.
4b. If we receive the token response, BrokerMsalController will return the string response as-is. If we receive an error, BrokerMsalController now needs to decide from the initial request if we should fall back to interactive or return an error. In the interactive case, we will run the logic to start an interactive request.
If I try to put this more succinctly:
AB#3317102