firebase / flutterfire

πŸ”₯ A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.62k stars 3.95k forks source link

πŸ›[firebase_auth] userAccessGroup Keychain setting not working according to docs #6552

Closed OGmetamonkey closed 3 years ago

OGmetamonkey commented 3 years ago

Bug report

Describe the bug The description of the userAccessGroup keychain sharing feature (introduced in firebase_auth version 0.18.0) says: "Set the property to your team group ID or set to null to remove sharing capabilities." I have my extensions configured to share keychains and have tested keychain sharing successfully outside of flutter auth/firebase.

I used the Keychain Sharing - Keychain Groups attribute (as set in both targets in XCode config and included in both targets entitlements file) for the "team group ID" as shown below:

  String userAccessGroupShared = "com.project.project-flutter";
  await user.setSettings(
            appVerificationDisabledForTesting: true, userAccessGroup: userAccessGroupShared);
          await user.signInWithEmailLink(email: _email, emailLink: _link); //ERROR OCCURS HERE

As stated, this works to share keychain across the app targets outside of firebase_auth. When attempting to set the userAccessGroup setting to the userAccessGroupShared value with the above firebase_auth code, I get this error:

error: [firebase_auth/keychain-error] An error occurred when accessing the keychain. The @c NSLocalizedFailureReasonErrorKey field in the @c NSError.userInfo dictionary will contain more information about the error encountered

Steps to reproduce

Steps to reproduce the behavior:

  1. Create a flutter project (iOS) with working firebase_auth.
  2. Add an extension to the iOS project. (I specifically added a functional autofill credential provider target
  3. Add keychain sharing and share a value from the main target to the credential provider target.
  4. Try to use the keychain group in the userAccessGroup attribute for firebase_auth sharing.
  5. Observe the error.

Expected behavior

I expected that firebase_auth would utilize the specified keychain group to save the firebase_auth token and my firebase_auth would be accessible on the extension target.

Flutter doctor

Run flutter doctor and paste the output below:

user@MacBook-Pro project % flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[βœ“] Flutter (Channel stable, 1.22.6, on Mac OS X 10.15.7 19H1030 darwin-x64, locale en-US)
[βœ“] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[βœ“] Xcode - develop for iOS and macOS (Xcode 12.4)
[βœ“] Android Studio (version 4.1)
[βœ“] VS Code (version 1.57.1)

[βœ“] Connected device (1 available)            

β€’ No issues found!

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Dart SDK 2.10.5
Flutter SDK 1.22.6
Project 1.0.0+1

dependencies:
- autofill_service 0.0.1 [flutter logging]
- cached_network_image 2.5.1 [flutter flutter_cache_manager octo_image]
- cloud_firestore 0.14.4 [flutter meta quiver firebase_core firebase_core_platform_interface cloud_firestore_platform_interface cloud_firestore_web]
- crypto 2.1.5 [collection convert typed_data]
- csv 4.1.0
- cupertino_icons 0.1.3
- dynamic_theme 1.0.1 [flutter shared_preferences]
- encrypt 4.1.0 [args asn1lib clock collection crypto pointycastle]
- favicon 1.0.13 [http html image]
- file_picker 2.1.6 [flutter flutter_web_plugins flutter_plugin_android_lifecycle plugin_platform_interface]
- firebase_auth 0.18.4+1 [meta firebase_core firebase_core_platform_interface firebase_auth_platform_interface firebase_auth_web flutter]
- firebase_core 0.5.3 [firebase_core_platform_interface flutter quiver meta firebase_core_web]
- firebase_dynamic_links 0.4.0+6 [flutter]
- flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine]
- flutter_cache_manager 2.1.2 [flutter path_provider uuid http path sqflite pedantic clock file rxdart image]
- flutter_material_color_picker 1.0.5 [flutter]
- flutter_secure_storage 3.3.5 [meta flutter]
- flutter_spinkit 4.1.2+1 [flutter]
- flutter_unity_widget 4.0.0-alpha.4 [flutter flutter_plugin_android_lifecycle stream_transform plugin_platform_interface]
- fluttertoast 7.1.8 [flutter flutter_web_plugins]
- http 0.12.2 [http_parser path pedantic]
- logging 0.11.4
- logging_appenders 0.4.3 [meta logging dio intl clock io]
- modal_progress_hud 0.1.3 [flutter]
- password_strength 0.1.3
- path_provider 1.6.27 [flutter path_provider_platform_interface path_provider_macos path_provider_linux path_provider_windows]
- provider 3.2.0 [flutter]
- rename 1.2.0 [args logger]
- shared_preferences 0.5.12+4 [meta flutter shared_preferences_platform_interface shared_preferences_linux shared_preferences_macos shared_preferences_web shared_preferences_windows]
- simple_permissions 0.1.9 [flutter]
- sqflite 1.3.2+1 [flutter sqflite_common path]
- stripe_payment 1.0.11 [flutter]
- stripe_sdk 4.0.2 [flutter http url_launcher mask_text_input_formatter flutter_slidable simple_animations supercharged awesome_card uni_links credit_card_validator]
- url_launcher 5.7.10 [flutter url_launcher_platform_interface url_launcher_web url_launcher_linux url_launcher_macos url_launcher_windows]
- webview_flutter 1.0.7 [flutter]

dev dependencies:
- flutter_launcher_icons 0.7.5 [image args yaml]
- flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span stream_channel string_scanner term_glyph typed_data]

transitive dependencies:
- archive 2.0.13 [crypto args path]
- args 1.6.0
- asn1lib 0.8.1
- async 2.5.0-nullsafety.1 [collection]
- awesome_card 1.1.0 [flutter]
- boolean_selector 2.1.0-nullsafety.1 [source_span string_scanner]
- characters 1.1.0-nullsafety.3
- charcode 1.2.0-nullsafety.1
- clock 1.1.0-nullsafety.1
- cloud_firestore_platform_interface 2.2.1 [flutter meta collection firebase_core plugin_platform_interface]
- cloud_firestore_web 0.2.1+2 [flutter flutter_web_plugins http_parser meta firebase_core firebase_core_web cloud_firestore_platform_interface js]
- collection 1.15.0-nullsafety.3
- convert 2.1.1 [charcode typed_data]
- credit_card_type_detector 1.1.0
- credit_card_validator 1.2.0 [credit_card_type_detector]
- csslib 0.16.2 [source_span]
- dio 3.0.10 [http_parser path]
- fake_async 1.2.0-nullsafety.1 [clock collection]
- ffi 0.1.3
- file 5.2.1 [intl meta path]
- firebase_auth_platform_interface 2.1.4 [flutter meta firebase_core plugin_platform_interface]
- firebase_auth_web 0.3.2+3 [flutter flutter_web_plugins meta http_parser intl firebase_core firebase_core_web firebase_auth_platform_interface js]
- firebase_core_platform_interface 2.1.0 [flutter meta plugin_platform_interface quiver]
- firebase_core_web 0.2.1+1 [firebase_core_platform_interface flutter flutter_web_plugins meta js]
- flutter_blurhash 0.5.0 [flutter meta]
- flutter_plugin_android_lifecycle 1.0.11 [flutter]
- flutter_slidable 0.5.7 [flutter]
- flutter_web_plugins 0.0.0 [flutter characters collection meta typed_data vector_math]
- html 0.14.0+4 [csslib source_span]
- http_parser 3.1.4 [charcode collection source_span string_scanner typed_data]
- image 2.1.19 [archive xml meta]
- intl 0.16.1 [path]
- io 0.3.4 [charcode meta path string_scanner]
- js 0.6.2
- logger 0.9.4
- mask_text_input_formatter 1.2.1 [flutter]
- matcher 0.12.10-nullsafety.1 [stack_trace]
- meta 1.3.0-nullsafety.3
- octo_image 0.3.0 [flutter flutter_blurhash]
- path 1.8.0-nullsafety.1
- path_provider_linux 0.0.1+2 [path xdg_directories path_provider_platform_interface flutter]
- path_provider_macos 0.0.4+6 [flutter]
- path_provider_platform_interface 1.0.4 [flutter meta platform plugin_platform_interface]
- path_provider_windows 0.0.4+3 [path_provider_platform_interface meta path flutter ffi win32]
- pedantic 1.9.2 [meta]
- petitparser 3.1.0 [meta]
- platform 2.2.1
- plugin_platform_interface 1.0.3 [meta]
- pointycastle 2.0.0
- process 3.0.13 [file intl meta path platform]
- quiver 2.1.5 [matcher meta]
- rxdart 0.24.1
- sa_v1_migration 1.1.2 [flutter]
- shared_preferences_linux 0.0.2+4 [file flutter meta path path_provider_linux shared_preferences_platform_interface]
- shared_preferences_macos 0.0.1+11 [shared_preferences_platform_interface flutter]
- shared_preferences_platform_interface 1.0.4 [meta flutter]
- shared_preferences_web 0.1.2+7 [shared_preferences_platform_interface flutter flutter_web_plugins meta]
- shared_preferences_windows 0.0.1+3 [shared_preferences_platform_interface flutter ffi file meta path path_provider_platform_interface path_provider_windows]
- simple_animations 2.5.1 [flutter supercharged sa_v1_migration pedantic]
- sky_engine 0.0.99
- source_span 1.8.0-nullsafety.2 [charcode collection path term_glyph]
- sqflite_common 1.0.2+1 [synchronized path meta]
- stack_trace 1.10.0-nullsafety.1 [path]
- stream_channel 2.1.0-nullsafety.1 [async]
- stream_transform 1.2.0
- string_scanner 1.1.0-nullsafety.1 [charcode source_span]
- supercharged 1.12.0 [supercharged_dart flutter]
- supercharged_dart 1.4.0
- synchronized 2.2.0+2
- term_glyph 1.2.0-nullsafety.1
- test_api 0.2.19-nullsafety.2 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher]
- typed_data 1.3.0-nullsafety.3 [collection]
- uni_links 0.4.0 [flutter]
- url_launcher_linux 0.0.1+4 [flutter]
- url_launcher_macos 0.0.1+9 [flutter]
- url_launcher_platform_interface 1.0.9 [flutter meta plugin_platform_interface]
- url_launcher_web 0.1.5+3 [url_launcher_platform_interface flutter flutter_web_plugins meta]
- url_launcher_windows 0.0.1+3 [flutter]
- uuid 2.2.2 [crypto convert]
- vector_math 2.1.0-nullsafety.3
- win32 1.7.4 [ffi]
- xdg_directories 0.1.2 [meta path process]
- xml 4.5.1 [collection convert meta petitparser]
- yaml 2.2.1 [charcode collection string_scanner source_span]
OGmetamonkey commented 3 years ago

I also tried this using the "Team ID" from https://developer.apple.com/account/#/membership/ . Same result.

String userAccessGroupShared = "TEAMIDFROMLINK";
  await user.setSettings(
            appVerificationDisabledForTesting: true, userAccessGroup: userAccessGroupShared);

2021-07-06 16:32:17.795340-0400 Runner[843:79577] flutter: [firebase_auth/keychain-error] An error occurred when accessing the keychain. The @c NSLocalizedFailureReasonErrorKey field in the @c NSError.userInfo dictionary will contain more information about the error encountered 2021-07-06 16:32:17.796084-0400 Runner[843:79577] flutter: catch exception for valid link above 2021-07-06 16:32:17.796696-0400 Runner[843:79577] flutter: [firebase_auth/keychain-error] An error occurred when accessing the keychain. The @c NSLocalizedFailureReasonErrorKey field in the @c NSError.userInfo dictionary will contain more information about the error encountered 2021-07-06 16:32:17.797230-0400 Runner[843:79577] flutter: USER NULL: null

markusaksli-nc commented 3 years ago

Hi @OGmetamonkey Does this issue persist on the latest version of firebase_auth? The version you are using is pretty outdated and there have been multiple improvements since then (such as increasing the underlying Firebase iOS SDK constraint). Thank you

OGmetamonkey commented 3 years ago

As it turns out the documentation just sent me down the wrong path. All I had to do was add the Google Firebase plist from my main target to my extension target.

OGmetamonkey commented 3 years ago

I'll close this based on my previous comment.