Skip to content

@W-21146662: [Android] App attestation integration testing#3

Draft
JohnsonEricAtSalesforce wants to merge 1 commit intodevfrom
feature/w-21146662_android-app-attestation-integration-testing
Draft

@W-21146662: [Android] App attestation integration testing#3
JohnsonEricAtSalesforce wants to merge 1 commit intodevfrom
feature/w-21146662_android-app-attestation-integration-testing

Conversation

@JohnsonEricAtSalesforce
Copy link
Owner

@JohnsonEricAtSalesforce JohnsonEricAtSalesforce commented Mar 12, 2026

🛑 Draft Pull Request To This Fork Rather Than Upstream - Intended For Discussion Only 🛑

This is a quick proof-of-concept for integrating the new Salesforce Mobile App Attestation Challenge API Endpoint and the Google Play Integrity API into one of Salesforce Mobile SDK's sample apps so that the new attestation parameter can be delivered to the Salesforce org when needed

This code isn't intended to be production-ready for this work item nor will this pull request be merged.

For an overview, here are the key tasks the app and MSDK have to complete to use Google Play Integrity API with the updated Salesforce org:

  • The Google Play app must be configured for Google Play App Integrity API and an associated Google Cloud Project
  • The new Salesforce ECA App Attestation Plug-In must be installed on the org
  • The App Attestation Plug-In must be configured with the matching Google Cloud Project Number
  • The Mobile App must provide the Google Cloud Project Number to MSDK (To-Do: Determine how this dynamically matches the selected login server ECJ20260312)
  • The Mobile App must enable the attestation feature in MSDK
  • MSDK must fetch the Salesforce Mobile App Attestation API Challenge
  • MSDK must "warm-up" the Google Integrity API Token Provider
  • At each authorization or token refresh, MSDK must fetch and provide the Google Integrity API Token to the org
  • The current toasts displayed by MSDK on error display the server's response

Production Considerations:

  • MSDK will likely need an "opt-in" set by the app to indicate attestation is active
  • The new attestation parameter can be passed to all Salesforce orgs. It will be ignored appropriately
  • The demonstration code will need to be moved to a new object and off the manager singleton
  • Each authorization and token refresh will need to ensure a token is available before proceeding when required. For instance the login web view cannot generate the authorization URL until a token is available
  • Compared to the demonstration code, the logic to request the token will need to be extracted and then called when needed rather than ahead of time. Google Play Integrity API has very low latency by design according to the documentation

* TODO: This will need to be made production-ready in the future. ECJ20260312
// TODO: Discuss a suitable scope for this as attaching it to this singleton may further legacy patterns. ECJ20260312
*/
fun testGooglePlayIntegrityApiPreparation() {
Copy link
Owner Author

Choose a reason for hiding this comment

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

This SalesforceSDKManager.testGooglePlayIntegrityApiPreparation method will not exist in the production version. It's only present to support this rough proof-of-concept test.

* @param restClient The REST client to use
*/
@Suppress("unused")
internal class AppAttestationChallengeApiClient(
Copy link
Owner Author

Choose a reason for hiding this comment

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

This new AppAttestationChallengeApiClient is modeled on the earlier stand-alone REST clients such as SfapApiClient. This new API only has one endpoint and its documentation is not finished.

@JohnsonEricAtSalesforce JohnsonEricAtSalesforce force-pushed the feature/w-21146662_android-app-attestation-integration-testing branch 2 times, most recently from 98efc08 to 8d39060 Compare March 13, 2026 22:44
@JohnsonEricAtSalesforce JohnsonEricAtSalesforce force-pushed the feature/w-21146662_android-app-attestation-integration-testing branch from 8d39060 to 082b018 Compare March 13, 2026 22:47
val salesforceAppAttestationChallenge = testSalesforceMobileAppAttestationChallengeRequest()
val salesforceAppAttestationChallengeHashByteArray = MessageDigest.getInstance("SHA-256")
.digest(salesforceAppAttestationChallenge.toByteArray(UTF_8))
val salesforceAppAttestationChallengeHashHexString = salesforceAppAttestationChallengeHashByteArray.joinToString("") { "%02x".format(it) }
Copy link
Owner Author

Choose a reason for hiding this comment

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

We spent some time today getting the correct SHA256 hashed hex string that exactly matches the Google Guava Hasher version that the backend is expecting. This snippet was aided by our agent tools.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant