Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
21c3ed2
start
melissaahn Oct 17, 2025
1276de7
cleaning up
melissaahn Oct 17, 2025
cf872e1
changelog
melissaahn Oct 17, 2025
1378c50
suggestion
melissaahn Oct 17, 2025
8f04dd0
exposing api
melissaahn Oct 21, 2025
addd84a
reentrant readwrite lock
melissaahn Oct 22, 2025
3672ba1
removing cache
melissaahn Oct 22, 2025
075440c
changed structure
melissaahn Oct 22, 2025
f813536
unused imports
melissaahn Oct 22, 2025
6e5b3c3
renames
melissaahn Oct 22, 2025
456e0d5
Merge branch 'melissaahn/WebAppsAccountIdRegistry' into melissaahn/Ex…
melissaahn Oct 22, 2025
c7cb41d
Merge remote-tracking branch 'origin/dev' into melissaahn/ExposeWebApis
melissaahn Oct 23, 2025
935091d
min version
melissaahn Oct 23, 2025
3eae88b
addressing comments
melissaahn Oct 25, 2025
b53404d
changelog
melissaahn Oct 25, 2025
6fbaa31
changelog
melissaahn Oct 28, 2025
34d9d6f
Merge remote-tracking branch 'origin/dev' into melissaahn/ExposeWebApis
melissaahn Oct 28, 2025
7b2876d
dev
melissaahn Oct 28, 2025
84ea614
dev
melissaahn Oct 28, 2025
17b851a
Merge branch 'dev' into melissaahn/ExposeWebApis
melissaahn Oct 28, 2025
262e689
Merge remote-tracking branch 'origin/dev' into melissaahn/ExposeWebApis
melissaahn Oct 28, 2025
a763095
saving progress
melissaahn Oct 28, 2025
19e573f
saving progress
melissaahn Oct 31, 2025
8a1d9ff
saving progress again
melissaahn Nov 3, 2025
27f6cf2
clean up
melissaahn Nov 3, 2025
827d081
Merge remote-tracking branch 'origin/dev' into melissaahn/GetTokenHel…
melissaahn Nov 3, 2025
7f0003d
removed
melissaahn Nov 3, 2025
94338cd
more
melissaahn Nov 4, 2025
5ac74ca
changelog
melissaahn Nov 4, 2025
bfc8ed3
comments
melissaahn Nov 4, 2025
699c860
comments
melissaahn Nov 4, 2025
14ae0ea
more constants
melissaahn Nov 4, 2025
3669d6d
updated error handling
melissaahn Nov 5, 2025
0eebf03
failures
melissaahn Nov 5, 2025
65ad998
cleaned up some moree
melissaahn Nov 5, 2025
4f6a4e6
some unit tests
melissaahn Nov 5, 2025
5309bb5
refactoring
melissaahn Nov 6, 2025
d8f7af8
Merge remote-tracking branch 'origin/dev' into melissaahn/GetTokenHel…
melissaahn Nov 6, 2025
938d27e
spotbug
melissaahn Nov 6, 2025
a53b257
edits
melissaahn Nov 6, 2025
7f362b5
moving files around
melissaahn Nov 7, 2025
a98544a
dev
melissaahn Nov 7, 2025
391eab5
big refactor
melissaahn Nov 11, 2025
3c3b36d
Merge remote-tracking branch 'origin/dev' into melissaahn/GetTokenHel…
melissaahn Nov 11, 2025
191ad5b
edits
melissaahn Nov 12, 2025
629b232
testing
melissaahn Nov 15, 2025
1a6dfba
edits
melissaahn Nov 18, 2025
dc07634
comments
melissaahn Nov 18, 2025
5c2484b
dev
melissaahn Nov 18, 2025
42061ce
comments
melissaahn Nov 18, 2025
a212d9f
updated test
melissaahn Nov 18, 2025
1f42ada
catch
melissaahn Nov 19, 2025
e3c2f5a
two more tests
melissaahn Nov 19, 2025
3c88be3
Merge remote-tracking branch 'origin/dev' into melissaahn/GetTokenHel…
melissaahn Dec 3, 2025
f8fbdf8
addressing some comments
melissaahn Dec 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Version 23.1.0
- [MINOR] WebApps AccountId Registry (#2787)
- [MINOR] Expose WebApps APIs (#2793)
- [MINOR] Add domainHint support to authorization request (#2792)
- [MINOR] Add support for WebApps getToken API (#2803)
- [PATCH] Fix auth method blocked error handling (#2804)

Version 23.0.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1379,22 +1379,32 @@ public static String computeMaxHostBrokerProtocol() {
/**
* 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";
Copy link
Contributor Author

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


/**
* String for broker webapps error result.
* String for broker webapps request.
*/
public static final String BROKER_WEB_APPS_ERROR = "error";
public static final String BROKER_WEB_APPS_EXECUTE_REQUEST = "web_apps_execute_request";

/**
* String for broker webapps request.
* String for broker webapps additional required params.
*/
public static final String BROKER_WEB_APPS_REQUEST = "request";
public static final String BROKER_WEB_APPS_ADDITIONAL_REQUIRED_PARAMS = "additional_required_params";

/**
* String for broker webapps response.
*/
public static final String BROKER_WEB_APPS_RESPONSE = "response";
public static final String BROKER_WEB_APPS_SUCCESSFUL_RESULT = "web_app_successful_result";

/**
* String for compressed broker webapps response.
*/
public static final String BROKER_WEB_APPS_SUCCESSFUL_RESULT_COMPRESSED = "web_app_successful_result_compressed";

/**
* String for broker webapps error result.
*/
public static final String BROKER_WEB_APPS_ERROR_RESULT = "web_apps_error_result";

/**
* String for generate shr result.
Expand Down Expand Up @@ -2142,4 +2152,3 @@ public static final class SdkPlatformFields {
public static final String VERSION = com.microsoft.identity.common.java.AuthenticationConstants.SdkPlatformFields.VERSION;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ private static final class SerializedNames {
final static String SIGN_IN_WITH_GOOGLE_CREDENTIAL = "sign_in_with_google_credential";

final static String TENANT_ID = "tenant_id";
final static String REQUEST_TYPE = "request_type";
final static String WEB_APPS_STATE = "web_apps_state";
}

/**
Expand Down Expand Up @@ -281,4 +283,15 @@ private static final class SerializedNames {
@Nullable
@SerializedName(SerializedNames.TENANT_ID)
private String mTenantId;

@Nullable
@SerializedName(SerializedNames.REQUEST_TYPE)
private String mRequestType;

/**
* State for web apps requests. Make sure not to log this.
*/
@Nullable
@SerializedName(SerializedNames.WEB_APPS_STATE)
private String mWebAppsState;
Copy link
Contributor Author

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.

}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class WebAppsAccountIdRegistry private constructor(
* @param supplier The storage supplier.
* @return A new instance of [WebAppsAccountIdRegistry].
*/
@JvmStatic
fun create(supplier: IStorageSupplier): WebAppsAccountIdRegistry {
val store = supplier.getEncryptedFileStore(WEBAPPS_ACCOUNT_ID_REGISTRY_STORAGE_KEY)
return WebAppsAccountIdRegistry(store)
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import com.microsoft.identity.common.java.commands.ICommand;
import com.microsoft.identity.common.java.commands.InteractiveTokenCommand;
import com.microsoft.identity.common.java.commands.parameters.InteractiveTokenCommandParameters;
import com.microsoft.identity.common.java.exception.ArgumentException;
import com.microsoft.identity.common.java.exception.ClientException;
import com.microsoft.identity.common.java.exception.ErrorStrings;
import com.microsoft.identity.common.java.flighting.CommonFlight;
Expand Down Expand Up @@ -161,6 +162,11 @@ public boolean isValidCallingApp(@NonNull String redirectUri, @NonNull String pa
return isValidBrokerRedirect;
}

@Override
public void isValidCallingAppForWebApps(int callingUid) throws ClientException, UnsupportedOperationException {
// This operation is not supported in non-broker contexts.
throw new UnsupportedOperationException("WebApp APIs are not functional in non-broker scenarios.");
}
@Override
@Nullable
public String getEnrollmentId(@NonNull final String userId, @NonNull final String packageName) {
Expand Down Expand Up @@ -324,4 +330,8 @@ private boolean isValidHubRedirectURIForNAATests(String redirectUri) {
|| redirectUri.equals("msauth://com.microsoft.teams/fcg80qvoM1YMKJZibjBwQcDfOno=")
|| redirectUri.equals("https://login.microsoftonline.com/common/oauth2/nativeclient"));
}

protected Context getContext() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this one used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AndroidBrokerPlatformUtil.isValidCallingAppForWebApps... used for validating that the caller app is in our designated allowlist

return mContext;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
import static com.microsoft.identity.common.adal.internal.AuthenticationConstants.Broker.AUTH_SCHEME_PARAMS_POP;
import static com.microsoft.identity.common.adal.internal.AuthenticationConstants.Broker.BROKER_REQUEST_V2;
import static com.microsoft.identity.common.adal.internal.AuthenticationConstants.Broker.BROKER_REQUEST_V2_COMPRESSED;
import static com.microsoft.identity.common.adal.internal.AuthenticationConstants.Broker.BROKER_WEB_APPS_REQUEST;
import static com.microsoft.identity.common.adal.internal.AuthenticationConstants.Broker.BROKER_WEB_APPS_ADDITIONAL_REQUIRED_PARAMS;
import static com.microsoft.identity.common.adal.internal.AuthenticationConstants.Broker.BROKER_WEB_APPS_EXECUTE_REQUEST;
import static com.microsoft.identity.common.adal.internal.AuthenticationConstants.Broker.CALLER_INFO_UID;
import static com.microsoft.identity.common.adal.internal.AuthenticationConstants.Broker.CAN_FOCI_APPS_CONSTRUCT_ACCOUNTS_FROM_PRT_ID_TOKEN_KEY;
import static com.microsoft.identity.common.adal.internal.AuthenticationConstants.Broker.CLIENT_ADVERTISED_MAXIMUM_BP_VERSION_KEY;
Expand All @@ -56,6 +57,8 @@
import com.microsoft.identity.common.java.authscheme.INameable;
import com.microsoft.identity.common.java.authscheme.PopAuthenticationSchemeInternal;
import com.microsoft.identity.common.java.commands.parameters.AcquirePrtSsoTokenCommandParameters;
import com.microsoft.identity.common.java.commands.parameters.BrokerInteractiveTokenCommandParameters;
import com.microsoft.identity.common.java.commands.parameters.BrokerSilentTokenCommandParameters;
import com.microsoft.identity.common.java.commands.parameters.CommandParameters;
import com.microsoft.identity.common.java.commands.parameters.DeviceCodeFlowCommandParameters;
import com.microsoft.identity.common.java.commands.parameters.GenerateShrCommandParameters;
Expand Down Expand Up @@ -138,6 +141,11 @@ public BrokerRequest brokerRequestFromAcquireTokenParameters(@NonNull final Inte
brokerRequestBuilder.signInWithGoogleCredential(androidInteractiveTokenCommandParameters.getSignInWithGoogleCredential());
}

if (parameters instanceof BrokerInteractiveTokenCommandParameters) {
brokerRequestBuilder.requestType(((BrokerInteractiveTokenCommandParameters) parameters).getRequestType().name());
brokerRequestBuilder.webAppsState(((BrokerInteractiveTokenCommandParameters) parameters).getWebAppsState());
}

return brokerRequestBuilder.build();
}

Expand Down Expand Up @@ -178,7 +186,7 @@ public BrokerRequest brokerRequestFromSilentOperationParameters(@NonNull final S
final String extraOptions = parameters.getExtraOptions() != null ?
QueryParamsAdapter._toJson(parameters.getExtraOptions()) : null;

final BrokerRequest brokerRequest = BrokerRequest.builder()
final BrokerRequest.BrokerRequestBuilder brokerRequestBuilder = BrokerRequest.builder()
.authority(parameters.getAuthority().getAuthorityURL().toString())
.scope(TextUtils.join(" ", parameters.getScopes()))
.redirect(parameters.getRedirectUri())
Expand All @@ -205,10 +213,13 @@ public BrokerRequest brokerRequestFromSilentOperationParameters(@NonNull final S
.spanId(SpanExtension.current().getSpanContext().getSpanId())
.traceFlags(SpanExtension.current().getSpanContext().getTraceFlags().asByte())
.build()
)
.build();
);

return brokerRequest;
if (parameters instanceof BrokerSilentTokenCommandParameters) {
brokerRequestBuilder.requestType(((BrokerSilentTokenCommandParameters) parameters).getRequestType().name());
}

return brokerRequestBuilder.build();
}

public @NonNull Bundle getRequestBundleForSsoToken(final @NonNull AcquirePrtSsoTokenCommandParameters parameters,
Expand Down Expand Up @@ -597,17 +608,20 @@ public Bundle getRequestBundleForAadDeviceIdRequest(
/**
* Method to construct a request bundle for broker executeWebAppRequest request.
*
* @param request input request
* @param request input request
* @param negotiatedBrokerProtocolVersion protocol version returned by broker hello.
* @param requiredBrokerProtocolVersion protocol version required by the client.
* @param additionalRequiredParams extra required arguments to be sent to broker.
* @return request Bundle
*/
public Bundle getRequestBundleForExecuteWebAppRequest(@NonNull final String request,
@NonNull final String negotiatedBrokerProtocolVersion,
@NonNull final String requiredBrokerProtocolVersion) {
@NonNull final String requiredBrokerProtocolVersion,
@NonNull final String additionalRequiredParams) {
final Bundle bundle = new Bundle();
bundle.putString(AuthenticationConstants.Broker.NEGOTIATED_BP_VERSION_KEY, negotiatedBrokerProtocolVersion);
bundle.putString(BROKER_WEB_APPS_REQUEST, request);
bundle.putString(BROKER_WEB_APPS_EXECUTE_REQUEST, request);
bundle.putString(BROKER_WEB_APPS_ADDITIONAL_REQUIRED_PARAMS, additionalRequiredParams);
addRequiredBrokerProtocolVersionToRequestBundle(bundle, requiredBrokerProtocolVersion);
return bundle;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,25 @@ public class AdalBrokerResultAdapter implements IBrokerResultAdapter {
return resultBundle;
}

@Override
public @NonNull Bundle bundleFromBaseExceptionForWebApps(@NonNull BaseException exception) {
throw new UnsupportedOperationException();
}

@Override
public @NonNull
ILocalAuthenticationResult authenticationResultFromBundle(Bundle resultBundle) {
throw new UnsupportedOperationException();
}

@NonNull
@Override
public Bundle bundleFromAuthenticationResultForWebApps(@NonNull ILocalAuthenticationResult authenticationResult,
@Nullable String negotiatedBrokerProtocolVersion,
@Nullable String state) throws BaseException {
throw new UnsupportedOperationException();
}

@Override
public @NonNull BaseException getBaseExceptionFromBundle(Bundle resultBundle) {
throw new UnsupportedOperationException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ public interface IBrokerResultAdapter {
@NonNull Bundle bundleFromAuthenticationResult(@NonNull final ILocalAuthenticationResult authenticationResult,
@Nullable final String negotiatedBrokerProtocolVersion);

/**
* Returns a success bundle with properties from result for web apps.
*
* @param authenticationResult
* @param negotiatedBrokerProtocolVersion
* @param state
* @return {@link Bundle}
*/
@NonNull Bundle bundleFromAuthenticationResultForWebApps(@NonNull final ILocalAuthenticationResult authenticationResult,
@Nullable final String negotiatedBrokerProtocolVersion,
@Nullable final String state) throws BaseException;

/**
* Returns an error bundle with properties from Exception.
*
Expand All @@ -52,6 +64,14 @@ public interface IBrokerResultAdapter {
@NonNull Bundle bundleFromBaseException(@NonNull BaseException exception,
@Nullable final String negotiatedBrokerProtocolVersion);

/**
* Returns an error bundle with properties from Exception for web apps.
*
* @param exception
* @return {@link Bundle}
*/
@NonNull Bundle bundleFromBaseExceptionForWebApps(@NonNull final BaseException exception);

/**
* Returns authentication result from Broker result bundle
*
Expand Down
Loading
Loading