From bfa57ad8884c45d6a614826232c49415c37a8473 Mon Sep 17 00:00:00 2001 From: Federico Maccaroni Date: Fri, 19 Apr 2024 17:41:35 -0300 Subject: [PATCH] PM-7585 Show error message when Origin is null, given no support for passkeys from native apps yet (#3175) --- src/App/Platforms/Android/Autofill/CredentialHelpers.cs | 9 +++++++++ .../Autofill/CredentialProviderSelectionActivity.cs | 7 +++++++ src/Core/Resources/Localization/AppResources.Designer.cs | 9 +++++++++ src/Core/Resources/Localization/AppResources.resx | 3 +++ 4 files changed, 28 insertions(+) diff --git a/src/App/Platforms/Android/Autofill/CredentialHelpers.cs b/src/App/Platforms/Android/Autofill/CredentialHelpers.cs index e9bb43ab8..616ca0f22 100644 --- a/src/App/Platforms/Android/Autofill/CredentialHelpers.cs +++ b/src/App/Platforms/Android/Autofill/CredentialHelpers.cs @@ -6,7 +6,9 @@ using AndroidX.Credentials; using AndroidX.Credentials.Exceptions; using AndroidX.Credentials.Provider; using AndroidX.Credentials.WebAuthn; +using Bit.App.Abstractions; using Bit.Core.Abstractions; +using Bit.Core.Resources.Localization; using Bit.Core.Utilities; using Bit.Core.Utilities.Fido2.Extensions; using Bit.Droid; @@ -78,6 +80,13 @@ namespace Bit.App.Platforms.Android.Autofill var origin = callingRequest.Origin; var credentialCreationOptions = GetPublicKeyCredentialCreationOptionsFromJson(callingRequest.RequestJson); + if (origin is null + && + ServiceContainer.TryResolve(out var deviceActionService)) + { + await deviceActionService.DisplayAlertAsync(AppResources.ErrorCreatingPasskey, AppResources.PasskeysNotSupportedForThisApp, AppResources.Ok); + } + var rp = new Core.Utilities.Fido2.PublicKeyCredentialRpEntity() { Id = credentialCreationOptions.Rp.Id, diff --git a/src/App/Platforms/Android/Autofill/CredentialProviderSelectionActivity.cs b/src/App/Platforms/Android/Autofill/CredentialProviderSelectionActivity.cs index dcf7963c7..690c36e7c 100644 --- a/src/App/Platforms/Android/Autofill/CredentialProviderSelectionActivity.cs +++ b/src/App/Platforms/Android/Autofill/CredentialProviderSelectionActivity.cs @@ -70,6 +70,13 @@ namespace Bit.Droid.Autofill var packageName = getRequest?.CallingAppInfo.PackageName; var appInfoOrigin = getRequest?.CallingAppInfo.Origin; + if (appInfoOrigin is null) + { + await _deviceActionService.Value.DisplayAlertAsync(AppResources.ErrorReadingPasskey, AppResources.PasskeysNotSupportedForThisApp, AppResources.Ok); + Finish(); + return; + } + var userInterface = new Fido2GetAssertionUserInterface( cipherId: cipherId, userVerified: false, diff --git a/src/Core/Resources/Localization/AppResources.Designer.cs b/src/Core/Resources/Localization/AppResources.Designer.cs index 5b28afc5d..cbe3adf4e 100644 --- a/src/Core/Resources/Localization/AppResources.Designer.cs +++ b/src/Core/Resources/Localization/AppResources.Designer.cs @@ -5281,6 +5281,15 @@ namespace Bit.Core.Resources.Localization { } } + /// + /// Looks up a localized string similar to Passkeys not supported for this app. + /// + public static string PasskeysNotSupportedForThisApp { + get { + return ResourceManager.GetString("PasskeysNotSupportedForThisApp", resourceCulture); + } + } + /// /// Looks up a localized string similar to Passkey will not be copied. /// diff --git a/src/Core/Resources/Localization/AppResources.resx b/src/Core/Resources/Localization/AppResources.resx index 312118517..d0940a16d 100644 --- a/src/Core/Resources/Localization/AppResources.resx +++ b/src/Core/Resources/Localization/AppResources.resx @@ -2987,4 +2987,7 @@ Do you want to switch to this account? Notice + + Passkeys not supported for this app +