bitwarden-mobile/src/App/Platforms/Android/Autofill/CredentialProviderSelection...

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

174 lines
7.7 KiB
C#
Raw Normal View History

[PM-5153] Android Passkey Implementation (#3020) * Initial WIP implementation for the app unlock flow when called from Passkey. Still needs code organization and to be finished. Also added a new Window workaround in App.xaml.cs to allow CredentialProviderSelectionActivity to launch separately. * Added missing IDeviceActionService.cs implementation for iOS to build. * Added Async to ReturnToPasskeyAfterUnlockMethod Changed i18n to AppResource.Unlock Removed unecessary cast * minor code change (added comment) * Added back the case for loading a specific Window for CredentialProviverSelectionActivity * Added fix for Intent not passing properly to CredentialProviderSelectionActivity Added Activity cancellation on error during execution of ReturnToPasskeyAfterUnlockAsync() * Added WIP code for Android passkey implementation. Currently returns a mostly complete response that is missing the ClientDataJson * Added WIP code for creating passkeys on Android. Still missing unlock flow and response of passkey creation is still not correct. Removed unused throw NotImplementedException from Fido2ClientService Added CredentialCreationActivity for passkey creation Added alternative code on CredentialProviderSelectionActivity to try to debug issue with response not being valid * Started working on logic to adding unlock flow. It's already handling the unlock but not passing the PendingIntentHandler info for CredentialCreation to CredentialCreationActivity * Changed "cross-platform" to "platform" * Created CredentialHelpers.cs class to share code used for Populating Passkeys in Android. * Added Passkey Credential Creation shared code to CredentialHelpers. Unlock flow for Passkey creation should now be working also. * Updated code for checking if the CredentialProviderService has been enabled by the user or not. Still WIP, somes notes in code due to Credential API not being complete. Also changed the disable code to open the Credential Settings. * Replaced the AndroidX.Credential helpers with custom JSON creation to fix the response for Credential Creation * minor code cleanup on CredentialProviderSelectionActivity * added todo comment * Feature/maui migraton passkeys android unlock fix andreas (#3077) * fix: bitwarden providing too many/wrong credentials * feat: use authenticator instead of client --------- Co-authored-by: Dinis Vieira <dinisvieira@outlook.com> * Removed / commented some older Passkey Proof of concept code. Auth and creation of passkey should still work both when device is unlocked (and not) Added some initial code in AutofillCiphersPageViewModel and CipherAddEditPageViewModel for handling Passkey creation * PM-6829 Implemented Fido2...UserInterfaces on Android and necessary logic to get/make a credential with those * Added IFido2MediatorService registrations Inverted two IsLockedAsync checks * Added navigation to autofillCipher when creating passkey * Updated LockPage to avoid multiple executions of SubmitAsync * Added new flow for creating new passkey on Android with the Cipher page for editing details * Changed the Credential Provider Switch to an external link control * Added i18n for Passkey Settings * Cleanup of older Credentials code used for Android Fido2 POC. Removed CredentialCreationActivity as it's no longer needed * fixed merge conflict/error and added error check to Fido2 navigation in App.xaml.cs * Removed from MainActivity casts from DeviceActionService Changed CredentialProviderServiceActivity to handle Fido errors and exceptions gracefully and show the user an error. Still not with the correct messages. * Added some error messages. Still need to confirm the Text Resource to use and change. * Changed some messages to use AppResources * Cleanup of Credential Android code and added exception result if the clientCreateCredentialResult is null * Updated Add new item button text when creating a new passkey * Added AccountSwitchedException for the Fido Mediator Service * Removed TODO that is no longer needed * Updated some todo messages in Android AutofillHandler * When authenticating a passkey on Android the "showDialog" callback can be called and there's no MainPage available so it was changed for that specific scenario to use _deviceActionService instead of MainPage. --------- Co-authored-by: Andreas Coroiu <andreas.coroiu@gmail.com> Co-authored-by: Federico Maccaroni <fedemkr@gmail.com>
2024-04-09 22:57:31 +02:00
using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.OS;
[PM-5153] Android Passkey Implementation (#3020) * Initial WIP implementation for the app unlock flow when called from Passkey. Still needs code organization and to be finished. Also added a new Window workaround in App.xaml.cs to allow CredentialProviderSelectionActivity to launch separately. * Added missing IDeviceActionService.cs implementation for iOS to build. * Added Async to ReturnToPasskeyAfterUnlockMethod Changed i18n to AppResource.Unlock Removed unecessary cast * minor code change (added comment) * Added back the case for loading a specific Window for CredentialProviverSelectionActivity * Added fix for Intent not passing properly to CredentialProviderSelectionActivity Added Activity cancellation on error during execution of ReturnToPasskeyAfterUnlockAsync() * Added WIP code for Android passkey implementation. Currently returns a mostly complete response that is missing the ClientDataJson * Added WIP code for creating passkeys on Android. Still missing unlock flow and response of passkey creation is still not correct. Removed unused throw NotImplementedException from Fido2ClientService Added CredentialCreationActivity for passkey creation Added alternative code on CredentialProviderSelectionActivity to try to debug issue with response not being valid * Started working on logic to adding unlock flow. It's already handling the unlock but not passing the PendingIntentHandler info for CredentialCreation to CredentialCreationActivity * Changed "cross-platform" to "platform" * Created CredentialHelpers.cs class to share code used for Populating Passkeys in Android. * Added Passkey Credential Creation shared code to CredentialHelpers. Unlock flow for Passkey creation should now be working also. * Updated code for checking if the CredentialProviderService has been enabled by the user or not. Still WIP, somes notes in code due to Credential API not being complete. Also changed the disable code to open the Credential Settings. * Replaced the AndroidX.Credential helpers with custom JSON creation to fix the response for Credential Creation * minor code cleanup on CredentialProviderSelectionActivity * added todo comment * Feature/maui migraton passkeys android unlock fix andreas (#3077) * fix: bitwarden providing too many/wrong credentials * feat: use authenticator instead of client --------- Co-authored-by: Dinis Vieira <dinisvieira@outlook.com> * Removed / commented some older Passkey Proof of concept code. Auth and creation of passkey should still work both when device is unlocked (and not) Added some initial code in AutofillCiphersPageViewModel and CipherAddEditPageViewModel for handling Passkey creation * PM-6829 Implemented Fido2...UserInterfaces on Android and necessary logic to get/make a credential with those * Added IFido2MediatorService registrations Inverted two IsLockedAsync checks * Added navigation to autofillCipher when creating passkey * Updated LockPage to avoid multiple executions of SubmitAsync * Added new flow for creating new passkey on Android with the Cipher page for editing details * Changed the Credential Provider Switch to an external link control * Added i18n for Passkey Settings * Cleanup of older Credentials code used for Android Fido2 POC. Removed CredentialCreationActivity as it's no longer needed * fixed merge conflict/error and added error check to Fido2 navigation in App.xaml.cs * Removed from MainActivity casts from DeviceActionService Changed CredentialProviderServiceActivity to handle Fido errors and exceptions gracefully and show the user an error. Still not with the correct messages. * Added some error messages. Still need to confirm the Text Resource to use and change. * Changed some messages to use AppResources * Cleanup of Credential Android code and added exception result if the clientCreateCredentialResult is null * Updated Add new item button text when creating a new passkey * Added AccountSwitchedException for the Fido Mediator Service * Removed TODO that is no longer needed * Updated some todo messages in Android AutofillHandler * When authenticating a passkey on Android the "showDialog" callback can be called and there's no MainPage available so it was changed for that specific scenario to use _deviceActionService instead of MainPage. --------- Co-authored-by: Andreas Coroiu <andreas.coroiu@gmail.com> Co-authored-by: Federico Maccaroni <fedemkr@gmail.com>
2024-04-09 22:57:31 +02:00
using AndroidX.Credentials;
using AndroidX.Credentials.Provider;
using AndroidX.Credentials.WebAuthn;
using Bit.App.Droid.Utilities;
[PM-5153] Android Passkey Implementation (#3020) * Initial WIP implementation for the app unlock flow when called from Passkey. Still needs code organization and to be finished. Also added a new Window workaround in App.xaml.cs to allow CredentialProviderSelectionActivity to launch separately. * Added missing IDeviceActionService.cs implementation for iOS to build. * Added Async to ReturnToPasskeyAfterUnlockMethod Changed i18n to AppResource.Unlock Removed unecessary cast * minor code change (added comment) * Added back the case for loading a specific Window for CredentialProviverSelectionActivity * Added fix for Intent not passing properly to CredentialProviderSelectionActivity Added Activity cancellation on error during execution of ReturnToPasskeyAfterUnlockAsync() * Added WIP code for Android passkey implementation. Currently returns a mostly complete response that is missing the ClientDataJson * Added WIP code for creating passkeys on Android. Still missing unlock flow and response of passkey creation is still not correct. Removed unused throw NotImplementedException from Fido2ClientService Added CredentialCreationActivity for passkey creation Added alternative code on CredentialProviderSelectionActivity to try to debug issue with response not being valid * Started working on logic to adding unlock flow. It's already handling the unlock but not passing the PendingIntentHandler info for CredentialCreation to CredentialCreationActivity * Changed "cross-platform" to "platform" * Created CredentialHelpers.cs class to share code used for Populating Passkeys in Android. * Added Passkey Credential Creation shared code to CredentialHelpers. Unlock flow for Passkey creation should now be working also. * Updated code for checking if the CredentialProviderService has been enabled by the user or not. Still WIP, somes notes in code due to Credential API not being complete. Also changed the disable code to open the Credential Settings. * Replaced the AndroidX.Credential helpers with custom JSON creation to fix the response for Credential Creation * minor code cleanup on CredentialProviderSelectionActivity * added todo comment * Feature/maui migraton passkeys android unlock fix andreas (#3077) * fix: bitwarden providing too many/wrong credentials * feat: use authenticator instead of client --------- Co-authored-by: Dinis Vieira <dinisvieira@outlook.com> * Removed / commented some older Passkey Proof of concept code. Auth and creation of passkey should still work both when device is unlocked (and not) Added some initial code in AutofillCiphersPageViewModel and CipherAddEditPageViewModel for handling Passkey creation * PM-6829 Implemented Fido2...UserInterfaces on Android and necessary logic to get/make a credential with those * Added IFido2MediatorService registrations Inverted two IsLockedAsync checks * Added navigation to autofillCipher when creating passkey * Updated LockPage to avoid multiple executions of SubmitAsync * Added new flow for creating new passkey on Android with the Cipher page for editing details * Changed the Credential Provider Switch to an external link control * Added i18n for Passkey Settings * Cleanup of older Credentials code used for Android Fido2 POC. Removed CredentialCreationActivity as it's no longer needed * fixed merge conflict/error and added error check to Fido2 navigation in App.xaml.cs * Removed from MainActivity casts from DeviceActionService Changed CredentialProviderServiceActivity to handle Fido errors and exceptions gracefully and show the user an error. Still not with the correct messages. * Added some error messages. Still need to confirm the Text Resource to use and change. * Changed some messages to use AppResources * Cleanup of Credential Android code and added exception result if the clientCreateCredentialResult is null * Updated Add new item button text when creating a new passkey * Added AccountSwitchedException for the Fido Mediator Service * Removed TODO that is no longer needed * Updated some todo messages in Android AutofillHandler * When authenticating a passkey on Android the "showDialog" callback can be called and there's no MainPage available so it was changed for that specific scenario to use _deviceActionService instead of MainPage. --------- Co-authored-by: Andreas Coroiu <andreas.coroiu@gmail.com> Co-authored-by: Federico Maccaroni <fedemkr@gmail.com>
2024-04-09 22:57:31 +02:00
using Bit.App.Abstractions;
using Bit.Core.Abstractions;
using Bit.Core.Utilities;
[PM-5153] Android Passkey Implementation (#3020) * Initial WIP implementation for the app unlock flow when called from Passkey. Still needs code organization and to be finished. Also added a new Window workaround in App.xaml.cs to allow CredentialProviderSelectionActivity to launch separately. * Added missing IDeviceActionService.cs implementation for iOS to build. * Added Async to ReturnToPasskeyAfterUnlockMethod Changed i18n to AppResource.Unlock Removed unecessary cast * minor code change (added comment) * Added back the case for loading a specific Window for CredentialProviverSelectionActivity * Added fix for Intent not passing properly to CredentialProviderSelectionActivity Added Activity cancellation on error during execution of ReturnToPasskeyAfterUnlockAsync() * Added WIP code for Android passkey implementation. Currently returns a mostly complete response that is missing the ClientDataJson * Added WIP code for creating passkeys on Android. Still missing unlock flow and response of passkey creation is still not correct. Removed unused throw NotImplementedException from Fido2ClientService Added CredentialCreationActivity for passkey creation Added alternative code on CredentialProviderSelectionActivity to try to debug issue with response not being valid * Started working on logic to adding unlock flow. It's already handling the unlock but not passing the PendingIntentHandler info for CredentialCreation to CredentialCreationActivity * Changed "cross-platform" to "platform" * Created CredentialHelpers.cs class to share code used for Populating Passkeys in Android. * Added Passkey Credential Creation shared code to CredentialHelpers. Unlock flow for Passkey creation should now be working also. * Updated code for checking if the CredentialProviderService has been enabled by the user or not. Still WIP, somes notes in code due to Credential API not being complete. Also changed the disable code to open the Credential Settings. * Replaced the AndroidX.Credential helpers with custom JSON creation to fix the response for Credential Creation * minor code cleanup on CredentialProviderSelectionActivity * added todo comment * Feature/maui migraton passkeys android unlock fix andreas (#3077) * fix: bitwarden providing too many/wrong credentials * feat: use authenticator instead of client --------- Co-authored-by: Dinis Vieira <dinisvieira@outlook.com> * Removed / commented some older Passkey Proof of concept code. Auth and creation of passkey should still work both when device is unlocked (and not) Added some initial code in AutofillCiphersPageViewModel and CipherAddEditPageViewModel for handling Passkey creation * PM-6829 Implemented Fido2...UserInterfaces on Android and necessary logic to get/make a credential with those * Added IFido2MediatorService registrations Inverted two IsLockedAsync checks * Added navigation to autofillCipher when creating passkey * Updated LockPage to avoid multiple executions of SubmitAsync * Added new flow for creating new passkey on Android with the Cipher page for editing details * Changed the Credential Provider Switch to an external link control * Added i18n for Passkey Settings * Cleanup of older Credentials code used for Android Fido2 POC. Removed CredentialCreationActivity as it's no longer needed * fixed merge conflict/error and added error check to Fido2 navigation in App.xaml.cs * Removed from MainActivity casts from DeviceActionService Changed CredentialProviderServiceActivity to handle Fido errors and exceptions gracefully and show the user an error. Still not with the correct messages. * Added some error messages. Still need to confirm the Text Resource to use and change. * Changed some messages to use AppResources * Cleanup of Credential Android code and added exception result if the clientCreateCredentialResult is null * Updated Add new item button text when creating a new passkey * Added AccountSwitchedException for the Fido Mediator Service * Removed TODO that is no longer needed * Updated some todo messages in Android AutofillHandler * When authenticating a passkey on Android the "showDialog" callback can be called and there's no MainPage available so it was changed for that specific scenario to use _deviceActionService instead of MainPage. --------- Co-authored-by: Andreas Coroiu <andreas.coroiu@gmail.com> Co-authored-by: Federico Maccaroni <fedemkr@gmail.com>
2024-04-09 22:57:31 +02:00
using Bit.Core.Resources.Localization;
using Bit.Core.Utilities.Fido2;
using Bit.Core.Services;
using Bit.App.Platforms.Android.Autofill;
using AndroidX.Credentials.Exceptions;
using Org.Json;
namespace Bit.Droid.Autofill
{
[Activity(
NoHistory = true,
LaunchMode = LaunchMode.SingleTop)]
public class CredentialProviderSelectionActivity : MauiAppCompatActivity
{
[PM-5153] Android Passkey Implementation (#3020) * Initial WIP implementation for the app unlock flow when called from Passkey. Still needs code organization and to be finished. Also added a new Window workaround in App.xaml.cs to allow CredentialProviderSelectionActivity to launch separately. * Added missing IDeviceActionService.cs implementation for iOS to build. * Added Async to ReturnToPasskeyAfterUnlockMethod Changed i18n to AppResource.Unlock Removed unecessary cast * minor code change (added comment) * Added back the case for loading a specific Window for CredentialProviverSelectionActivity * Added fix for Intent not passing properly to CredentialProviderSelectionActivity Added Activity cancellation on error during execution of ReturnToPasskeyAfterUnlockAsync() * Added WIP code for Android passkey implementation. Currently returns a mostly complete response that is missing the ClientDataJson * Added WIP code for creating passkeys on Android. Still missing unlock flow and response of passkey creation is still not correct. Removed unused throw NotImplementedException from Fido2ClientService Added CredentialCreationActivity for passkey creation Added alternative code on CredentialProviderSelectionActivity to try to debug issue with response not being valid * Started working on logic to adding unlock flow. It's already handling the unlock but not passing the PendingIntentHandler info for CredentialCreation to CredentialCreationActivity * Changed "cross-platform" to "platform" * Created CredentialHelpers.cs class to share code used for Populating Passkeys in Android. * Added Passkey Credential Creation shared code to CredentialHelpers. Unlock flow for Passkey creation should now be working also. * Updated code for checking if the CredentialProviderService has been enabled by the user or not. Still WIP, somes notes in code due to Credential API not being complete. Also changed the disable code to open the Credential Settings. * Replaced the AndroidX.Credential helpers with custom JSON creation to fix the response for Credential Creation * minor code cleanup on CredentialProviderSelectionActivity * added todo comment * Feature/maui migraton passkeys android unlock fix andreas (#3077) * fix: bitwarden providing too many/wrong credentials * feat: use authenticator instead of client --------- Co-authored-by: Dinis Vieira <dinisvieira@outlook.com> * Removed / commented some older Passkey Proof of concept code. Auth and creation of passkey should still work both when device is unlocked (and not) Added some initial code in AutofillCiphersPageViewModel and CipherAddEditPageViewModel for handling Passkey creation * PM-6829 Implemented Fido2...UserInterfaces on Android and necessary logic to get/make a credential with those * Added IFido2MediatorService registrations Inverted two IsLockedAsync checks * Added navigation to autofillCipher when creating passkey * Updated LockPage to avoid multiple executions of SubmitAsync * Added new flow for creating new passkey on Android with the Cipher page for editing details * Changed the Credential Provider Switch to an external link control * Added i18n for Passkey Settings * Cleanup of older Credentials code used for Android Fido2 POC. Removed CredentialCreationActivity as it's no longer needed * fixed merge conflict/error and added error check to Fido2 navigation in App.xaml.cs * Removed from MainActivity casts from DeviceActionService Changed CredentialProviderServiceActivity to handle Fido errors and exceptions gracefully and show the user an error. Still not with the correct messages. * Added some error messages. Still need to confirm the Text Resource to use and change. * Changed some messages to use AppResources * Cleanup of Credential Android code and added exception result if the clientCreateCredentialResult is null * Updated Add new item button text when creating a new passkey * Added AccountSwitchedException for the Fido Mediator Service * Removed TODO that is no longer needed * Updated some todo messages in Android AutofillHandler * When authenticating a passkey on Android the "showDialog" callback can be called and there's no MainPage available so it was changed for that specific scenario to use _deviceActionService instead of MainPage. --------- Co-authored-by: Andreas Coroiu <andreas.coroiu@gmail.com> Co-authored-by: Federico Maccaroni <fedemkr@gmail.com>
2024-04-09 22:57:31 +02:00
private LazyResolve<IFido2MediatorService> _fido2MediatorService = new LazyResolve<IFido2MediatorService>();
private LazyResolve<IFido2AndroidGetAssertionUserInterface> _fido2GetAssertionUserInterface = new LazyResolve<IFido2AndroidGetAssertionUserInterface>();
[PM-5153] Android Passkey Implementation (#3020) * Initial WIP implementation for the app unlock flow when called from Passkey. Still needs code organization and to be finished. Also added a new Window workaround in App.xaml.cs to allow CredentialProviderSelectionActivity to launch separately. * Added missing IDeviceActionService.cs implementation for iOS to build. * Added Async to ReturnToPasskeyAfterUnlockMethod Changed i18n to AppResource.Unlock Removed unecessary cast * minor code change (added comment) * Added back the case for loading a specific Window for CredentialProviverSelectionActivity * Added fix for Intent not passing properly to CredentialProviderSelectionActivity Added Activity cancellation on error during execution of ReturnToPasskeyAfterUnlockAsync() * Added WIP code for Android passkey implementation. Currently returns a mostly complete response that is missing the ClientDataJson * Added WIP code for creating passkeys on Android. Still missing unlock flow and response of passkey creation is still not correct. Removed unused throw NotImplementedException from Fido2ClientService Added CredentialCreationActivity for passkey creation Added alternative code on CredentialProviderSelectionActivity to try to debug issue with response not being valid * Started working on logic to adding unlock flow. It's already handling the unlock but not passing the PendingIntentHandler info for CredentialCreation to CredentialCreationActivity * Changed "cross-platform" to "platform" * Created CredentialHelpers.cs class to share code used for Populating Passkeys in Android. * Added Passkey Credential Creation shared code to CredentialHelpers. Unlock flow for Passkey creation should now be working also. * Updated code for checking if the CredentialProviderService has been enabled by the user or not. Still WIP, somes notes in code due to Credential API not being complete. Also changed the disable code to open the Credential Settings. * Replaced the AndroidX.Credential helpers with custom JSON creation to fix the response for Credential Creation * minor code cleanup on CredentialProviderSelectionActivity * added todo comment * Feature/maui migraton passkeys android unlock fix andreas (#3077) * fix: bitwarden providing too many/wrong credentials * feat: use authenticator instead of client --------- Co-authored-by: Dinis Vieira <dinisvieira@outlook.com> * Removed / commented some older Passkey Proof of concept code. Auth and creation of passkey should still work both when device is unlocked (and not) Added some initial code in AutofillCiphersPageViewModel and CipherAddEditPageViewModel for handling Passkey creation * PM-6829 Implemented Fido2...UserInterfaces on Android and necessary logic to get/make a credential with those * Added IFido2MediatorService registrations Inverted two IsLockedAsync checks * Added navigation to autofillCipher when creating passkey * Updated LockPage to avoid multiple executions of SubmitAsync * Added new flow for creating new passkey on Android with the Cipher page for editing details * Changed the Credential Provider Switch to an external link control * Added i18n for Passkey Settings * Cleanup of older Credentials code used for Android Fido2 POC. Removed CredentialCreationActivity as it's no longer needed * fixed merge conflict/error and added error check to Fido2 navigation in App.xaml.cs * Removed from MainActivity casts from DeviceActionService Changed CredentialProviderServiceActivity to handle Fido errors and exceptions gracefully and show the user an error. Still not with the correct messages. * Added some error messages. Still need to confirm the Text Resource to use and change. * Changed some messages to use AppResources * Cleanup of Credential Android code and added exception result if the clientCreateCredentialResult is null * Updated Add new item button text when creating a new passkey * Added AccountSwitchedException for the Fido Mediator Service * Removed TODO that is no longer needed * Updated some todo messages in Android AutofillHandler * When authenticating a passkey on Android the "showDialog" callback can be called and there's no MainPage available so it was changed for that specific scenario to use _deviceActionService instead of MainPage. --------- Co-authored-by: Andreas Coroiu <andreas.coroiu@gmail.com> Co-authored-by: Federico Maccaroni <fedemkr@gmail.com>
2024-04-09 22:57:31 +02:00
private LazyResolve<IVaultTimeoutService> _vaultTimeoutService = new LazyResolve<IVaultTimeoutService>();
private LazyResolve<IStateService> _stateService = new LazyResolve<IStateService>();
private LazyResolve<ICipherService> _cipherService = new LazyResolve<ICipherService>();
private LazyResolve<IUserVerificationMediatorService> _userVerificationMediatorService = new LazyResolve<IUserVerificationMediatorService>();
private LazyResolve<IDeviceActionService> _deviceActionService = new LazyResolve<IDeviceActionService>();
protected override void OnCreate(Bundle bundle)
{
Intent?.Validate();
base.OnCreate(bundle);
var cipherId = Intent?.GetStringExtra(CredentialProviderConstants.CredentialProviderCipherId);
if (string.IsNullOrEmpty(cipherId))
{
Finish();
return;
}
[PM-5153] Android Passkey Implementation (#3020) * Initial WIP implementation for the app unlock flow when called from Passkey. Still needs code organization and to be finished. Also added a new Window workaround in App.xaml.cs to allow CredentialProviderSelectionActivity to launch separately. * Added missing IDeviceActionService.cs implementation for iOS to build. * Added Async to ReturnToPasskeyAfterUnlockMethod Changed i18n to AppResource.Unlock Removed unecessary cast * minor code change (added comment) * Added back the case for loading a specific Window for CredentialProviverSelectionActivity * Added fix for Intent not passing properly to CredentialProviderSelectionActivity Added Activity cancellation on error during execution of ReturnToPasskeyAfterUnlockAsync() * Added WIP code for Android passkey implementation. Currently returns a mostly complete response that is missing the ClientDataJson * Added WIP code for creating passkeys on Android. Still missing unlock flow and response of passkey creation is still not correct. Removed unused throw NotImplementedException from Fido2ClientService Added CredentialCreationActivity for passkey creation Added alternative code on CredentialProviderSelectionActivity to try to debug issue with response not being valid * Started working on logic to adding unlock flow. It's already handling the unlock but not passing the PendingIntentHandler info for CredentialCreation to CredentialCreationActivity * Changed "cross-platform" to "platform" * Created CredentialHelpers.cs class to share code used for Populating Passkeys in Android. * Added Passkey Credential Creation shared code to CredentialHelpers. Unlock flow for Passkey creation should now be working also. * Updated code for checking if the CredentialProviderService has been enabled by the user or not. Still WIP, somes notes in code due to Credential API not being complete. Also changed the disable code to open the Credential Settings. * Replaced the AndroidX.Credential helpers with custom JSON creation to fix the response for Credential Creation * minor code cleanup on CredentialProviderSelectionActivity * added todo comment * Feature/maui migraton passkeys android unlock fix andreas (#3077) * fix: bitwarden providing too many/wrong credentials * feat: use authenticator instead of client --------- Co-authored-by: Dinis Vieira <dinisvieira@outlook.com> * Removed / commented some older Passkey Proof of concept code. Auth and creation of passkey should still work both when device is unlocked (and not) Added some initial code in AutofillCiphersPageViewModel and CipherAddEditPageViewModel for handling Passkey creation * PM-6829 Implemented Fido2...UserInterfaces on Android and necessary logic to get/make a credential with those * Added IFido2MediatorService registrations Inverted two IsLockedAsync checks * Added navigation to autofillCipher when creating passkey * Updated LockPage to avoid multiple executions of SubmitAsync * Added new flow for creating new passkey on Android with the Cipher page for editing details * Changed the Credential Provider Switch to an external link control * Added i18n for Passkey Settings * Cleanup of older Credentials code used for Android Fido2 POC. Removed CredentialCreationActivity as it's no longer needed * fixed merge conflict/error and added error check to Fido2 navigation in App.xaml.cs * Removed from MainActivity casts from DeviceActionService Changed CredentialProviderServiceActivity to handle Fido errors and exceptions gracefully and show the user an error. Still not with the correct messages. * Added some error messages. Still need to confirm the Text Resource to use and change. * Changed some messages to use AppResources * Cleanup of Credential Android code and added exception result if the clientCreateCredentialResult is null * Updated Add new item button text when creating a new passkey * Added AccountSwitchedException for the Fido Mediator Service * Removed TODO that is no longer needed * Updated some todo messages in Android AutofillHandler * When authenticating a passkey on Android the "showDialog" callback can be called and there's no MainPage available so it was changed for that specific scenario to use _deviceActionService instead of MainPage. --------- Co-authored-by: Andreas Coroiu <andreas.coroiu@gmail.com> Co-authored-by: Federico Maccaroni <fedemkr@gmail.com>
2024-04-09 22:57:31 +02:00
GetCipherAndPerformFido2AuthAsync(cipherId).FireAndForget();
}
//Used to avoid crash on MAUI when doing back
public override void OnBackPressed()
{
Finish();
}
[PM-5153] Android Passkey Implementation (#3020) * Initial WIP implementation for the app unlock flow when called from Passkey. Still needs code organization and to be finished. Also added a new Window workaround in App.xaml.cs to allow CredentialProviderSelectionActivity to launch separately. * Added missing IDeviceActionService.cs implementation for iOS to build. * Added Async to ReturnToPasskeyAfterUnlockMethod Changed i18n to AppResource.Unlock Removed unecessary cast * minor code change (added comment) * Added back the case for loading a specific Window for CredentialProviverSelectionActivity * Added fix for Intent not passing properly to CredentialProviderSelectionActivity Added Activity cancellation on error during execution of ReturnToPasskeyAfterUnlockAsync() * Added WIP code for Android passkey implementation. Currently returns a mostly complete response that is missing the ClientDataJson * Added WIP code for creating passkeys on Android. Still missing unlock flow and response of passkey creation is still not correct. Removed unused throw NotImplementedException from Fido2ClientService Added CredentialCreationActivity for passkey creation Added alternative code on CredentialProviderSelectionActivity to try to debug issue with response not being valid * Started working on logic to adding unlock flow. It's already handling the unlock but not passing the PendingIntentHandler info for CredentialCreation to CredentialCreationActivity * Changed "cross-platform" to "platform" * Created CredentialHelpers.cs class to share code used for Populating Passkeys in Android. * Added Passkey Credential Creation shared code to CredentialHelpers. Unlock flow for Passkey creation should now be working also. * Updated code for checking if the CredentialProviderService has been enabled by the user or not. Still WIP, somes notes in code due to Credential API not being complete. Also changed the disable code to open the Credential Settings. * Replaced the AndroidX.Credential helpers with custom JSON creation to fix the response for Credential Creation * minor code cleanup on CredentialProviderSelectionActivity * added todo comment * Feature/maui migraton passkeys android unlock fix andreas (#3077) * fix: bitwarden providing too many/wrong credentials * feat: use authenticator instead of client --------- Co-authored-by: Dinis Vieira <dinisvieira@outlook.com> * Removed / commented some older Passkey Proof of concept code. Auth and creation of passkey should still work both when device is unlocked (and not) Added some initial code in AutofillCiphersPageViewModel and CipherAddEditPageViewModel for handling Passkey creation * PM-6829 Implemented Fido2...UserInterfaces on Android and necessary logic to get/make a credential with those * Added IFido2MediatorService registrations Inverted two IsLockedAsync checks * Added navigation to autofillCipher when creating passkey * Updated LockPage to avoid multiple executions of SubmitAsync * Added new flow for creating new passkey on Android with the Cipher page for editing details * Changed the Credential Provider Switch to an external link control * Added i18n for Passkey Settings * Cleanup of older Credentials code used for Android Fido2 POC. Removed CredentialCreationActivity as it's no longer needed * fixed merge conflict/error and added error check to Fido2 navigation in App.xaml.cs * Removed from MainActivity casts from DeviceActionService Changed CredentialProviderServiceActivity to handle Fido errors and exceptions gracefully and show the user an error. Still not with the correct messages. * Added some error messages. Still need to confirm the Text Resource to use and change. * Changed some messages to use AppResources * Cleanup of Credential Android code and added exception result if the clientCreateCredentialResult is null * Updated Add new item button text when creating a new passkey * Added AccountSwitchedException for the Fido Mediator Service * Removed TODO that is no longer needed * Updated some todo messages in Android AutofillHandler * When authenticating a passkey on Android the "showDialog" callback can be called and there's no MainPage available so it was changed for that specific scenario to use _deviceActionService instead of MainPage. --------- Co-authored-by: Andreas Coroiu <andreas.coroiu@gmail.com> Co-authored-by: Federico Maccaroni <fedemkr@gmail.com>
2024-04-09 22:57:31 +02:00
private async Task GetCipherAndPerformFido2AuthAsync(string cipherId)
{
[PM-5153] Android Passkey Implementation (#3020) * Initial WIP implementation for the app unlock flow when called from Passkey. Still needs code organization and to be finished. Also added a new Window workaround in App.xaml.cs to allow CredentialProviderSelectionActivity to launch separately. * Added missing IDeviceActionService.cs implementation for iOS to build. * Added Async to ReturnToPasskeyAfterUnlockMethod Changed i18n to AppResource.Unlock Removed unecessary cast * minor code change (added comment) * Added back the case for loading a specific Window for CredentialProviverSelectionActivity * Added fix for Intent not passing properly to CredentialProviderSelectionActivity Added Activity cancellation on error during execution of ReturnToPasskeyAfterUnlockAsync() * Added WIP code for Android passkey implementation. Currently returns a mostly complete response that is missing the ClientDataJson * Added WIP code for creating passkeys on Android. Still missing unlock flow and response of passkey creation is still not correct. Removed unused throw NotImplementedException from Fido2ClientService Added CredentialCreationActivity for passkey creation Added alternative code on CredentialProviderSelectionActivity to try to debug issue with response not being valid * Started working on logic to adding unlock flow. It's already handling the unlock but not passing the PendingIntentHandler info for CredentialCreation to CredentialCreationActivity * Changed "cross-platform" to "platform" * Created CredentialHelpers.cs class to share code used for Populating Passkeys in Android. * Added Passkey Credential Creation shared code to CredentialHelpers. Unlock flow for Passkey creation should now be working also. * Updated code for checking if the CredentialProviderService has been enabled by the user or not. Still WIP, somes notes in code due to Credential API not being complete. Also changed the disable code to open the Credential Settings. * Replaced the AndroidX.Credential helpers with custom JSON creation to fix the response for Credential Creation * minor code cleanup on CredentialProviderSelectionActivity * added todo comment * Feature/maui migraton passkeys android unlock fix andreas (#3077) * fix: bitwarden providing too many/wrong credentials * feat: use authenticator instead of client --------- Co-authored-by: Dinis Vieira <dinisvieira@outlook.com> * Removed / commented some older Passkey Proof of concept code. Auth and creation of passkey should still work both when device is unlocked (and not) Added some initial code in AutofillCiphersPageViewModel and CipherAddEditPageViewModel for handling Passkey creation * PM-6829 Implemented Fido2...UserInterfaces on Android and necessary logic to get/make a credential with those * Added IFido2MediatorService registrations Inverted two IsLockedAsync checks * Added navigation to autofillCipher when creating passkey * Updated LockPage to avoid multiple executions of SubmitAsync * Added new flow for creating new passkey on Android with the Cipher page for editing details * Changed the Credential Provider Switch to an external link control * Added i18n for Passkey Settings * Cleanup of older Credentials code used for Android Fido2 POC. Removed CredentialCreationActivity as it's no longer needed * fixed merge conflict/error and added error check to Fido2 navigation in App.xaml.cs * Removed from MainActivity casts from DeviceActionService Changed CredentialProviderServiceActivity to handle Fido errors and exceptions gracefully and show the user an error. Still not with the correct messages. * Added some error messages. Still need to confirm the Text Resource to use and change. * Changed some messages to use AppResources * Cleanup of Credential Android code and added exception result if the clientCreateCredentialResult is null * Updated Add new item button text when creating a new passkey * Added AccountSwitchedException for the Fido Mediator Service * Removed TODO that is no longer needed * Updated some todo messages in Android AutofillHandler * When authenticating a passkey on Android the "showDialog" callback can be called and there's no MainPage available so it was changed for that specific scenario to use _deviceActionService instead of MainPage. --------- Co-authored-by: Andreas Coroiu <andreas.coroiu@gmail.com> Co-authored-by: Federico Maccaroni <fedemkr@gmail.com>
2024-04-09 22:57:31 +02:00
string RpId = string.Empty;
try
{
var getRequest = PendingIntentHandler.RetrieveProviderGetCredentialRequest(Intent);
if (getRequest is null)
{
FailAndFinish();
return;
}
var credentialOption = getRequest.CredentialOptions.FirstOrDefault();
[PM-5153] Android Passkey Implementation (#3020) * Initial WIP implementation for the app unlock flow when called from Passkey. Still needs code organization and to be finished. Also added a new Window workaround in App.xaml.cs to allow CredentialProviderSelectionActivity to launch separately. * Added missing IDeviceActionService.cs implementation for iOS to build. * Added Async to ReturnToPasskeyAfterUnlockMethod Changed i18n to AppResource.Unlock Removed unecessary cast * minor code change (added comment) * Added back the case for loading a specific Window for CredentialProviverSelectionActivity * Added fix for Intent not passing properly to CredentialProviderSelectionActivity Added Activity cancellation on error during execution of ReturnToPasskeyAfterUnlockAsync() * Added WIP code for Android passkey implementation. Currently returns a mostly complete response that is missing the ClientDataJson * Added WIP code for creating passkeys on Android. Still missing unlock flow and response of passkey creation is still not correct. Removed unused throw NotImplementedException from Fido2ClientService Added CredentialCreationActivity for passkey creation Added alternative code on CredentialProviderSelectionActivity to try to debug issue with response not being valid * Started working on logic to adding unlock flow. It's already handling the unlock but not passing the PendingIntentHandler info for CredentialCreation to CredentialCreationActivity * Changed "cross-platform" to "platform" * Created CredentialHelpers.cs class to share code used for Populating Passkeys in Android. * Added Passkey Credential Creation shared code to CredentialHelpers. Unlock flow for Passkey creation should now be working also. * Updated code for checking if the CredentialProviderService has been enabled by the user or not. Still WIP, somes notes in code due to Credential API not being complete. Also changed the disable code to open the Credential Settings. * Replaced the AndroidX.Credential helpers with custom JSON creation to fix the response for Credential Creation * minor code cleanup on CredentialProviderSelectionActivity * added todo comment * Feature/maui migraton passkeys android unlock fix andreas (#3077) * fix: bitwarden providing too many/wrong credentials * feat: use authenticator instead of client --------- Co-authored-by: Dinis Vieira <dinisvieira@outlook.com> * Removed / commented some older Passkey Proof of concept code. Auth and creation of passkey should still work both when device is unlocked (and not) Added some initial code in AutofillCiphersPageViewModel and CipherAddEditPageViewModel for handling Passkey creation * PM-6829 Implemented Fido2...UserInterfaces on Android and necessary logic to get/make a credential with those * Added IFido2MediatorService registrations Inverted two IsLockedAsync checks * Added navigation to autofillCipher when creating passkey * Updated LockPage to avoid multiple executions of SubmitAsync * Added new flow for creating new passkey on Android with the Cipher page for editing details * Changed the Credential Provider Switch to an external link control * Added i18n for Passkey Settings * Cleanup of older Credentials code used for Android Fido2 POC. Removed CredentialCreationActivity as it's no longer needed * fixed merge conflict/error and added error check to Fido2 navigation in App.xaml.cs * Removed from MainActivity casts from DeviceActionService Changed CredentialProviderServiceActivity to handle Fido errors and exceptions gracefully and show the user an error. Still not with the correct messages. * Added some error messages. Still need to confirm the Text Resource to use and change. * Changed some messages to use AppResources * Cleanup of Credential Android code and added exception result if the clientCreateCredentialResult is null * Updated Add new item button text when creating a new passkey * Added AccountSwitchedException for the Fido Mediator Service * Removed TODO that is no longer needed * Updated some todo messages in Android AutofillHandler * When authenticating a passkey on Android the "showDialog" callback can be called and there's no MainPage available so it was changed for that specific scenario to use _deviceActionService instead of MainPage. --------- Co-authored-by: Andreas Coroiu <andreas.coroiu@gmail.com> Co-authored-by: Federico Maccaroni <fedemkr@gmail.com>
2024-04-09 22:57:31 +02:00
var credentialPublic = credentialOption as GetPublicKeyCredentialOption;
var requestOptions = new PublicKeyCredentialRequestOptions(credentialPublic.RequestJson);
RpId = requestOptions.RpId;
[PM-5153] Android Passkey Implementation (#3020) * Initial WIP implementation for the app unlock flow when called from Passkey. Still needs code organization and to be finished. Also added a new Window workaround in App.xaml.cs to allow CredentialProviderSelectionActivity to launch separately. * Added missing IDeviceActionService.cs implementation for iOS to build. * Added Async to ReturnToPasskeyAfterUnlockMethod Changed i18n to AppResource.Unlock Removed unecessary cast * minor code change (added comment) * Added back the case for loading a specific Window for CredentialProviverSelectionActivity * Added fix for Intent not passing properly to CredentialProviderSelectionActivity Added Activity cancellation on error during execution of ReturnToPasskeyAfterUnlockAsync() * Added WIP code for Android passkey implementation. Currently returns a mostly complete response that is missing the ClientDataJson * Added WIP code for creating passkeys on Android. Still missing unlock flow and response of passkey creation is still not correct. Removed unused throw NotImplementedException from Fido2ClientService Added CredentialCreationActivity for passkey creation Added alternative code on CredentialProviderSelectionActivity to try to debug issue with response not being valid * Started working on logic to adding unlock flow. It's already handling the unlock but not passing the PendingIntentHandler info for CredentialCreation to CredentialCreationActivity * Changed "cross-platform" to "platform" * Created CredentialHelpers.cs class to share code used for Populating Passkeys in Android. * Added Passkey Credential Creation shared code to CredentialHelpers. Unlock flow for Passkey creation should now be working also. * Updated code for checking if the CredentialProviderService has been enabled by the user or not. Still WIP, somes notes in code due to Credential API not being complete. Also changed the disable code to open the Credential Settings. * Replaced the AndroidX.Credential helpers with custom JSON creation to fix the response for Credential Creation * minor code cleanup on CredentialProviderSelectionActivity * added todo comment * Feature/maui migraton passkeys android unlock fix andreas (#3077) * fix: bitwarden providing too many/wrong credentials * feat: use authenticator instead of client --------- Co-authored-by: Dinis Vieira <dinisvieira@outlook.com> * Removed / commented some older Passkey Proof of concept code. Auth and creation of passkey should still work both when device is unlocked (and not) Added some initial code in AutofillCiphersPageViewModel and CipherAddEditPageViewModel for handling Passkey creation * PM-6829 Implemented Fido2...UserInterfaces on Android and necessary logic to get/make a credential with those * Added IFido2MediatorService registrations Inverted two IsLockedAsync checks * Added navigation to autofillCipher when creating passkey * Updated LockPage to avoid multiple executions of SubmitAsync * Added new flow for creating new passkey on Android with the Cipher page for editing details * Changed the Credential Provider Switch to an external link control * Added i18n for Passkey Settings * Cleanup of older Credentials code used for Android Fido2 POC. Removed CredentialCreationActivity as it's no longer needed * fixed merge conflict/error and added error check to Fido2 navigation in App.xaml.cs * Removed from MainActivity casts from DeviceActionService Changed CredentialProviderServiceActivity to handle Fido errors and exceptions gracefully and show the user an error. Still not with the correct messages. * Added some error messages. Still need to confirm the Text Resource to use and change. * Changed some messages to use AppResources * Cleanup of Credential Android code and added exception result if the clientCreateCredentialResult is null * Updated Add new item button text when creating a new passkey * Added AccountSwitchedException for the Fido Mediator Service * Removed TODO that is no longer needed * Updated some todo messages in Android AutofillHandler * When authenticating a passkey on Android the "showDialog" callback can be called and there's no MainPage available so it was changed for that specific scenario to use _deviceActionService instead of MainPage. --------- Co-authored-by: Andreas Coroiu <andreas.coroiu@gmail.com> Co-authored-by: Federico Maccaroni <fedemkr@gmail.com>
2024-04-09 22:57:31 +02:00
var requestInfo = Intent.GetBundleExtra(CredentialProviderConstants.CredentialDataIntentExtra);
var credentialId = requestInfo?.GetByteArray(CredentialProviderConstants.CredentialIdIntentExtra);
var hasVaultBeenUnlockedInThisTransaction = Intent.GetBooleanExtra(CredentialProviderConstants.CredentialHasVaultBeenUnlockedInThisTransactionExtra, false);
var androidOrigin = getRequest.CallingAppInfo.GetAndroidOrigin();
var packageName = getRequest.CallingAppInfo.PackageName;
var origin = getRequest.CallingAppInfo.Origin ?? androidOrigin;
if (origin is null)
{
await _deviceActionService.Value.DisplayAlertAsync(AppResources.ErrorReadingPasskey, AppResources.PasskeysNotSupportedForThisApp, AppResources.Ok);
FailAndFinish();
return;
}
_fido2GetAssertionUserInterface.Value.Init(
cipherId,
false,
() => hasVaultBeenUnlockedInThisTransaction,
RpId
);
var clientAssertParams = new Fido2ClientAssertCredentialParams
[PM-5153] Android Passkey Implementation (#3020) * Initial WIP implementation for the app unlock flow when called from Passkey. Still needs code organization and to be finished. Also added a new Window workaround in App.xaml.cs to allow CredentialProviderSelectionActivity to launch separately. * Added missing IDeviceActionService.cs implementation for iOS to build. * Added Async to ReturnToPasskeyAfterUnlockMethod Changed i18n to AppResource.Unlock Removed unecessary cast * minor code change (added comment) * Added back the case for loading a specific Window for CredentialProviverSelectionActivity * Added fix for Intent not passing properly to CredentialProviderSelectionActivity Added Activity cancellation on error during execution of ReturnToPasskeyAfterUnlockAsync() * Added WIP code for Android passkey implementation. Currently returns a mostly complete response that is missing the ClientDataJson * Added WIP code for creating passkeys on Android. Still missing unlock flow and response of passkey creation is still not correct. Removed unused throw NotImplementedException from Fido2ClientService Added CredentialCreationActivity for passkey creation Added alternative code on CredentialProviderSelectionActivity to try to debug issue with response not being valid * Started working on logic to adding unlock flow. It's already handling the unlock but not passing the PendingIntentHandler info for CredentialCreation to CredentialCreationActivity * Changed "cross-platform" to "platform" * Created CredentialHelpers.cs class to share code used for Populating Passkeys in Android. * Added Passkey Credential Creation shared code to CredentialHelpers. Unlock flow for Passkey creation should now be working also. * Updated code for checking if the CredentialProviderService has been enabled by the user or not. Still WIP, somes notes in code due to Credential API not being complete. Also changed the disable code to open the Credential Settings. * Replaced the AndroidX.Credential helpers with custom JSON creation to fix the response for Credential Creation * minor code cleanup on CredentialProviderSelectionActivity * added todo comment * Feature/maui migraton passkeys android unlock fix andreas (#3077) * fix: bitwarden providing too many/wrong credentials * feat: use authenticator instead of client --------- Co-authored-by: Dinis Vieira <dinisvieira@outlook.com> * Removed / commented some older Passkey Proof of concept code. Auth and creation of passkey should still work both when device is unlocked (and not) Added some initial code in AutofillCiphersPageViewModel and CipherAddEditPageViewModel for handling Passkey creation * PM-6829 Implemented Fido2...UserInterfaces on Android and necessary logic to get/make a credential with those * Added IFido2MediatorService registrations Inverted two IsLockedAsync checks * Added navigation to autofillCipher when creating passkey * Updated LockPage to avoid multiple executions of SubmitAsync * Added new flow for creating new passkey on Android with the Cipher page for editing details * Changed the Credential Provider Switch to an external link control * Added i18n for Passkey Settings * Cleanup of older Credentials code used for Android Fido2 POC. Removed CredentialCreationActivity as it's no longer needed * fixed merge conflict/error and added error check to Fido2 navigation in App.xaml.cs * Removed from MainActivity casts from DeviceActionService Changed CredentialProviderServiceActivity to handle Fido errors and exceptions gracefully and show the user an error. Still not with the correct messages. * Added some error messages. Still need to confirm the Text Resource to use and change. * Changed some messages to use AppResources * Cleanup of Credential Android code and added exception result if the clientCreateCredentialResult is null * Updated Add new item button text when creating a new passkey * Added AccountSwitchedException for the Fido Mediator Service * Removed TODO that is no longer needed * Updated some todo messages in Android AutofillHandler * When authenticating a passkey on Android the "showDialog" callback can be called and there's no MainPage available so it was changed for that specific scenario to use _deviceActionService instead of MainPage. --------- Co-authored-by: Andreas Coroiu <andreas.coroiu@gmail.com> Co-authored-by: Federico Maccaroni <fedemkr@gmail.com>
2024-04-09 22:57:31 +02:00
{
Challenge = requestOptions.GetChallenge(),
RpId = RpId,
AllowCredentials = new Core.Utilities.Fido2.PublicKeyCredentialDescriptor[] { new Core.Utilities.Fido2.PublicKeyCredentialDescriptor { Id = credentialId } },
Origin = origin,
SameOriginWithAncestors = true,
UserVerification = requestOptions.UserVerification
[PM-5153] Android Passkey Implementation (#3020) * Initial WIP implementation for the app unlock flow when called from Passkey. Still needs code organization and to be finished. Also added a new Window workaround in App.xaml.cs to allow CredentialProviderSelectionActivity to launch separately. * Added missing IDeviceActionService.cs implementation for iOS to build. * Added Async to ReturnToPasskeyAfterUnlockMethod Changed i18n to AppResource.Unlock Removed unecessary cast * minor code change (added comment) * Added back the case for loading a specific Window for CredentialProviverSelectionActivity * Added fix for Intent not passing properly to CredentialProviderSelectionActivity Added Activity cancellation on error during execution of ReturnToPasskeyAfterUnlockAsync() * Added WIP code for Android passkey implementation. Currently returns a mostly complete response that is missing the ClientDataJson * Added WIP code for creating passkeys on Android. Still missing unlock flow and response of passkey creation is still not correct. Removed unused throw NotImplementedException from Fido2ClientService Added CredentialCreationActivity for passkey creation Added alternative code on CredentialProviderSelectionActivity to try to debug issue with response not being valid * Started working on logic to adding unlock flow. It's already handling the unlock but not passing the PendingIntentHandler info for CredentialCreation to CredentialCreationActivity * Changed "cross-platform" to "platform" * Created CredentialHelpers.cs class to share code used for Populating Passkeys in Android. * Added Passkey Credential Creation shared code to CredentialHelpers. Unlock flow for Passkey creation should now be working also. * Updated code for checking if the CredentialProviderService has been enabled by the user or not. Still WIP, somes notes in code due to Credential API not being complete. Also changed the disable code to open the Credential Settings. * Replaced the AndroidX.Credential helpers with custom JSON creation to fix the response for Credential Creation * minor code cleanup on CredentialProviderSelectionActivity * added todo comment * Feature/maui migraton passkeys android unlock fix andreas (#3077) * fix: bitwarden providing too many/wrong credentials * feat: use authenticator instead of client --------- Co-authored-by: Dinis Vieira <dinisvieira@outlook.com> * Removed / commented some older Passkey Proof of concept code. Auth and creation of passkey should still work both when device is unlocked (and not) Added some initial code in AutofillCiphersPageViewModel and CipherAddEditPageViewModel for handling Passkey creation * PM-6829 Implemented Fido2...UserInterfaces on Android and necessary logic to get/make a credential with those * Added IFido2MediatorService registrations Inverted two IsLockedAsync checks * Added navigation to autofillCipher when creating passkey * Updated LockPage to avoid multiple executions of SubmitAsync * Added new flow for creating new passkey on Android with the Cipher page for editing details * Changed the Credential Provider Switch to an external link control * Added i18n for Passkey Settings * Cleanup of older Credentials code used for Android Fido2 POC. Removed CredentialCreationActivity as it's no longer needed * fixed merge conflict/error and added error check to Fido2 navigation in App.xaml.cs * Removed from MainActivity casts from DeviceActionService Changed CredentialProviderServiceActivity to handle Fido errors and exceptions gracefully and show the user an error. Still not with the correct messages. * Added some error messages. Still need to confirm the Text Resource to use and change. * Changed some messages to use AppResources * Cleanup of Credential Android code and added exception result if the clientCreateCredentialResult is null * Updated Add new item button text when creating a new passkey * Added AccountSwitchedException for the Fido Mediator Service * Removed TODO that is no longer needed * Updated some todo messages in Android AutofillHandler * When authenticating a passkey on Android the "showDialog" callback can be called and there's no MainPage available so it was changed for that specific scenario to use _deviceActionService instead of MainPage. --------- Co-authored-by: Andreas Coroiu <andreas.coroiu@gmail.com> Co-authored-by: Federico Maccaroni <fedemkr@gmail.com>
2024-04-09 22:57:31 +02:00
};
var extraAssertParams = new Fido2ExtraAssertCredentialParams
(
getRequest.CallingAppInfo.Origin != null ? credentialPublic.GetClientDataHash() : null,
packageName
[PM-5153] Android Passkey Implementation (#3020) * Initial WIP implementation for the app unlock flow when called from Passkey. Still needs code organization and to be finished. Also added a new Window workaround in App.xaml.cs to allow CredentialProviderSelectionActivity to launch separately. * Added missing IDeviceActionService.cs implementation for iOS to build. * Added Async to ReturnToPasskeyAfterUnlockMethod Changed i18n to AppResource.Unlock Removed unecessary cast * minor code change (added comment) * Added back the case for loading a specific Window for CredentialProviverSelectionActivity * Added fix for Intent not passing properly to CredentialProviderSelectionActivity Added Activity cancellation on error during execution of ReturnToPasskeyAfterUnlockAsync() * Added WIP code for Android passkey implementation. Currently returns a mostly complete response that is missing the ClientDataJson * Added WIP code for creating passkeys on Android. Still missing unlock flow and response of passkey creation is still not correct. Removed unused throw NotImplementedException from Fido2ClientService Added CredentialCreationActivity for passkey creation Added alternative code on CredentialProviderSelectionActivity to try to debug issue with response not being valid * Started working on logic to adding unlock flow. It's already handling the unlock but not passing the PendingIntentHandler info for CredentialCreation to CredentialCreationActivity * Changed "cross-platform" to "platform" * Created CredentialHelpers.cs class to share code used for Populating Passkeys in Android. * Added Passkey Credential Creation shared code to CredentialHelpers. Unlock flow for Passkey creation should now be working also. * Updated code for checking if the CredentialProviderService has been enabled by the user or not. Still WIP, somes notes in code due to Credential API not being complete. Also changed the disable code to open the Credential Settings. * Replaced the AndroidX.Credential helpers with custom JSON creation to fix the response for Credential Creation * minor code cleanup on CredentialProviderSelectionActivity * added todo comment * Feature/maui migraton passkeys android unlock fix andreas (#3077) * fix: bitwarden providing too many/wrong credentials * feat: use authenticator instead of client --------- Co-authored-by: Dinis Vieira <dinisvieira@outlook.com> * Removed / commented some older Passkey Proof of concept code. Auth and creation of passkey should still work both when device is unlocked (and not) Added some initial code in AutofillCiphersPageViewModel and CipherAddEditPageViewModel for handling Passkey creation * PM-6829 Implemented Fido2...UserInterfaces on Android and necessary logic to get/make a credential with those * Added IFido2MediatorService registrations Inverted two IsLockedAsync checks * Added navigation to autofillCipher when creating passkey * Updated LockPage to avoid multiple executions of SubmitAsync * Added new flow for creating new passkey on Android with the Cipher page for editing details * Changed the Credential Provider Switch to an external link control * Added i18n for Passkey Settings * Cleanup of older Credentials code used for Android Fido2 POC. Removed CredentialCreationActivity as it's no longer needed * fixed merge conflict/error and added error check to Fido2 navigation in App.xaml.cs * Removed from MainActivity casts from DeviceActionService Changed CredentialProviderServiceActivity to handle Fido errors and exceptions gracefully and show the user an error. Still not with the correct messages. * Added some error messages. Still need to confirm the Text Resource to use and change. * Changed some messages to use AppResources * Cleanup of Credential Android code and added exception result if the clientCreateCredentialResult is null * Updated Add new item button text when creating a new passkey * Added AccountSwitchedException for the Fido Mediator Service * Removed TODO that is no longer needed * Updated some todo messages in Android AutofillHandler * When authenticating a passkey on Android the "showDialog" callback can be called and there's no MainPage available so it was changed for that specific scenario to use _deviceActionService instead of MainPage. --------- Co-authored-by: Andreas Coroiu <andreas.coroiu@gmail.com> Co-authored-by: Federico Maccaroni <fedemkr@gmail.com>
2024-04-09 22:57:31 +02:00
);
var assertResult = await _fido2MediatorService.Value.AssertCredentialAsync(clientAssertParams, extraAssertParams);
[PM-5153] Android Passkey Implementation (#3020) * Initial WIP implementation for the app unlock flow when called from Passkey. Still needs code organization and to be finished. Also added a new Window workaround in App.xaml.cs to allow CredentialProviderSelectionActivity to launch separately. * Added missing IDeviceActionService.cs implementation for iOS to build. * Added Async to ReturnToPasskeyAfterUnlockMethod Changed i18n to AppResource.Unlock Removed unecessary cast * minor code change (added comment) * Added back the case for loading a specific Window for CredentialProviverSelectionActivity * Added fix for Intent not passing properly to CredentialProviderSelectionActivity Added Activity cancellation on error during execution of ReturnToPasskeyAfterUnlockAsync() * Added WIP code for Android passkey implementation. Currently returns a mostly complete response that is missing the ClientDataJson * Added WIP code for creating passkeys on Android. Still missing unlock flow and response of passkey creation is still not correct. Removed unused throw NotImplementedException from Fido2ClientService Added CredentialCreationActivity for passkey creation Added alternative code on CredentialProviderSelectionActivity to try to debug issue with response not being valid * Started working on logic to adding unlock flow. It's already handling the unlock but not passing the PendingIntentHandler info for CredentialCreation to CredentialCreationActivity * Changed "cross-platform" to "platform" * Created CredentialHelpers.cs class to share code used for Populating Passkeys in Android. * Added Passkey Credential Creation shared code to CredentialHelpers. Unlock flow for Passkey creation should now be working also. * Updated code for checking if the CredentialProviderService has been enabled by the user or not. Still WIP, somes notes in code due to Credential API not being complete. Also changed the disable code to open the Credential Settings. * Replaced the AndroidX.Credential helpers with custom JSON creation to fix the response for Credential Creation * minor code cleanup on CredentialProviderSelectionActivity * added todo comment * Feature/maui migraton passkeys android unlock fix andreas (#3077) * fix: bitwarden providing too many/wrong credentials * feat: use authenticator instead of client --------- Co-authored-by: Dinis Vieira <dinisvieira@outlook.com> * Removed / commented some older Passkey Proof of concept code. Auth and creation of passkey should still work both when device is unlocked (and not) Added some initial code in AutofillCiphersPageViewModel and CipherAddEditPageViewModel for handling Passkey creation * PM-6829 Implemented Fido2...UserInterfaces on Android and necessary logic to get/make a credential with those * Added IFido2MediatorService registrations Inverted two IsLockedAsync checks * Added navigation to autofillCipher when creating passkey * Updated LockPage to avoid multiple executions of SubmitAsync * Added new flow for creating new passkey on Android with the Cipher page for editing details * Changed the Credential Provider Switch to an external link control * Added i18n for Passkey Settings * Cleanup of older Credentials code used for Android Fido2 POC. Removed CredentialCreationActivity as it's no longer needed * fixed merge conflict/error and added error check to Fido2 navigation in App.xaml.cs * Removed from MainActivity casts from DeviceActionService Changed CredentialProviderServiceActivity to handle Fido errors and exceptions gracefully and show the user an error. Still not with the correct messages. * Added some error messages. Still need to confirm the Text Resource to use and change. * Changed some messages to use AppResources * Cleanup of Credential Android code and added exception result if the clientCreateCredentialResult is null * Updated Add new item button text when creating a new passkey * Added AccountSwitchedException for the Fido Mediator Service * Removed TODO that is no longer needed * Updated some todo messages in Android AutofillHandler * When authenticating a passkey on Android the "showDialog" callback can be called and there's no MainPage available so it was changed for that specific scenario to use _deviceActionService instead of MainPage. --------- Co-authored-by: Andreas Coroiu <andreas.coroiu@gmail.com> Co-authored-by: Federico Maccaroni <fedemkr@gmail.com>
2024-04-09 22:57:31 +02:00
var result = new Intent();
var responseInnerAndroidJson = new JSONObject();
if (assertResult.ClientDataJSON != null)
{
responseInnerAndroidJson.Put("clientDataJSON", CoreHelpers.Base64UrlEncode(assertResult.ClientDataJSON));
}
responseInnerAndroidJson.Put("authenticatorData", CoreHelpers.Base64UrlEncode(assertResult.AuthenticatorData));
responseInnerAndroidJson.Put("signature", CoreHelpers.Base64UrlEncode(assertResult.Signature));
responseInnerAndroidJson.Put("userHandle", CoreHelpers.Base64UrlEncode(assertResult.SelectedCredential.UserHandle));
var rootAndroidJson = new JSONObject();
rootAndroidJson.Put("id", CoreHelpers.Base64UrlEncode(assertResult.SelectedCredential.Id));
rootAndroidJson.Put("rawId", CoreHelpers.Base64UrlEncode(assertResult.SelectedCredential.Id));
rootAndroidJson.Put("authenticatorAttachment", "platform");
rootAndroidJson.Put("type", "public-key");
rootAndroidJson.Put("clientExtensionResults", new JSONObject());
rootAndroidJson.Put("response", responseInnerAndroidJson);
var json = rootAndroidJson.ToString();
var cred = new PublicKeyCredential(json);
[PM-5153] Android Passkey Implementation (#3020) * Initial WIP implementation for the app unlock flow when called from Passkey. Still needs code organization and to be finished. Also added a new Window workaround in App.xaml.cs to allow CredentialProviderSelectionActivity to launch separately. * Added missing IDeviceActionService.cs implementation for iOS to build. * Added Async to ReturnToPasskeyAfterUnlockMethod Changed i18n to AppResource.Unlock Removed unecessary cast * minor code change (added comment) * Added back the case for loading a specific Window for CredentialProviverSelectionActivity * Added fix for Intent not passing properly to CredentialProviderSelectionActivity Added Activity cancellation on error during execution of ReturnToPasskeyAfterUnlockAsync() * Added WIP code for Android passkey implementation. Currently returns a mostly complete response that is missing the ClientDataJson * Added WIP code for creating passkeys on Android. Still missing unlock flow and response of passkey creation is still not correct. Removed unused throw NotImplementedException from Fido2ClientService Added CredentialCreationActivity for passkey creation Added alternative code on CredentialProviderSelectionActivity to try to debug issue with response not being valid * Started working on logic to adding unlock flow. It's already handling the unlock but not passing the PendingIntentHandler info for CredentialCreation to CredentialCreationActivity * Changed "cross-platform" to "platform" * Created CredentialHelpers.cs class to share code used for Populating Passkeys in Android. * Added Passkey Credential Creation shared code to CredentialHelpers. Unlock flow for Passkey creation should now be working also. * Updated code for checking if the CredentialProviderService has been enabled by the user or not. Still WIP, somes notes in code due to Credential API not being complete. Also changed the disable code to open the Credential Settings. * Replaced the AndroidX.Credential helpers with custom JSON creation to fix the response for Credential Creation * minor code cleanup on CredentialProviderSelectionActivity * added todo comment * Feature/maui migraton passkeys android unlock fix andreas (#3077) * fix: bitwarden providing too many/wrong credentials * feat: use authenticator instead of client --------- Co-authored-by: Dinis Vieira <dinisvieira@outlook.com> * Removed / commented some older Passkey Proof of concept code. Auth and creation of passkey should still work both when device is unlocked (and not) Added some initial code in AutofillCiphersPageViewModel and CipherAddEditPageViewModel for handling Passkey creation * PM-6829 Implemented Fido2...UserInterfaces on Android and necessary logic to get/make a credential with those * Added IFido2MediatorService registrations Inverted two IsLockedAsync checks * Added navigation to autofillCipher when creating passkey * Updated LockPage to avoid multiple executions of SubmitAsync * Added new flow for creating new passkey on Android with the Cipher page for editing details * Changed the Credential Provider Switch to an external link control * Added i18n for Passkey Settings * Cleanup of older Credentials code used for Android Fido2 POC. Removed CredentialCreationActivity as it's no longer needed * fixed merge conflict/error and added error check to Fido2 navigation in App.xaml.cs * Removed from MainActivity casts from DeviceActionService Changed CredentialProviderServiceActivity to handle Fido errors and exceptions gracefully and show the user an error. Still not with the correct messages. * Added some error messages. Still need to confirm the Text Resource to use and change. * Changed some messages to use AppResources * Cleanup of Credential Android code and added exception result if the clientCreateCredentialResult is null * Updated Add new item button text when creating a new passkey * Added AccountSwitchedException for the Fido Mediator Service * Removed TODO that is no longer needed * Updated some todo messages in Android AutofillHandler * When authenticating a passkey on Android the "showDialog" callback can be called and there's no MainPage available so it was changed for that specific scenario to use _deviceActionService instead of MainPage. --------- Co-authored-by: Andreas Coroiu <andreas.coroiu@gmail.com> Co-authored-by: Federico Maccaroni <fedemkr@gmail.com>
2024-04-09 22:57:31 +02:00
var credResponse = new GetCredentialResponse(cred);
PendingIntentHandler.SetGetCredentialResponse(result, credResponse);
await MainThread.InvokeOnMainThreadAsync(() =>
{
SetResult(Result.Ok, result);
Finish();
});
}
catch (NotAllowedError)
{
await MainThread.InvokeOnMainThreadAsync(async () =>
[PM-5153] Android Passkey Implementation (#3020) * Initial WIP implementation for the app unlock flow when called from Passkey. Still needs code organization and to be finished. Also added a new Window workaround in App.xaml.cs to allow CredentialProviderSelectionActivity to launch separately. * Added missing IDeviceActionService.cs implementation for iOS to build. * Added Async to ReturnToPasskeyAfterUnlockMethod Changed i18n to AppResource.Unlock Removed unecessary cast * minor code change (added comment) * Added back the case for loading a specific Window for CredentialProviverSelectionActivity * Added fix for Intent not passing properly to CredentialProviderSelectionActivity Added Activity cancellation on error during execution of ReturnToPasskeyAfterUnlockAsync() * Added WIP code for Android passkey implementation. Currently returns a mostly complete response that is missing the ClientDataJson * Added WIP code for creating passkeys on Android. Still missing unlock flow and response of passkey creation is still not correct. Removed unused throw NotImplementedException from Fido2ClientService Added CredentialCreationActivity for passkey creation Added alternative code on CredentialProviderSelectionActivity to try to debug issue with response not being valid * Started working on logic to adding unlock flow. It's already handling the unlock but not passing the PendingIntentHandler info for CredentialCreation to CredentialCreationActivity * Changed "cross-platform" to "platform" * Created CredentialHelpers.cs class to share code used for Populating Passkeys in Android. * Added Passkey Credential Creation shared code to CredentialHelpers. Unlock flow for Passkey creation should now be working also. * Updated code for checking if the CredentialProviderService has been enabled by the user or not. Still WIP, somes notes in code due to Credential API not being complete. Also changed the disable code to open the Credential Settings. * Replaced the AndroidX.Credential helpers with custom JSON creation to fix the response for Credential Creation * minor code cleanup on CredentialProviderSelectionActivity * added todo comment * Feature/maui migraton passkeys android unlock fix andreas (#3077) * fix: bitwarden providing too many/wrong credentials * feat: use authenticator instead of client --------- Co-authored-by: Dinis Vieira <dinisvieira@outlook.com> * Removed / commented some older Passkey Proof of concept code. Auth and creation of passkey should still work both when device is unlocked (and not) Added some initial code in AutofillCiphersPageViewModel and CipherAddEditPageViewModel for handling Passkey creation * PM-6829 Implemented Fido2...UserInterfaces on Android and necessary logic to get/make a credential with those * Added IFido2MediatorService registrations Inverted two IsLockedAsync checks * Added navigation to autofillCipher when creating passkey * Updated LockPage to avoid multiple executions of SubmitAsync * Added new flow for creating new passkey on Android with the Cipher page for editing details * Changed the Credential Provider Switch to an external link control * Added i18n for Passkey Settings * Cleanup of older Credentials code used for Android Fido2 POC. Removed CredentialCreationActivity as it's no longer needed * fixed merge conflict/error and added error check to Fido2 navigation in App.xaml.cs * Removed from MainActivity casts from DeviceActionService Changed CredentialProviderServiceActivity to handle Fido errors and exceptions gracefully and show the user an error. Still not with the correct messages. * Added some error messages. Still need to confirm the Text Resource to use and change. * Changed some messages to use AppResources * Cleanup of Credential Android code and added exception result if the clientCreateCredentialResult is null * Updated Add new item button text when creating a new passkey * Added AccountSwitchedException for the Fido Mediator Service * Removed TODO that is no longer needed * Updated some todo messages in Android AutofillHandler * When authenticating a passkey on Android the "showDialog" callback can be called and there's no MainPage available so it was changed for that specific scenario to use _deviceActionService instead of MainPage. --------- Co-authored-by: Andreas Coroiu <andreas.coroiu@gmail.com> Co-authored-by: Federico Maccaroni <fedemkr@gmail.com>
2024-04-09 22:57:31 +02:00
{
await _deviceActionService.Value.DisplayAlertAsync(AppResources.ErrorReadingPasskey, string.Format(AppResources.ThereWasAProblemReadingAPasskeyForXTryAgainLater, RpId), AppResources.Ok);
FailAndFinish();
[PM-5153] Android Passkey Implementation (#3020) * Initial WIP implementation for the app unlock flow when called from Passkey. Still needs code organization and to be finished. Also added a new Window workaround in App.xaml.cs to allow CredentialProviderSelectionActivity to launch separately. * Added missing IDeviceActionService.cs implementation for iOS to build. * Added Async to ReturnToPasskeyAfterUnlockMethod Changed i18n to AppResource.Unlock Removed unecessary cast * minor code change (added comment) * Added back the case for loading a specific Window for CredentialProviverSelectionActivity * Added fix for Intent not passing properly to CredentialProviderSelectionActivity Added Activity cancellation on error during execution of ReturnToPasskeyAfterUnlockAsync() * Added WIP code for Android passkey implementation. Currently returns a mostly complete response that is missing the ClientDataJson * Added WIP code for creating passkeys on Android. Still missing unlock flow and response of passkey creation is still not correct. Removed unused throw NotImplementedException from Fido2ClientService Added CredentialCreationActivity for passkey creation Added alternative code on CredentialProviderSelectionActivity to try to debug issue with response not being valid * Started working on logic to adding unlock flow. It's already handling the unlock but not passing the PendingIntentHandler info for CredentialCreation to CredentialCreationActivity * Changed "cross-platform" to "platform" * Created CredentialHelpers.cs class to share code used for Populating Passkeys in Android. * Added Passkey Credential Creation shared code to CredentialHelpers. Unlock flow for Passkey creation should now be working also. * Updated code for checking if the CredentialProviderService has been enabled by the user or not. Still WIP, somes notes in code due to Credential API not being complete. Also changed the disable code to open the Credential Settings. * Replaced the AndroidX.Credential helpers with custom JSON creation to fix the response for Credential Creation * minor code cleanup on CredentialProviderSelectionActivity * added todo comment * Feature/maui migraton passkeys android unlock fix andreas (#3077) * fix: bitwarden providing too many/wrong credentials * feat: use authenticator instead of client --------- Co-authored-by: Dinis Vieira <dinisvieira@outlook.com> * Removed / commented some older Passkey Proof of concept code. Auth and creation of passkey should still work both when device is unlocked (and not) Added some initial code in AutofillCiphersPageViewModel and CipherAddEditPageViewModel for handling Passkey creation * PM-6829 Implemented Fido2...UserInterfaces on Android and necessary logic to get/make a credential with those * Added IFido2MediatorService registrations Inverted two IsLockedAsync checks * Added navigation to autofillCipher when creating passkey * Updated LockPage to avoid multiple executions of SubmitAsync * Added new flow for creating new passkey on Android with the Cipher page for editing details * Changed the Credential Provider Switch to an external link control * Added i18n for Passkey Settings * Cleanup of older Credentials code used for Android Fido2 POC. Removed CredentialCreationActivity as it's no longer needed * fixed merge conflict/error and added error check to Fido2 navigation in App.xaml.cs * Removed from MainActivity casts from DeviceActionService Changed CredentialProviderServiceActivity to handle Fido errors and exceptions gracefully and show the user an error. Still not with the correct messages. * Added some error messages. Still need to confirm the Text Resource to use and change. * Changed some messages to use AppResources * Cleanup of Credential Android code and added exception result if the clientCreateCredentialResult is null * Updated Add new item button text when creating a new passkey * Added AccountSwitchedException for the Fido Mediator Service * Removed TODO that is no longer needed * Updated some todo messages in Android AutofillHandler * When authenticating a passkey on Android the "showDialog" callback can be called and there's no MainPage available so it was changed for that specific scenario to use _deviceActionService instead of MainPage. --------- Co-authored-by: Andreas Coroiu <andreas.coroiu@gmail.com> Co-authored-by: Federico Maccaroni <fedemkr@gmail.com>
2024-04-09 22:57:31 +02:00
});
}
catch (Exception ex)
{
LoggerHelper.LogEvenIfCantBeResolved(ex);
await MainThread.InvokeOnMainThreadAsync(async () =>
[PM-5153] Android Passkey Implementation (#3020) * Initial WIP implementation for the app unlock flow when called from Passkey. Still needs code organization and to be finished. Also added a new Window workaround in App.xaml.cs to allow CredentialProviderSelectionActivity to launch separately. * Added missing IDeviceActionService.cs implementation for iOS to build. * Added Async to ReturnToPasskeyAfterUnlockMethod Changed i18n to AppResource.Unlock Removed unecessary cast * minor code change (added comment) * Added back the case for loading a specific Window for CredentialProviverSelectionActivity * Added fix for Intent not passing properly to CredentialProviderSelectionActivity Added Activity cancellation on error during execution of ReturnToPasskeyAfterUnlockAsync() * Added WIP code for Android passkey implementation. Currently returns a mostly complete response that is missing the ClientDataJson * Added WIP code for creating passkeys on Android. Still missing unlock flow and response of passkey creation is still not correct. Removed unused throw NotImplementedException from Fido2ClientService Added CredentialCreationActivity for passkey creation Added alternative code on CredentialProviderSelectionActivity to try to debug issue with response not being valid * Started working on logic to adding unlock flow. It's already handling the unlock but not passing the PendingIntentHandler info for CredentialCreation to CredentialCreationActivity * Changed "cross-platform" to "platform" * Created CredentialHelpers.cs class to share code used for Populating Passkeys in Android. * Added Passkey Credential Creation shared code to CredentialHelpers. Unlock flow for Passkey creation should now be working also. * Updated code for checking if the CredentialProviderService has been enabled by the user or not. Still WIP, somes notes in code due to Credential API not being complete. Also changed the disable code to open the Credential Settings. * Replaced the AndroidX.Credential helpers with custom JSON creation to fix the response for Credential Creation * minor code cleanup on CredentialProviderSelectionActivity * added todo comment * Feature/maui migraton passkeys android unlock fix andreas (#3077) * fix: bitwarden providing too many/wrong credentials * feat: use authenticator instead of client --------- Co-authored-by: Dinis Vieira <dinisvieira@outlook.com> * Removed / commented some older Passkey Proof of concept code. Auth and creation of passkey should still work both when device is unlocked (and not) Added some initial code in AutofillCiphersPageViewModel and CipherAddEditPageViewModel for handling Passkey creation * PM-6829 Implemented Fido2...UserInterfaces on Android and necessary logic to get/make a credential with those * Added IFido2MediatorService registrations Inverted two IsLockedAsync checks * Added navigation to autofillCipher when creating passkey * Updated LockPage to avoid multiple executions of SubmitAsync * Added new flow for creating new passkey on Android with the Cipher page for editing details * Changed the Credential Provider Switch to an external link control * Added i18n for Passkey Settings * Cleanup of older Credentials code used for Android Fido2 POC. Removed CredentialCreationActivity as it's no longer needed * fixed merge conflict/error and added error check to Fido2 navigation in App.xaml.cs * Removed from MainActivity casts from DeviceActionService Changed CredentialProviderServiceActivity to handle Fido errors and exceptions gracefully and show the user an error. Still not with the correct messages. * Added some error messages. Still need to confirm the Text Resource to use and change. * Changed some messages to use AppResources * Cleanup of Credential Android code and added exception result if the clientCreateCredentialResult is null * Updated Add new item button text when creating a new passkey * Added AccountSwitchedException for the Fido Mediator Service * Removed TODO that is no longer needed * Updated some todo messages in Android AutofillHandler * When authenticating a passkey on Android the "showDialog" callback can be called and there's no MainPage available so it was changed for that specific scenario to use _deviceActionService instead of MainPage. --------- Co-authored-by: Andreas Coroiu <andreas.coroiu@gmail.com> Co-authored-by: Federico Maccaroni <fedemkr@gmail.com>
2024-04-09 22:57:31 +02:00
{
await _deviceActionService.Value.DisplayAlertAsync(AppResources.ErrorReadingPasskey, string.Format(AppResources.ThereWasAProblemReadingAPasskeyForXTryAgainLater, RpId), AppResources.Ok);
FailAndFinish();
[PM-5153] Android Passkey Implementation (#3020) * Initial WIP implementation for the app unlock flow when called from Passkey. Still needs code organization and to be finished. Also added a new Window workaround in App.xaml.cs to allow CredentialProviderSelectionActivity to launch separately. * Added missing IDeviceActionService.cs implementation for iOS to build. * Added Async to ReturnToPasskeyAfterUnlockMethod Changed i18n to AppResource.Unlock Removed unecessary cast * minor code change (added comment) * Added back the case for loading a specific Window for CredentialProviverSelectionActivity * Added fix for Intent not passing properly to CredentialProviderSelectionActivity Added Activity cancellation on error during execution of ReturnToPasskeyAfterUnlockAsync() * Added WIP code for Android passkey implementation. Currently returns a mostly complete response that is missing the ClientDataJson * Added WIP code for creating passkeys on Android. Still missing unlock flow and response of passkey creation is still not correct. Removed unused throw NotImplementedException from Fido2ClientService Added CredentialCreationActivity for passkey creation Added alternative code on CredentialProviderSelectionActivity to try to debug issue with response not being valid * Started working on logic to adding unlock flow. It's already handling the unlock but not passing the PendingIntentHandler info for CredentialCreation to CredentialCreationActivity * Changed "cross-platform" to "platform" * Created CredentialHelpers.cs class to share code used for Populating Passkeys in Android. * Added Passkey Credential Creation shared code to CredentialHelpers. Unlock flow for Passkey creation should now be working also. * Updated code for checking if the CredentialProviderService has been enabled by the user or not. Still WIP, somes notes in code due to Credential API not being complete. Also changed the disable code to open the Credential Settings. * Replaced the AndroidX.Credential helpers with custom JSON creation to fix the response for Credential Creation * minor code cleanup on CredentialProviderSelectionActivity * added todo comment * Feature/maui migraton passkeys android unlock fix andreas (#3077) * fix: bitwarden providing too many/wrong credentials * feat: use authenticator instead of client --------- Co-authored-by: Dinis Vieira <dinisvieira@outlook.com> * Removed / commented some older Passkey Proof of concept code. Auth and creation of passkey should still work both when device is unlocked (and not) Added some initial code in AutofillCiphersPageViewModel and CipherAddEditPageViewModel for handling Passkey creation * PM-6829 Implemented Fido2...UserInterfaces on Android and necessary logic to get/make a credential with those * Added IFido2MediatorService registrations Inverted two IsLockedAsync checks * Added navigation to autofillCipher when creating passkey * Updated LockPage to avoid multiple executions of SubmitAsync * Added new flow for creating new passkey on Android with the Cipher page for editing details * Changed the Credential Provider Switch to an external link control * Added i18n for Passkey Settings * Cleanup of older Credentials code used for Android Fido2 POC. Removed CredentialCreationActivity as it's no longer needed * fixed merge conflict/error and added error check to Fido2 navigation in App.xaml.cs * Removed from MainActivity casts from DeviceActionService Changed CredentialProviderServiceActivity to handle Fido errors and exceptions gracefully and show the user an error. Still not with the correct messages. * Added some error messages. Still need to confirm the Text Resource to use and change. * Changed some messages to use AppResources * Cleanup of Credential Android code and added exception result if the clientCreateCredentialResult is null * Updated Add new item button text when creating a new passkey * Added AccountSwitchedException for the Fido Mediator Service * Removed TODO that is no longer needed * Updated some todo messages in Android AutofillHandler * When authenticating a passkey on Android the "showDialog" callback can be called and there's no MainPage available so it was changed for that specific scenario to use _deviceActionService instead of MainPage. --------- Co-authored-by: Andreas Coroiu <andreas.coroiu@gmail.com> Co-authored-by: Federico Maccaroni <fedemkr@gmail.com>
2024-04-09 22:57:31 +02:00
});
}
}
private void FailAndFinish()
[PM-5153] Android Passkey Implementation (#3020) * Initial WIP implementation for the app unlock flow when called from Passkey. Still needs code organization and to be finished. Also added a new Window workaround in App.xaml.cs to allow CredentialProviderSelectionActivity to launch separately. * Added missing IDeviceActionService.cs implementation for iOS to build. * Added Async to ReturnToPasskeyAfterUnlockMethod Changed i18n to AppResource.Unlock Removed unecessary cast * minor code change (added comment) * Added back the case for loading a specific Window for CredentialProviverSelectionActivity * Added fix for Intent not passing properly to CredentialProviderSelectionActivity Added Activity cancellation on error during execution of ReturnToPasskeyAfterUnlockAsync() * Added WIP code for Android passkey implementation. Currently returns a mostly complete response that is missing the ClientDataJson * Added WIP code for creating passkeys on Android. Still missing unlock flow and response of passkey creation is still not correct. Removed unused throw NotImplementedException from Fido2ClientService Added CredentialCreationActivity for passkey creation Added alternative code on CredentialProviderSelectionActivity to try to debug issue with response not being valid * Started working on logic to adding unlock flow. It's already handling the unlock but not passing the PendingIntentHandler info for CredentialCreation to CredentialCreationActivity * Changed "cross-platform" to "platform" * Created CredentialHelpers.cs class to share code used for Populating Passkeys in Android. * Added Passkey Credential Creation shared code to CredentialHelpers. Unlock flow for Passkey creation should now be working also. * Updated code for checking if the CredentialProviderService has been enabled by the user or not. Still WIP, somes notes in code due to Credential API not being complete. Also changed the disable code to open the Credential Settings. * Replaced the AndroidX.Credential helpers with custom JSON creation to fix the response for Credential Creation * minor code cleanup on CredentialProviderSelectionActivity * added todo comment * Feature/maui migraton passkeys android unlock fix andreas (#3077) * fix: bitwarden providing too many/wrong credentials * feat: use authenticator instead of client --------- Co-authored-by: Dinis Vieira <dinisvieira@outlook.com> * Removed / commented some older Passkey Proof of concept code. Auth and creation of passkey should still work both when device is unlocked (and not) Added some initial code in AutofillCiphersPageViewModel and CipherAddEditPageViewModel for handling Passkey creation * PM-6829 Implemented Fido2...UserInterfaces on Android and necessary logic to get/make a credential with those * Added IFido2MediatorService registrations Inverted two IsLockedAsync checks * Added navigation to autofillCipher when creating passkey * Updated LockPage to avoid multiple executions of SubmitAsync * Added new flow for creating new passkey on Android with the Cipher page for editing details * Changed the Credential Provider Switch to an external link control * Added i18n for Passkey Settings * Cleanup of older Credentials code used for Android Fido2 POC. Removed CredentialCreationActivity as it's no longer needed * fixed merge conflict/error and added error check to Fido2 navigation in App.xaml.cs * Removed from MainActivity casts from DeviceActionService Changed CredentialProviderServiceActivity to handle Fido errors and exceptions gracefully and show the user an error. Still not with the correct messages. * Added some error messages. Still need to confirm the Text Resource to use and change. * Changed some messages to use AppResources * Cleanup of Credential Android code and added exception result if the clientCreateCredentialResult is null * Updated Add new item button text when creating a new passkey * Added AccountSwitchedException for the Fido Mediator Service * Removed TODO that is no longer needed * Updated some todo messages in Android AutofillHandler * When authenticating a passkey on Android the "showDialog" callback can be called and there's no MainPage available so it was changed for that specific scenario to use _deviceActionService instead of MainPage. --------- Co-authored-by: Andreas Coroiu <andreas.coroiu@gmail.com> Co-authored-by: Federico Maccaroni <fedemkr@gmail.com>
2024-04-09 22:57:31 +02:00
{
var result = new Intent();
PendingIntentHandler.SetGetCredentialException(result, new GetCredentialUnknownException());
SetResult(Result.Ok, result);
Finish();
}
}
}