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.73k stars 3.98k forks source link

πŸ› [firebase_auth] Incorrect redirect url when using Microsoft as AuthProvider #10867

Open KlausJokisuo opened 1 year ago

KlausJokisuo commented 1 year ago

Bug report

Describe the bug

Current environment

We're using Firebase Auth and Azure AD. We have configured the Firebase Auth by enabling Microsoft as a Sign-in provider by giving Application ID and Application secret from Azure. Within Azure, we have redirect URL https://[our-firebase-project-id].firebaseapp.com/__/auth/handler.

In addition to mobile clients, we have a web client using React. When doing web development, we use Github Actions to push a preview on every PR. The preview URL looks like this https://[our-firebase-project-id]--${{ github.sha }}.web.app The preview URL is automatically also added into Firebase Authorized Domains

Actual bug

We get an error from Microsoft about a mismatch in the redirect URL. The redirect URL is always within this format [our-firebase-project-id]--05e13eaefdf5c6bce3984e0afd93d-ubjumkgc.web.app The 05e13eaefdf5c6bce3984e0afd93d changes randomly.

So the question is, why Firebase Auth choose to use that preview URL as a redirect URL on mobile?

Steps to reproduce

Steps to reproduce the behavior:

  1. Setup Firebase Auth and enable Microsoft as a Sign-in provider
  2. Login
  3. Redirect mismatch error on redirect-url

    Expected behavior

The user successfully logs in using Microsoft as a Sign-in provider


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.7.12, on macOS 13.3.1 22E261 darwin-arm64, locale en-FI) [βœ“] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc1) [βœ“] Xcode - develop for iOS and macOS (Xcode 14.3) [βœ“] Chrome - develop for the web [βœ“] Android Studio (version 2020.3) [βœ“] Android Studio (version 2022.2) [βœ“] Android Studio (version 2022.1) [βœ“] IntelliJ IDEA Ultimate Edition (version 2023.1) [βœ“] IntelliJ IDEA Ultimate Edition (version 2023.1) [βœ“] VS Code (version 1.77.3) [βœ“] Connected device (4 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.19.6 Flutter SDK 3.7.12 dependencies: - auto_route 6.3.0 [flutter path collection meta] - bugsnag_flutter 2.4.0 [flutter] - collection 1.17.0 - cupertino_icons 1.0.5 - dio 5.1.1 [http_parser meta path] - email_validator 2.1.17 - firebase_auth 4.4.2 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta] - firebase_core 2.10.0 [firebase_core_platform_interface firebase_core_web flutter meta] - flutter 0.0.0 [characters collection js material_color_utilities meta vector_math sky_engine] - flutter_bloc 8.1.2 [flutter bloc provider] - flutter_displaymode 0.6.0 [flutter] - flutter_dotenv 5.0.2 [flutter] - flutter_hooks 0.18.6 [flutter] - flutter_localizations 0.0.0 [flutter intl characters clock collection js material_color_utilities meta path vector_math] - flutter_svg 2.0.5 [flutter vector_graphics vector_graphics_codec vector_graphics_compiler] - fpdart 0.5.0 - freezed_annotation 2.2.0 [collection json_annotation meta] - get_it 7.3.0 [async collection] - gql_dio_link 0.3.0 [dio gql gql_exec gql_link meta] - graphql 5.1.3 [meta path gql gql_exec gql_link gql_http_link gql_transform_link gql_error_link gql_dedupe_link hive normalize http collection web_socket_channel stream_channel rxdart uuid] - injectable 2.1.1 [get_it] - intl 0.17.0 [clock path] - json_annotation 4.8.0 [meta] - logger 1.3.0 - mockito 5.4.0 [analyzer build code_builder collection dart_style matcher meta path source_gen test_api] - package_info_plus 3.1.1 [ffi flutter flutter_web_plugins http meta path package_info_plus_platform_interface win32] - path_provider 2.0.14 [flutter path_provider_android path_provider_foundation path_provider_linux path_provider_platform_interface path_provider_windows] - rxdart 0.27.7 - shared_preferences 2.1.0 [flutter shared_preferences_android shared_preferences_foundation shared_preferences_linux shared_preferences_platform_interface shared_preferences_web shared_preferences_windows] - url_launcher 6.1.10 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows] - uuid 3.0.7 [crypto] dev dependencies: - auto_route_generator 6.2.0 [build source_gen analyzer path build_runner code_builder dart_style xml args glob auto_route] - bloc_test 9.1.1 [bloc diff_match_patch meta mocktail test] - build_runner 2.3.3 [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] - dart_code_metrics 5.7.2 [analyzer analyzer_plugin ansicolor args collection crypto dart_code_metrics_presets file glob html http meta path platform pub_updater source_span uuid xml 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 collection js matcher material_color_utilities meta source_span stream_channel string_scanner term_glyph] - freezed 2.3.2 [analyzer build build_config collection meta source_gen freezed_annotation json_annotation] - google_sign_in 6.1.0 [flutter google_sign_in_android google_sign_in_ios google_sign_in_platform_interface google_sign_in_web] - graphql_codegen 0.12.0 [gql build glob code_builder dart_style built_collection path gql_code_builder recase json_annotation] - injectable_generator 2.1.5 [build source_gen path glob analyzer code_builder dart_style injectable collection recase] - json_serializable 6.6.1 [analyzer async build build_config collection json_annotation meta path pub_semver pubspec_parse source_gen source_helper] transitive dependencies: - _fe_analyzer_shared 58.0.0 [meta] - _flutterfire_internals 1.1.1 [collection firebase_core firebase_core_platform_interface flutter meta] - analyzer 5.10.0 [_fe_analyzer_shared collection convert crypto glob meta package_config path pub_semver source_span watcher yaml] - analyzer_plugin 0.11.2 [analyzer collection dart_style pub_semver yaml] - ansicolor 2.0.1 - args 2.4.0 - async 2.10.0 [collection meta] - bloc 8.1.1 [meta] - boolean_selector 2.1.1 [source_span string_scanner] - build 2.3.1 [analyzer async convert crypto glob logging meta path] - build_config 1.1.1 [checked_yaml json_annotation path pubspec_parse yaml] - build_daemon 3.1.1 [built_collection built_value http_multi_server logging path pool shelf shelf_web_socket stream_transform watcher web_socket_channel] - build_resolvers 2.2.0 [analyzer async build collection crypto graphs logging path package_config pool pub_semver stream_transform yaml] - build_runner_core 7.2.7 [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.4.4 [built_collection collection fixnum meta] - characters 1.2.1 - checked_yaml 2.0.2 [json_annotation source_span yaml] - clock 1.1.1 - code_builder 4.4.0 [built_collection built_value collection matcher meta] - convert 3.1.1 [typed_data] - coverage 1.6.3 [args logging package_config path source_maps stack_trace vm_service] - crypto 3.0.2 [typed_data] - csslib 0.17.2 [source_span] - dart_code_metrics_presets 1.6.0 - dart_style 2.3.0 [analyzer args path pub_semver source_span] - diff_match_patch 0.4.1 - fake_async 1.3.1 [clock collection] - ffi 2.0.1 - file 6.1.4 [meta path] - firebase_auth_platform_interface 6.13.1 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - firebase_auth_web 5.3.2 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser intl js meta] - firebase_core_platform_interface 4.6.0 [collection flutter flutter_test meta plugin_platform_interface] - firebase_core_web 2.3.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - fixnum 1.1.0 - flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta vector_math] - frontend_server_client 3.2.0 [async path] - glob 2.1.1 [async collection file path string_scanner] - google_identity_services_web 0.2.1 [js meta] - google_sign_in_android 6.1.13 [flutter google_sign_in_platform_interface] - google_sign_in_ios 5.6.1 [flutter google_sign_in_platform_interface] - google_sign_in_platform_interface 2.4.0 [flutter plugin_platform_interface quiver] - google_sign_in_web 0.12.0 [flutter flutter_web_plugins google_identity_services_web google_sign_in_platform_interface http js] - gql 0.14.0 [collection meta source_span] - gql_code_builder 0.7.1 [analyzer built_collection built_value code_builder collection gql gql_exec path] - gql_dedupe_link 2.0.3+1 [async gql_exec gql_link meta] - gql_error_link 0.2.3+1 [async gql_exec gql_link meta] - gql_exec 0.4.3 [collection gql meta] - gql_http_link 0.4.5 [gql gql_exec gql_link http http_parser meta] - gql_link 0.5.1 [gql gql_exec meta] - gql_transform_link 0.2.2+1 [gql_exec gql_link] - graphs 2.2.0 [collection] - hive 2.2.3 [meta crypto] - html 0.15.2 [csslib source_span] - http 0.13.5 [async http_parser meta path] - http_multi_server 3.2.1 [async] - http_parser 4.0.2 [collection source_span string_scanner typed_data] - io 1.0.4 [meta path string_scanner] - js 0.6.5 [meta] - lints 2.0.1 - logging 1.1.1 - matcher 0.12.13 [meta stack_trace] - material_color_utilities 0.2.0 - meta 1.8.0 - mime 1.0.4 - mocktail 0.3.0 [collection matcher test] - nested 1.0.0 [flutter] - node_preamble 2.0.2 - normalize 0.7.2 [gql collection] - package_config 2.1.0 [path] - package_info_plus_platform_interface 2.0.1 [flutter meta plugin_platform_interface] - path 1.8.2 - path_parsing 1.0.1 [vector_math meta] - path_provider_android 2.0.25 [flutter path_provider_platform_interface] - path_provider_foundation 2.2.2 [flutter path_provider_platform_interface] - path_provider_linux 2.1.10 [ffi flutter path path_provider_platform_interface xdg_directories] - path_provider_platform_interface 2.0.6 [flutter platform plugin_platform_interface] - path_provider_windows 2.1.6 [ffi flutter path path_provider_platform_interface win32] - petitparser 5.1.0 [meta] - platform 3.1.0 - plugin_platform_interface 2.1.4 [meta] - pool 1.5.1 [async stack_trace] - process 4.2.4 [file path platform] - provider 6.0.5 [collection flutter nested] - pub_semver 2.1.3 [collection meta] - pub_updater 0.2.4 [http json_annotation process] - pubspec_parse 1.2.2 [checked_yaml collection json_annotation pub_semver yaml] - quiver 3.2.1 [matcher] - recase 4.1.0 - shared_preferences_android 2.1.2 [flutter shared_preferences_platform_interface] - shared_preferences_foundation 2.2.1 [flutter shared_preferences_platform_interface] - shared_preferences_linux 2.2.0 [file flutter path path_provider_linux path_provider_platform_interface shared_preferences_platform_interface] - shared_preferences_platform_interface 2.2.0 [flutter plugin_platform_interface] - shared_preferences_web 2.1.0 [flutter flutter_web_plugins shared_preferences_platform_interface] - shared_preferences_windows 2.2.0 [file flutter path path_provider_platform_interface path_provider_windows shared_preferences_platform_interface] - shelf 1.4.0 [async collection http_parser path stack_trace stream_channel] - shelf_packages_handler 3.0.1 [path shelf shelf_static] - shelf_static 1.1.1 [convert http_parser mime path shelf] - shelf_web_socket 1.0.3 [shelf stream_channel web_socket_channel] - sky_engine 0.0.99 - source_gen 1.2.7 [analyzer async build dart_style glob path source_span yaml] - source_helper 1.3.3 [analyzer collection source_gen] - source_map_stack_trace 2.1.1 [path source_maps stack_trace] - source_maps 0.10.12 [source_span] - source_span 1.9.1 [collection path term_glyph] - stack_trace 1.11.0 [path] - stream_channel 2.1.1 [async] - stream_transform 2.1.0 - string_scanner 1.2.0 [source_span] - term_glyph 1.2.1 - test 1.22.0 [analyzer async boolean_selector collection coverage http_multi_server io js node_preamble package_config path pool shelf shelf_packages_handler shelf_static shelf_web_socket source_span stack_trace stream_channel typed_data web_socket_channel webkit_inspection_protocol yaml test_api test_core] - test_api 0.4.16 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher] - test_core 0.4.20 [analyzer async args boolean_selector collection coverage frontend_server_client glob io meta package_config path pool source_map_stack_trace source_maps source_span stack_trace stream_channel vm_service yaml matcher test_api] - timing 1.0.1 [json_annotation] - typed_data 1.3.1 [collection] - url_launcher_android 6.0.27 [flutter url_launcher_platform_interface] - url_launcher_ios 6.1.4 [flutter url_launcher_platform_interface] - url_launcher_linux 3.0.4 [flutter url_launcher_platform_interface] - url_launcher_macos 3.0.5 [flutter url_launcher_platform_interface] - url_launcher_platform_interface 2.1.2 [flutter plugin_platform_interface] - url_launcher_web 2.0.16 [flutter flutter_web_plugins url_launcher_platform_interface] - url_launcher_windows 3.0.5 [flutter url_launcher_platform_interface] - vector_graphics 1.1.5 [flutter vector_graphics_codec] - vector_graphics_codec 1.1.5 - vector_graphics_compiler 1.1.5 [args meta path_parsing xml vector_graphics_codec] - vector_math 2.1.4 - vm_service 9.4.0 - watcher 1.0.2 [async path] - web_socket_channel 2.2.0 [async crypto stream_channel] - webkit_inspection_protocol 1.2.0 [logging] - win32 4.1.3 [ffi] - xdg_directories 1.0.0 [meta path process] - xml 6.2.2 [collection meta petitparser] - yaml 3.1.1 [collection source_span string_scanner] ```

darshankawar commented 1 year ago

Thanks for the report.

We get an error from Microsoft about a mismatch in the redirect URL. The redirect URL is always within this format [our-firebase-project-id]--05e13eaefdf5c6bce3984e0afd93d-ubjumkgc.web.app The 05e13eaefdf5c6bce3984e0afd93d changes randomly.

So the question is, why Firebase Auth choose to use that preview URL as a redirect URL on mobile?

I'll keep this issue open for team's input on the actual error and question raised.

/cc @Lyokone