[PM-31446] fix:Append assetlinks.json path to DAL URLs (#6447)

This commit is contained in:
Patrick Honkonen 2026-01-30 13:22:00 -05:00 committed by GitHub
parent 675b346666
commit 92ba38c831
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 4 deletions

View File

@ -50,6 +50,8 @@ import kotlinx.coroutines.withContext
import kotlinx.serialization.json.Json
import timber.log.Timber
private const val DAL_ROUTE = ".well-known/assetlinks.json"
/**
* Primary implementation of [BitwardenCredentialManager].
*/
@ -123,7 +125,7 @@ class BitwardenCredentialManagerImpl(
.getSignatureFingerprintAsHexString()
.orEmpty(),
host = hostUrl,
assetLinkUrl = hostUrl,
assetLinkUrl = hostUrl.toDigitalAssetLinkUrl(),
),
)
}
@ -316,7 +318,7 @@ class BitwardenCredentialManagerImpl(
packageName = callingAppInfo.packageName,
sha256CertFingerprint = signatureFingerprint,
host = host,
assetLinkUrl = host,
assetLinkUrl = host.toDigitalAssetLinkUrl(),
),
)
@ -428,6 +430,13 @@ class BitwardenCredentialManagerImpl(
?.relyingParty
?.id
?.prefixHttpsIfNecessaryOrNull()
private fun String.toDigitalAssetLinkUrl(): String =
when {
this.endsWith(DAL_ROUTE) -> this
this.endsWith("/") -> "$this$DAL_ROUTE"
else -> "$this/$DAL_ROUTE"
}
}
private const val MAX_AUTHENTICATION_ATTEMPTS = 5

View File

@ -681,7 +681,8 @@ class BitwardenCredentialManagerTest {
DEFAULT_PACKAGE_NAME,
DEFAULT_CERT_FINGERPRINT,
"https://${mockAssertionOptions.relyingPartyId!!}",
"https://${mockAssertionOptions.relyingPartyId}",
@Suppress("MaxLineLength")
"https://${mockAssertionOptions.relyingPartyId}/.well-known/assetlinks.json",
),
),
requestCaptureSlot.captured.origin,
@ -1499,7 +1500,7 @@ private val DEFAULT_ANDROID_ORIGIN = Origin.Android(
packageName = DEFAULT_PACKAGE_NAME,
sha256CertFingerprint = DEFAULT_CERT_FINGERPRINT,
host = "https://$DEFAULT_HOST",
assetLinkUrl = "https://$DEFAULT_HOST",
assetLinkUrl = "https://$DEFAULT_HOST/.well-known/assetlinks.json",
),
)
private val DEFAULT_WEB_ORIGIN = Origin.Web("bitwarden.com")