-
Notifications
You must be signed in to change notification settings - Fork 950
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
Authorize using Firebase CLI credentials #2214
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approval for TypeScript readability. Please add more folks for the context of the change if possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementation LGTM, although I'm not familiar with how these different components are wired together in the emulator suite.
|
||
// We could use fs.writeFileSync() here but it's important that the caller understands | ||
// that this is a somewhat expensive operation so we make it a Promise. | ||
return new Promise((res, rej) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this overwrite whatever is currently in that path? Is that the behavior we want?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that's the behavior we want. I'm willing to pay this small extra cost to avoid the whole class of bugs that come with potentially out of date credentials.
Co-authored-by: Yuchen Shi <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple tactical comments, also here's some broad thinking:
This is a broadly useful thing in terms of making it possible for your local environment to be application default credentialed for the things you want to access. It's also a little dangerous in that regard, and I know gcloud
is moving away from using user-based credentials for anything. If I have a major reservation about doing it at all, it's that -- the credentials associated with the Firebase CLI are broad.
Separately though, the fact that you can do this at all might unblock firebase shell
and could be really useful for developers who want to write firebase-admin
scripts. Having a command like firebase account:credentials
that populates this file for non-emulator use might be worth considering.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have my 👍 , pending your TODOs - let me know if you want me to come back and look at this again.
Description
Fixes #1940
TODO:
This change will allow the Firebase emulators to pass the credentials from
firebase login
as Cloud application default credentials.Currently the emulators rely on picking up gcloud auth application-default login credentials on the machine which is at best annoying and at worst means that the emulators are authorized as the wrong user.
Here's the new behavior matrix:
GAC
EnvGAC
env to emulator with user credentialGAC
credentialGAC
env, ADC is ignoredGAC
credentialGAC
credential, ADC is ignoredGAC
credential, all othersNote: we can/should change the behavior of Scenario 3 when this bug is fixed:
firebase/firebase-js-sdk#3144
Scenarios Tested
Functions used for all tests:
Scenario 1
See logs
Emulator logs
Scenario 2
See logs
Scenario 3
See logs
Scenario 4
See logs
Scenario 5
See logs
Scenario 6
See logs
Scenario 7
See logs
Scenario 8
See logs
Sample Commands
N/A