Skip to content

feat(auth): Add support for Auth Emulator #1044

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

Merged
merged 15 commits into from
Oct 16, 2020
Merged

Conversation

samtstern
Copy link
Contributor

@samtstern samtstern commented Sep 28, 2020

Discussion

For Googlers: this design doc explains the behavior changes and security implications.

  • Basic URL replacement
  • Short-circuit custom auth token signing
  • Short-circuit verifyIdToken

Testing

  • New unit tests

API Changes

N/A

RELEASE NOTE: Added support for Firebase Auth Emulator.

@samtstern samtstern changed the title WIP: Add support for Auth Emulator Add support for Auth Emulator Sep 29, 2020
@yuchenshi
Copy link
Member

BTW awesome work, will take a detailed pass later once we settle the bigger picture questions

Copy link
Member

@yuchenshi yuchenshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (pending verifyIdToken change)

Copy link
Contributor

@hiranya911 hiranya911 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good. I've made some suggestions on cleaning up the implementation and improving the test coverage.

@@ -75,9 +75,15 @@ export class FirebaseTokenVerifier {
private publicKeysExpireAt: number;
private readonly shortNameArticle: string;

constructor(private clientCertUrl: string, private algorithm: string,
constructor(private clientCertUrl: string, private algorithm: jwt.Algorithm,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This really ought to accept an options object. But it's ok to do that later.

* @inheritDoc
*/
public getAccountId(): Promise<string> {
return Promise.resolve('[email protected]');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not so sure about this ... could we do something better here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably the best thing we can do

@samtstern samtstern marked this pull request as ready for review October 14, 2020 12:06
@samtstern
Copy link
Contributor Author

@yuchenshi and @hiranya911 thank you both for your comments, I got the code into a much cleaner state where useEmulator is no longer passed down beyond Auth.

Copy link
Contributor

@hiranya911 hiranya911 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. This looks pretty good. Just a bunch of nits and cleanup suggestions. Lets use single quotes around string literals everywhere.

@samtstern samtstern requested a review from hiranya911 October 14, 2020 18:35
Copy link
Contributor

@hiranya911 hiranya911 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. LGTM 👍

Copy link
Contributor

@hiranya911 hiranya911 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a suggestion.

@yuchenshi yuchenshi merged commit dbb0c78 into master Oct 16, 2020
@yuchenshi yuchenshi deleted the ss-auth-emulator-support branch October 16, 2020 20:59
@hiranya911 hiranya911 changed the title Add support for Auth Emulator fix(auth): Add support for Auth Emulator Oct 20, 2020
@hiranya911 hiranya911 changed the title fix(auth): Add support for Auth Emulator feat(auth): Add support for Auth Emulator Oct 20, 2020
@joelpoloney
Copy link

❤️❤️❤️❤️❤️❤️

@nickreynke
Copy link

Thank you for implementing the emulator! Good work!

BorntraegerMarc pushed a commit to BorntraegerMarc/firebase-admin-node that referenced this pull request Jan 28, 2021
* Basic URL replacement and custom tokens

* Fix test

* Tests actually pass

* Mock verifyIdToken

* Add another test

* Small style change

* Small simplification

* Significant cleanup of all the useEmulator stuff

* Make sure we don't use env var to short-circuit ID Token verification

* Make lint pass

* Add unit tests that go through the Auth interface

* Hiranya nits

* Make private method even more private and scary, require env

* Make the private method throw

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

Successfully merging this pull request may close these issues.

5 participants