Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(authentication): ♻️ : refactor vault cipher management. #1026

Merged
merged 8 commits into from
Jul 22, 2024

Conversation

Chralu
Copy link
Collaborator

@Chralu Chralu commented Jul 9, 2024

Description

Fixes #982

Type of change

  • Refactorization

Material used:

  • iOS (Smartphone/Tablet)
  • Android (Smartphone/Tablet)
  • Browser
  • Linux
  • Windows
  • iOS (Mac)

How Has This Been Tested?

  • Creation new wallet
  • Import wallet
  • Manual lock
  • Change authentification type
  • Access to seed screen
  • Enable / Disabled unlock screen with different period
  • Activate / Desactivate shuffle pin
  • Activate / Desactivate hide screen
  • Close wallet

Tested with

  • MacOS ok
  • Iphone with FaceID ok
  • Ipad with TouchID ok
  • Chrome extension ok
  • Windows todo
  • Linux todo

NB: i can't test with yubikey

Patrol

Please list here the tests created in Patrol for this pull request.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Useful info for the reviewer:

@Chralu Chralu force-pushed the Chralu/issue982 branch 12 times, most recently from 91efbae to 9541132 Compare July 16, 2024 12:19
@Chralu Chralu marked this pull request as ready for review July 16, 2024 12:20
@Chralu Chralu requested a review from redDwarf03 July 16, 2024 12:20
@Chralu Chralu changed the title feat(authentication): 🚧 refactor vault cipher management. feat(authentication): ♻️ : refactor vault cipher management. Jul 16, 2024
@redDwarf03

This comment has been minimized.

@redDwarf03

This comment has been minimized.

@redDwarf03

This comment has been minimized.

@redDwarf03 redDwarf03 added this to the 2.3.8 milestone Jul 17, 2024
@Chralu
Copy link
Collaborator Author

Chralu commented Jul 17, 2024

Issues #1029 #1030 #1031 created from comments above.

@Chralu
Copy link
Collaborator Author

Chralu commented Jul 18, 2024

I connect a pixel 4 to VS Code and launch the app.
I tried to create a new wallet with biometrics on testnet but (i don't know why) error to create the keychain.
I exit the app and relaunch in VSCode.
I tried to create a new wallet with pin on testnet and after the confirmation of the pin, i have this error

Launching lib/main.dart on Pixel 4 in debug mode...
✓ Built build/app/outputs/flutter-apk/app-debug.apk
Connecting to VM Service at ws://127.0.0.1:63396/D8OkKYyG8gc=/ws
[GoRouter] setting initial location /
[GoRouter] Full paths for routes:
             => /
             => /logging_out
             => /biometrics
             => /password
             => /pin
             => /yubikey
             => /intro_configure_security
             => /intro_welcome
             => /intro_welcome_get_first_infos
             => /intro_backup
             => /intro_backup_safety
             => /intro_import
             => /intro_backup_confirm
             => /network_dialog
             => /sendingAnimation
             => /set_biometrics
             => /set_password
             => /set_yubikey
             => /home
             => /security_menu_view
             => /customization_menu_view
             => /about_menu_view
             => /nft_list_per_category
             => /nft_creation
             =>   /nft_creation/add_address
             => /messenger_discussion
             => /discussion_details
             => /update_discussion
             => /add_account
             => /add_contact
             => /buy
             => /dex
             => /contact_detail
             => /connectivity_warning
             => /add_token
             => /chart
             => /app_seed_backup
             => /transaction_info
             => /transfer
             => /nft_creation_process_import_tab_aeweb
             => /nft_creation_process_import_tab_http
             => /nft_creation_process_import_tab_ipfs
             => /nft_detail
             => /configure_category_list
             => /create_discussion
             => /settings
             => /create_discussion_validation
             => /add_discussion
             => /update_discussion_add_members
           known full paths for route names:
             add_address => /nft_creation/add_address
[_selectedLanguageProvider] didAddProvider(AvailableLanguage.english)
[_availableLocalesProvider] didAddProvider([en, fr])
[GoRouter] Using MaterialApp configuration
[AuthenticationGuard-Widget] Init state
[AuthenticationGuard-LastInteractionDateProvider] didAddProvider(AsyncLoading<({DateTime? date, bool isStartupValue})>())
[AuthenticationGuard-Provider] didAddProvider(AsyncLoading<AuthenticationGuardState>())
[AuthenticationGuard-Widget] Unschedule lock
W/Parcel  (13037): Expecting binder but got null!
[AuthenticationGuard-LastInteractionDateProvider] didUpdateProvider(AsyncData<({DateTime? date, bool isStartupValue})>(value: (date: null, isStartupValue: true)))
[DataMigration] Current data version: 541
[DataMigration] Skipping migration from version 437
[DataMigration] Skipping migration from version 512
[DataMigration] Skipping migration from version 526
[DataMigration] Skipping migration from version 540
[DataMigration] Skipping migration from version 541
[DataMigration] Migrations successfully executed
[_migrationsProvider] didAddProvider([Instance of 'LocalDataMigration', Instance of 'LocalDataMigration', Instance of 'LocalDataMigration', Instance of 'LocalDataMigration', Instance of 'LocalDataMigration'])
[AuthenticationGuard-Provider] didUpdateProvider(AsyncData<AuthenticationGuardState>(value: AuthenticationGuardState(lockDate: 2024-07-17 19:15:56.902103, timerEnabled: true, isLocked: true)))
[DataMigration] Current data version updated to 541.
[_selectedLocaleProvider] didAddProvider(en_US)
[_verifiedTokensNotifierProvider] didAddProvider([])
[_verifiedTokensRepositoryProvider] didAddProvider(Instance of 'VerifiedTokensRepository')
[_migrationsProvider] didDisposeProvider
W/rchethic_wallet(13037): type=1400 audit(0.0:2071): avc: denied { read } for name="cache" dev="dm-8" ino=16 scontext=u:r:untrusted_app:s0:c32,c257,c512,c768 tcontext=u:object_r:cache_file:s0 tclass=lnk_file permissive=0 app=net.archethic.archethic_wallet
[VerifiedTokensRepository] Verified tokens [00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4, 00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1, 0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827, 00001ED63AC2850CEA282D3D0CA5047418BC2720CB49D15B611D2845611F605716A1]
[VerifiedTokensNotifier] Verified tokens list (AvailableNetworks.archethicTestNet) [00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4, 00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1, 0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827, 00001ED63AC2850CEA282D3D0CA5047418BC2720CB49D15B611D2845611F605716A1]
[_verifiedTokensNotifierProvider] didUpdateProvider([00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4, 00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1, 0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827, 00001ED63AC2850CEA282D3D0CA5047418BC2720CB49D15B611D2845611F605716A1])
I/RootBeer(13037): LOOKING FOR BINARY: /data/local/su Absent :(
I/RootBeer(13037): LOOKING FOR BINARY: /data/local/bin/su Absent :(
I/RootBeer(13037): LOOKING FOR BINARY: /data/local/xbin/su Absent :(
I/RootBeer(13037): LOOKING FOR BINARY: /sbin/su Absent :(
I/RootBeer(13037): LOOKING FOR BINARY: /su/bin/su Absent :(
I/RootBeer(13037): LOOKING FOR BINARY: /system/bin/su Absent :(
I/RootBeer(13037): LOOKING FOR BINARY: /system/bin/.ext/su Absent :(
I/RootBeer(13037): LOOKING FOR BINARY: /system/bin/failsafe/su Absent :(
I/RootBeer(13037): LOOKING FOR BINARY: /system/sd/xbin/su Absent :(
I/RootBeer(13037): LOOKING FOR BINARY: /system/usr/we-need-root/su Absent :(
I/RootBeer(13037): LOOKING FOR BINARY: /system/xbin/su Absent :(
I/RootBeer(13037): LOOKING FOR BINARY: /cache/su Absent :(
I/RootBeer(13037): LOOKING FOR BINARY: /data/su Absent :(
I/RootBeer(13037): LOOKING FOR BINARY: /dev/su Absent :(
I/RootBeer(13037): LOOKING FOR BINARY: /product/bin/su Absent :(
I/RootBeer(13037): LOOKING FOR BINARY: /apex/com.android.runtime/bin/su Absent :(
I/RootBeer(13037): LOOKING FOR BINARY: /apex/com.android.art/bin/su Absent :(
I/RootBeer(13037): LOOKING FOR BINARY: /system_ext/bin/su Absent :(
I/RootBeer(13037): LOOKING FOR BINARY: /odm/bin/su Absent :(
I/RootBeer(13037): LOOKING FOR BINARY: /vendor/bin/su Absent :(
I/RootBeer(13037): LOOKING FOR BINARY: /vendor/xbin/su Absent :(
W/Settings(13037): Setting development_settings_enabled has moved from android.provider.Settings.Secure to android.provider.Settings.Global.
[AuthFactory] Init AuthFactory and Vault authent.
[Vault] Set cipher delegate
[_sessionNotifierProvider] didAddProvider(Instance of 'LoggedOutSession')
[AuthenticationGuard-Provider] Unschedule Autolock
[AuthenticationGuard-LastInteractionDateProvider] clear storage
[AuthenticationGuard-LastInteractionDateProvider] didUpdateProvider(AsyncData<({DateTime? date, bool isStartupValue})>(value: (date: null, isStartupValue: false)))
[AuthenticationGuard-Provider] didDisposeProvider
[AuthenticationGuard-Provider] didUpdateProvider(AsyncLoading<AuthenticationGuardState>(value: AuthenticationGuardState(lockDate: 2024-07-17 19:15:56.902103, timerEnabled: true, isLocked: true)))
[AuthenticationGuard-Provider] didUpdateProvider(AsyncData<AuthenticationGuardState>(value: AuthenticationGuardState(lockDate: null, timerEnabled: true, isLocked: true)))
[_contactRepositoryProvider] didAddProvider(Instance of 'ContactRepository')
[_contactRepositoryProvider] didDisposeProvider
[AuthenticationGuard-Widget] Unschedule lock
[Vault] Deleting vault box MessengerDiscussion...
[Vault] ... vault box MessengerDiscussion deleted
[Vault] Deleting vault box _vaultBox...
[Vault] ... vault box _vaultBox deleted
[Vault] Deleting vault box cacheManagerHive...
[Vault] ... vault box cacheManagerHive deleted
[Vault] Clearing vault secure key
[Vault] Locking vault
[Vault lock task] Starting
[Vault lock task] Done
[GoRouter] going to /intro_welcome
[connectivityStatusProvider] didAddProvider(ConnectivityStatus.isConnected)
D/ProfileInstaller(13037): Installing profile for net.archethic.archethic_wallet
[GoRouter] pushing /network_dialog
[_verifiedTokensNotifierProvider] didDisposeProvider
[GoRouter] popping /intro_welcome
[GoRouter] going to /intro_import
[GoRouter] going to /intro_welcome
[GoRouter] going to /intro_welcome_get_first_infos
D/InputMethodManager(13037): showSoftInput() view=io.flutter.embedding.android.FlutterView{3ee33d1 VFE...... .F....ID 0,0-1080,2214 #2 aid=1073741824} flags=0 reason=SHOW_SOFT_INPUT
I/AssistStructure(13037): Flattened final assist data: 420 bytes, containing 1 windows, 3 views
D/InputConnectionAdaptor(13037): The input method toggled cursor monitoring on
W/OnBackInvokedCallback(13037): OnBackInvokedCallback is not enabled for the application.
W/OnBackInvokedCallback(13037): Set 'android:enableOnBackInvokedCallback="true"' in the application manifest.
D/InsetsController(13037): show(ime(), fromIme=true)
[GoRouter] pushing /network_dialog
D/InsetsController(13037): show(ime(), fromIme=true)
[GoRouter] popping /intro_welcome_get_first_infos
D/InputMethodManager(13037): showSoftInput() view=io.flutter.embedding.android.FlutterView{3ee33d1 VFE...... .F...... 0,0-1080,2214 #2 aid=1073741824} flags=0 reason=SHOW_SOFT_INPUT
D/InputConnectionAdaptor(13037): The input method toggled cursor monitoring on
W/OnBackInvokedCallback(13037): OnBackInvokedCallback is not enabled for the application.
W/OnBackInvokedCallback(13037): Set 'android:enableOnBackInvokedCallback="true"' in the application manifest.
D/InsetsController(13037): show(ime(), fromIme=true)
D/InputMethodManager(13037): showSoftInput() view=io.flutter.embedding.android.FlutterView{3ee33d1 VFE...... .F...... 0,0-1080,2214 #2 aid=1073741824} flags=0 reason=SHOW_SOFT_INPUT
D/InsetsController(13037): show(ime(), fromIme=true)
D/InputMethodManager(13037): showSoftInput() view=io.flutter.embedding.android.FlutterView{3ee33d1 VFE...... .F...... 0,0-1080,2214 #2 aid=1073741824} flags=0 reason=SHOW_SOFT_INPUT
D/InsetsController(13037): show(ime(), fromIme=true)
D/InputMethodManager(13037): showSoftInput() view=io.flutter.embedding.android.FlutterView{3ee33d1 VFE...... .F...... 0,0-1080,2214 #2 aid=1073741824} flags=0 reason=SHOW_SOFT_INPUT
D/InsetsController(13037): show(ime(), fromIme=true)
D/InputMethodManager(13037): showSoftInput() view=io.flutter.embedding.android.FlutterView{3ee33d1 VFE...... .F...... 0,0-1080,2214 #2 aid=1073741824} flags=0 reason=SHOW_SOFT_INPUT
D/InsetsController(13037): show(ime(), fromIme=true)
D/InsetsController(13037): show(ime(), fromIme=true)
[GoRouter] popping /intro_welcome_get_first_infos
[GoRouter] going to /intro_backup_safety
[GoRouter] going to /intro_backup
[GoRouter] going to /intro_backup_confirm
[GoRouter] popping /intro_backup_confirm
[_setRecoveryPhraseSavedProvider] didAddProvider(AsyncLoading<void>())
[GoRouter] pushing /intro_configure_security
[_setRecoveryPhraseSavedProvider] didDisposeProvider
[_isRecoveryPhraseSavedProvider] didAddProvider(AsyncLoading<bool>())
[_isRecoveryPhraseSavedProvider] didDisposeProvider
[Vault] Init vault secure key
[GoRouter] pushing /pin
I/flutter (13037): ══╡ EXCEPTION CAUGHT BY AUTHENTHIVESECUREDDATASOURCE ╞══════════════════════════════════════════════
I/flutter (13037): The following _$LockedApplicationImpl was thrown Failed to open Hive encrypted
I/flutter (13037): Box<dynamic>(NonWebAuthentication).:
I/flutter (13037): Failure.locked()
I/flutter (13037):
I/flutter (13037): When the exception was thrown, this was the stack:
I/flutter (13037): #0      AuthentHiveSecuredDatasource._prepareCipher (package:aewallet/infrastructure/datasources/authent_nonweb.secured_hive.dart:89:22)
I/flutter (13037): <asynchronous suspension>
I/flutter (13037): #1      AuthentHiveSecuredDatasource._openSecuredBox (package:aewallet/infrastructure/datasources/authent_nonweb.secured_hive.dart:76:27)
I/flutter (13037): <asynchronous suspension>
I/flutter (13037): #2      AuthentHiveSecuredDatasource.getInstance (package:aewallet/infrastructure/datasources/authent_nonweb.secured_hive.dart:29:26)
I/flutter (13037): <asynchronous suspension>
I/flutter (13037): #3      AuthenticationRepositoryNonWeb.encodeWithPin (package:aewallet/infrastructure/repositories/authentication.nonweb.dart:65:28)
I/flutter (13037): <asynchronous suspension>
I/flutter (13037): #4      UpdateMyPin.run (package:aewallet/domain/usecases/authentication/update_my_pin.dart:41:24)
I/flutter (13037): <asynchronous suspension>
I/flutter (13037): #5      _PinScreenState._encodePayload (package:aewallet/ui/views/authenticate/pin_screen.dart:240:29)
I/flutter (13037): <asynchronous suspension>
I/flutter (13037): #6      _PinScreenState._buildPinScreenButton.<anonymous closure>.<anonymous closure> (package:aewallet/ui/views/authenticate/pin_screen.dart:206:21)
I/flutter (13037): <asynchronous suspension>
I/flutter (13037): ════════════════════════════════════════════════════════════════════════════════════════════════════
E/flutter (13037): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Failure.locked()
E/flutter (13037): #0      AuthentHiveSecuredDatasource._prepareCipher (package:aewallet/infrastructure/datasources/authent_nonweb.secured_hive.dart:89:22)
E/flutter (13037): <asynchronous suspension>
E/flutter (13037): #1      AuthentHiveSecuredDatasource._openSecuredBox (package:aewallet/infrastructure/datasources/authent_nonweb.secured_hive.dart:76:27)
E/flutter (13037): <asynchronous suspension>
E/flutter (13037): #2      AuthentHiveSecuredDatasource.getInstance (package:aewallet/infrastructure/datasources/authent_nonweb.secured_hive.dart:29:26)
E/flutter (13037): <asynchronous suspension>
E/flutter (13037): #3      AuthenticationRepositoryNonWeb.encodeWithPin (package:aewallet/infrastructure/repositories/authentication.nonweb.dart:65:28)
E/flutter (13037): <asynchronous suspension>
E/flutter (13037): #4      UpdateMyPin.run (package:aewallet/domain/usecases/authentication/update_my_pin.dart:41:24)
E/flutter (13037): <asynchronous suspension>
E/flutter (13037): #5      _PinScreenState._encodePayload (package:aewallet/ui/views/authenticate/pin_screen.dart:240:29)
E/flutter (13037): <asynchronous suspension>
E/flutter (13037): #6      _PinScreenState._buildPinScreenButton.<anonymous closure>.<anonymous closure> (package:aewallet/ui/views/authenticate/pin_screen.dart:206:21)
E/flutter (13037): <asynchronous suspension>
E/flutter (13037):

@redDwarf03 redDwarf03 merged commit ebaf76f into dev Jul 22, 2024
2 checks passed
@redDwarf03 redDwarf03 deleted the Chralu/issue982 branch July 22, 2024 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Creating a wallet with biometrics does not unlock vault as intended
2 participants