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

Add support for Auth emulator via useEmulator #778

Closed
c5n8 opened this issue Nov 3, 2020 · 29 comments
Closed

Add support for Auth emulator via useEmulator #778

c5n8 opened this issue Nov 3, 2020 · 29 comments

Comments

@c5n8
Copy link

c5n8 commented Nov 3, 2020

Is your feature request related to a problem? Please describe.
UI still connect to project server when using auth emulator.

Describe the solution you'd like
A way to connect UI to auth emulator.

Describe alternatives you've considered
I have modified default auth instance to use emulator, but still failed to make UI use emulator.

Additional context
Related Documentation

@akauppi
Copy link

akauppi commented Nov 3, 2020

This should have been obvious. Could Firebase teams please have a post-mortem about why such information leaks through, and releases are not in sync?

Then again, none of the Changelogs likely state that we should expect firebaseui to be compatible with the auth emulation, do they?

@sam-gc
Copy link
Contributor

sam-gc commented Nov 3, 2020

Hi @c5n8 thanks for raising this! We are aware of the issue and we are investigating (b/165671830).

@sam-gc
Copy link
Contributor

sam-gc commented Nov 3, 2020

@akauppi -- We released the Auth Emulator BETA just last week. We're really excited about the emulator and we wanted to get it into the hands of customers as quickly as we could, knowing how valuable it can be to a safe development workflow!🙂 We're currently working on ensuring that the Auth emulator works with FirebaseUI; it has a slightly different release schedule, and releases aren't always aligned with other Firebase SDKs.

@bojeil-google
Copy link
Contributor

bojeil-google commented Nov 4, 2020

FirebaseUI cannot currently readily support the Auth emulator as it creates an internal Auth instance which does not propagate the emulator settings. Additional work is needed to support this. Filed it as a feature request.

@akauppi
Copy link

akauppi commented Nov 6, 2020

@samhorlbeck just a slight nod. I meant no harm. Somehow the mention that Auth Emulator was only beta has escaped me.

@sam-gc
Copy link
Contributor

sam-gc commented Nov 9, 2020

@akauppi no worries, that's how I spell "BETA," not meant as emphasis :)

@jmcdl
Copy link

jmcdl commented Nov 9, 2020

It's not explicit in the original comment, but am I correct in thinking that @c5n8 is referring to the fact that the useEmulator() method suggested in the linked docs (copied below) appears to be undefined?

firebase.auth().useEmulator('http://localhost:9099/');

At least when I try to use it in my React app I get a 'useEmulator is not a function' error from webpack and my IDE (WebStorm).

I would note that the same method is suggested for the firestore emulator and is also wrong.

The code given in the docs is:

// Initialize your Web app as described in the Get started for Web
// Firebase previously initialized using firebase.initializeApp().
var db = firebase.firestore();
if (location.hostname === "localhost") {
  db.useEmulator("localhost", 8080);
}

What actually works is:

var db = firebase.firestore();
if (location.hostname === "localhost") {
  db.settings({
  host: "localhost:5002",
  ssl: false,
});
}

@sam-gc
Copy link
Contributor

sam-gc commented Nov 10, 2020

@jmcdl this is a different issue: Firebase UI for Auth does not currently honor the call to firebase.auth().useEmulator() though the function is defined properly on firebase.auth(). It sounds like you may be using an older version of the SDK that does not have the useEmulator() function (it was added quite recently, as in the last month or two, at least for Auth).

If you're still having the issue, please file a bug in the firebase-js-sdk repo.

@jmcdl
Copy link

jmcdl commented Nov 10, 2020

@samhorlbeck thank you, you were correct that I wasn't using the latest version of the firebase sdk. Updating the SDK has resolved the error.

@horizon89
Copy link

horizon89 commented Nov 24, 2020

Great to read that I'm not the only one in need of this. Any idea when this might be resolved? Thank you so much for the work that you do. Greatly appreciated.

@bojeil-google
Copy link
Contributor

Hey folks, in order to support the emulator in firebaseui, the emulator settings need to be copied from the external auth instance into the temporary internal one.

This can be done after initialization of the internal instance.

However, the missing piece is that we need to get the emulator settings from the provided Auth instance and I don't believe that a getter for this is exposed yet.

@cupcakearmy
Copy link

Docs should be more clear. I immagined it would simply work as in the docs. There should be a warning about this here: https://firebase.google.com/docs/emulator-suite/connect_auth

Hope the feature is here soon :)

@benomatis
Copy link

@cupcakearmy I might be missing something, but I believe what was meant above is that useEmulator is not currently working specifically in firebaseui (mind the ui at the end of the word), which is why this issue is logged here. The linked doc is generally about firebase emulator for auth; I have not tested, but I'm assuming that if you set up auth yourself (NOT using firebaseui), you'll probably be able to get it working.

@cupcakearmy
Copy link

cupcakearmy commented Dec 1, 2020

@benomatis yes. Without the UI the Auth emulation works. It's just not mentioned anywhere. So a little temporal warning would be very helpful :) But the UI is the most common way, especially at the beginning to use auth in firebase.

@benomatis
Copy link

@cupcakearmy If anywhere, it should probably be mentioned in firebaseui's docs, not the main firebase docs; it's basically a separate product.

@cupcakearmy
Copy link

Sure. Just somewhere where it's obvious :)

@codercatdev
Copy link

Whew thought I was losing my mind!!

@QaDeS
Copy link

QaDeS commented Dec 14, 2020

FirebaseUI cannot currently readily support the Auth emulator as it creates an internal Auth instance which does not propagate the emulator settings.

Needed this to work now, so I removed the creation of the internal Auth instance just to see what breaks. Nothing did – for all I can say – so I was wondering what this mechanism is/was actually meant for?

Pull request: #794

@brianrodri
Copy link

brianrodri commented Dec 28, 2020

Edit: removed my original comment since it's the same thing mentioned in #778 (comment)


Following up on #778 (comment), is the next step to file an issue on firebase-js-sdk requesting getEmulatorConfig to be public?

@bojeil-google
Copy link
Contributor

Yes getEmulatorConfig needs to be exposed so it can be call in firebaseui.

@cupcakearmy
Copy link

@bojeil-google do you know if there is an estimated ETA on this?

@bojeil-google
Copy link
Contributor

@samhorlbeck is currently working on it.

@chetbox
Copy link

chetbox commented Jan 29, 2021

I believe it should now be possible to get the emulator settings with the latest Firebase SDK: https://firebase.google.com/support/release-notes/js#version_824_-_january_21_2021

@benomatis
Copy link

Looks like it's been added here as well, but not yet released: bb65d49

@interactive-web-dev
Copy link

Any approximate ETA on the release date? I'm unfamiliar with how frequently they occur.

@bojeil-google
Copy link
Contributor

We are working on it. We discovered another unrelated issue in the process of the release and we may have to delay the release until the bug is fixed. You can expect this to be out sometime this week or next week.

@bojeil-google
Copy link
Contributor

Emulator support should now be available in the latest FirebaseUI-web release.

@antoinedc
Copy link

I'm still having issues with this. It looks like some requests are sent to the emulator and some are not.
For example, https://www.googleapis.com/identitytoolkit/v3/relyingparty/createAuthUri?key=xxx is not proxied through the emulator, same with the signin/signup process requests.

Here is my code:

firebase.initializeApp(FIREBASE_CONFIG, 'debug');
var auth = firebase.auth()
auth.useEmulator("http://localhost:9099")
var ui = new firebaseui.auth.AuthUI(auth);
ui.start('#firebaseui-auth-container', {
    signInSuccessUrl: '/transactions',
    signInOptions: [
        {
            provider: firebase.auth.EmailAuthProvider.PROVIDER_ID,
            requireDisplayName: false
        }
    ]
});

FIREBASE_CONFIG contains a dummy apiKey and projectId.

However, if I proceed to login with a live api key and a production account, and then check for currentUser(), it seems to go through the emulator: http://localhost:9099/www.googleapis.com/identitytoolkit/v3/relyingparty/getAccountInfo?key=xxx, and it (obviously) fails with a 400 USER_NOT_FOUND.

@antoinedc
Copy link

Problem solved, in case it's useful for someone: updating firebaseui is not enough, you also need to be on firebase 8.2.4 at least to have the emulatorConfig exposed (I was on firebase 8.2.1)

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

Successfully merging a pull request may close this issue.