Skip to content

Firebase Auth Emulator Fails Over Local Network #7342

Closed

Description

@mjgerace

[REQUIRED] Step 1: Describe your environment

  • Xcode version: 12.0
  • Firebase SDK version:
- Firebase/Auth (7.3.0):
    - Firebase/CoreOnly
    - FirebaseAuth (~> 7.3.0)
  - Firebase/CoreOnly (7.3.0):
    - FirebaseCore (= 7.3.0)
  - FirebaseAuth (7.3.0):
    - FirebaseCore (~> 7.0)
    - GoogleUtilities/AppDelegateSwizzler (~> 7.0)
    - GoogleUtilities/Environment (~> 7.0)
    - GTMSessionFetcher/Core (~> 1.4)
  • Installation method: yarn install + react native autolinking (through cocoapods)
  • Firebase Component: Auth

[REQUIRED] Step 2: Describe the problem

We are attempting to host our firebase auth emulator on our local network (192.168.1.1xx) so that our physical devices in debug mode (for react native) can connect to it. Normally, on a simulator, this isn't an issue, as we use localhost. We changed our 'host' properties in firebase.json and everything works well in that regard - we are able to hit 192.168.1.1xx:9099 from browsers on other devices, meaning that our auth emulator has bound correctly.

However! When trying to hit this URL, we encountered a bug deep down in this codebase.

When switching from http://localhost:9099 to http://192.168.1.1xx:9099, we started getting the generic failure messages. Please note that our API was perfectly reachable, just not the auth code!

When digging deep into things, we got this error:

Insecure fetch request has a scheme (http) not found in fetcher allowedInsecureSchemes ( @[] ): http://192.168.1.100:9099/www.googleapis.com/identitytoolkit/v3/relyingparty/signupNewUser?key=(OURKEYHERE)

It seems evident to me that this is a bug where you guys need to allow insecure schemes (http) for useEmulator, so that we can successfully reach our auth emulator on the local network.

If you need anything else, please ask. We are happy to provide more info.

Steps to reproduce:

What happened? How can we make the problem occur?
This could be a description, log/console output, etc.

To reproduce this problem:

  1. Bind auth emulator to your local network, and bind functions.
  2. Run both emulators.
  3. Observe that both the api and auth emulator are reachable from another device on the internal network (say, a phone).
  4. Observe that the api works great.
  5. Observe that the auth emulator refuses to hit a local IP on the network 192.168.1.1xx, resulting in failure for auth to be useful.

Relevant Code:

It seems likely that the bug lives in this file..

Our code was simply calling

firebase.auth().useEmulator('http://192.168.1.1xx:9099/');
await auth().createUserWithEmailAndPassword(email, password);

It is worth noting we are using rnfirebase to make the calls down to this source.

Activity

  1. ryanwilson commented on Jan 21, 2021

    @ryanwilson
    Member

    Thanks for the report! It looks like we do this properly in Functions already and we'll need to do something similar for Auth (and check the others that use the emulator):

    // Override normal security rules if this is a local test.
    if (_emulatorOrigin) {
    fetcher.allowLocalhostRequest = YES;
    fetcher.allowedInsecureSchemes = @[ @"http" ];
    }

  2. added this to the 7.6.0 - M89 milestone on Jan 22, 2021
  3. locked and limited conversation to collaborators on Feb 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions