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

Firebase Auth Emulator Fails Over Local Network #7342

Closed
mjgerace opened this issue Jan 21, 2021 · 1 comment · Fixed by #7350
Closed

Firebase Auth Emulator Fails Over Local Network #7342

mjgerace opened this issue Jan 21, 2021 · 1 comment · Fixed by #7350
Assignees
Milestone

Comments

@mjgerace
Copy link

mjgerace commented Jan 21, 2021

[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.

@ryanwilson
Copy link
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" ];
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants