Skip to content

firebase_auth sendSignInLinkToEmail() dynamicLinkDomain does not account for full URL prefix of connected hosting domains #8955

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

Closed
mdrideout opened this issue Jun 22, 2022 · 6 comments
Labels
plugin: auth resolution: fixed A fix has been merged or is pending merge from a PR. type: bug Something isn't working

Comments

@mdrideout
Copy link

Bug report

Describe the bug
The FirebaseAuth.instance.sendSignInLinkToEmail() function does not account for the full URL prefix set in the firebase console dynamic links settings for "connected domains" (or any domain serving Firebase hosting content) when generating the dynamic link.

The dynamicLinkDomain parameter does not allow for inclusion of the full prefix or account for it if set in Firebase console.

Tested on iOS.

Steps to reproduce

Steps to reproduce the behavior:

  1. Set up a custom domain dynamic link with a prefix in the firebase console, such as https://example.domain.com/link.
  2. Attempt to use sendSignInLinkToEmail() function with values such as:
                        await FirebaseAuth.instance.sendSignInLinkToEmail(
                          email: emailController.value.text,
                          actionCodeSettings: ActionCodeSettings(
                            url: authVerificationUrl,
                            handleCodeInApp: true, // this must be true
                            iOSBundleId: "example",
                            androidPackageName: "example",
                            androidInstallApp: true, // prompts user to install the app on android if not installed
                            androidMinimumVersion: '9',
                            dynamicLinkDomain: "example.domain.com",
                          ),
                        );

Using example.domain.com/link here throws an error.

  1. The link is successfully sent to the email address, formed as follows:
https://example.domain.com/?link=https://firebase-app-test-staging.firebaseapp.com/__/auth/action?apiKey%3DAIzaSyBmZjMO6mXay9BOgbBJb_amrjTtAsj-f3k%26mode%3DsignIn%26oobCode%3DwDq1kZptcnd8vX5SqDb9a3PFBVPEGnYdP4zChI8gDgoAAAGBjABG_g%26continueUrl%3Dhttps://example.domain.com/email-link-verify%26lang%3Den&apn=example.domain.app_name&amv=9&ibi=example.domain.app_name&ifl=https://firebase-app-test-staging.firebaseapp.com/__/auth/action?apiKey%3DAIzaSyBmZjMO6mXay9BOgbBJb_amrjTtAsj-f3k%26mode%3DsignIn%26oobCode%3DwDq1....GnYdP4zChI8gDgoAAAGBjABG_g%26continueUrl%3Dhttps://example.domain.com/email-link-verify%26lang%3Den

The link is missing the /link path segment, so it goes directly to the Flutter Web hosted application instead of using the rewrite rules for the path segment. Example hosting rewrite rules:

    "rewrites": [
      {
        "source": "/link/**",
        "dynamicLinks": true
      },
      {
        "source": "!/link/**",
        "destination": "/index.html"
      }
    ]

Expected behavior

The initial part of the link sent to the email address should incorporate the full URL prefix as declared in the firebase console. Either by looking that up in the Firebase console, or allowing it to be specified properly with the dynamicLinkDomain parameter.

Sample project

Example can be replicated with a skeleton flutter app setup with Firebase.


Current Solution

The current solution or workaround is to utilize a *.page.link Dynamic Links url prefix, because domains serving Firebase Web Hosting content do not seem to work.


Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.0.1, on macOS 12.4 21F79 darwin-x64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] VS Code (version 1.68.1)
[✓] Connected device (3 available)
[✓] HTTP Host Availability

• No issues found!


Flutter dependencies

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

Click To Expand
Dart SDK 2.17.1
Flutter SDK 3.0.1
mbb_flutter 1.0.0+1

dependencies:
- app_links 3.2.0 [flutter app_links_platform_interface app_links_web app_links_windows app_links_macos]
- email_validator 2.0.1
- firebase_auth 3.3.19 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta]
- firebase_core 1.17.1 [firebase_core_platform_interface firebase_core_web flutter meta]
- firebase_dynamic_links 4.2.5 [firebase_core firebase_core_platform_interface firebase_dynamic_links_platform_interface flutter meta plugin_platform_interface]
- flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine]
- flutter_localizations 0.0.0 [flutter intl characters clock collection material_color_utilities meta path vector_math]
- flutter_riverpod 2.0.0-dev.9 [collection flutter meta riverpod state_notifier]
- flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta vector_math]
- freezed_annotation 2.0.3 [collection json_annotation meta]
- go_router 3.1.1 [collection flutter flutter_web_plugins logging meta]
- logger 1.1.0
- shared_preferences 2.0.15 [flutter shared_preferences_android shared_preferences_ios shared_preferences_linux shared_preferences_macos shared_preferences_platform_interface shared_preferences_web shared_preferences_windows]

dev dependencies:
- build_runner 2.1.11 [args async analyzer build build_config build_daemon build_resolvers build_runner_core code_builder collection crypto dart_style frontend_server_client glob graphs http_multi_server io js logging meta mime package_config path pool pub_semver pubspec_parse shelf shelf_web_socket stack_trace stream_transform timing watcher web_socket_channel yaml]
- flutter_lints 2.0.1 [lints]
- flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher material_color_utilities meta source_span stream_channel string_scanner term_glyph]
- freezed 2.0.3+1 [analyzer build build_config collection meta source_gen freezed_annotation json_annotation]
- json_serializable 6.2.0 [analyzer async build build_config collection json_annotation meta path pub_semver pubspec_parse source_gen source_helper]

transitive dependencies:
- _fe_analyzer_shared 40.0.0 [meta]
- analyzer 4.1.0 [_fe_analyzer_shared collection convert crypto glob meta package_config path pub_semver source_span watcher yaml]
- app_links_macos 1.0.0 [flutter app_links_platform_interface]
- app_links_platform_interface 1.0.2 [flutter plugin_platform_interface]
- app_links_web 1.0.0 [flutter flutter_web_plugins app_links_platform_interface]
- app_links_windows 1.0.0 [flutter app_links_platform_interface]
- args 2.3.1
- async 2.8.2 [collection meta]
- boolean_selector 2.1.0 [source_span string_scanner]
- build 2.3.0 [analyzer async convert crypto glob logging meta path]
- build_config 1.0.0 [checked_yaml json_annotation path pubspec_parse yaml]
- build_daemon 3.1.0 [built_collection built_value http_multi_server logging path pool shelf shelf_web_socket stream_transform watcher web_socket_channel]
- build_resolvers 2.0.9 [analyzer async build crypto graphs logging path package_config pool pub_semver stream_transform yaml]
- build_runner_core 7.2.3 [async build build_config build_resolvers collection convert crypto glob graphs json_annotation logging meta path package_config pool timing watcher yaml]
- built_collection 5.1.1
- built_value 8.3.2 [built_collection collection fixnum meta]
- characters 1.2.0
- charcode 1.3.1
- checked_yaml 2.0.1 [json_annotation source_span yaml]
- clock 1.1.0
- code_builder 4.1.0 [built_collection built_value collection matcher meta]
- collection 1.16.0
- convert 3.0.2 [typed_data]
- crypto 3.0.2 [typed_data]
- dart_style 2.2.3 [analyzer args path pub_semver source_span]
- fake_async 1.3.0 [clock collection]
- ffi 2.0.0
- file 6.1.2 [meta path]
- firebase_auth_platform_interface 6.2.7 [firebase_core flutter meta plugin_platform_interface]
- firebase_auth_web 3.3.16 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser intl js meta]
- firebase_core_platform_interface 4.4.0 [collection flutter meta plugin_platform_interface]
- firebase_core_web 1.6.4 [firebase_core_platform_interface flutter flutter_web_plugins js meta]
- firebase_dynamic_links_platform_interface 0.2.3+3 [firebase_core flutter meta plugin_platform_interface]
- fixnum 1.0.1
- frontend_server_client 2.1.3 [async path]
- glob 2.0.2 [async collection file path string_scanner]
- graphs 2.1.0 [collection]
- http_multi_server 3.2.0 [async]
- http_parser 4.0.1 [collection source_span string_scanner typed_data]
- intl 0.17.0 [clock path]
- io 1.0.3 [meta path string_scanner]
- js 0.6.4
- json_annotation 4.5.0 [meta]
- lints 2.0.0
- logging 1.0.2
- matcher 0.12.11 [stack_trace]
- material_color_utilities 0.1.4
- meta 1.7.0
- mime 1.0.2
- package_config 2.0.2 [path]
- path 1.8.1
- path_provider_linux 2.1.7 [ffi flutter path path_provider_platform_interface xdg_directories]
- path_provider_platform_interface 2.0.4 [flutter platform plugin_platform_interface]
- path_provider_windows 2.1.0 [ffi flutter path path_provider_platform_interface win32]
- platform 3.1.0
- plugin_platform_interface 2.1.2 [meta]
- pool 1.5.0 [async stack_trace]
- process 4.2.4 [file path platform]
- pub_semver 2.1.1 [collection meta]
- pubspec_parse 1.2.0 [checked_yaml collection json_annotation pub_semver yaml]
- riverpod 2.0.0-dev.9 [collection meta stack_trace state_notifier]
- shared_preferences_android 2.0.12 [flutter shared_preferences_platform_interface]
- shared_preferences_ios 2.1.1 [flutter shared_preferences_platform_interface]
- shared_preferences_linux 2.1.1 [file flutter path path_provider_linux path_provider_platform_interface shared_preferences_platform_interface]
- shared_preferences_macos 2.0.4 [flutter shared_preferences_platform_interface]
- shared_preferences_platform_interface 2.0.0 [flutter]
- shared_preferences_web 2.0.4 [flutter flutter_web_plugins shared_preferences_platform_interface]
- shared_preferences_windows 2.1.1 [file flutter path path_provider_platform_interface path_provider_windows shared_preferences_platform_interface]
- shelf 1.3.0 [async collection http_parser path stack_trace stream_channel]
- shelf_web_socket 1.0.1 [shelf stream_channel web_socket_channel]
- sky_engine 0.0.99
- source_gen 1.2.2 [analyzer async build dart_style glob meta path source_span yaml]
- source_helper 1.3.2 [analyzer collection source_gen]
- source_span 1.8.2 [collection path term_glyph]
- stack_trace 1.10.0 [path]
- state_notifier 0.7.2+1 [meta]
- stream_channel 2.1.0 [async]
- stream_transform 2.0.0
- string_scanner 1.1.0 [charcode source_span]
- term_glyph 1.2.0
- test_api 0.4.9 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher]
- timing 1.0.0 [json_annotation]
- typed_data 1.3.1 [collection]
- vector_math 2.1.2
- watcher 1.0.1 [async path]
- web_socket_channel 2.2.0 [async crypto stream_channel]
- win32 2.7.0 [ffi]
- xdg_directories 0.2.0+1 [meta path process]
- yaml 3.1.1 [collection source_span string_scanner]

@mdrideout mdrideout added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Jun 22, 2022
@darshankawar darshankawar added the triage Issue is currently being triaged. label Jun 27, 2022
@darshankawar
Copy link

Thanks for the report. Using the details provided above, I see the same behavior.

/cc @russellwheatley

@darshankawar darshankawar added plugin: auth and removed Needs Attention This issue needs maintainer attention. triage Issue is currently being triaged. labels Jun 27, 2022
@JankoLancer
Copy link

I have the same issue, is there any news about this?

@Peng-Qian
Copy link

same here, any updates

@Willham12
Copy link

bump

@darshankawar
Copy link

Please upvote original issue description with thumbs up emoji. Based on number of upvotes, team can look into and prioritize as applicable.

@Lyokone
Copy link
Contributor

Lyokone commented Nov 24, 2023

Will be fixed by #11925

@Lyokone Lyokone closed this as completed Nov 24, 2023
@darshankawar darshankawar added the resolution: fixed A fix has been merged or is pending merge from a PR. label Nov 27, 2023
@firebase firebase locked and limited conversation to collaborators Dec 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
plugin: auth resolution: fixed A fix has been merged or is pending merge from a PR. type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants