Skip to content

Conversation

samtstern
Copy link
Contributor

@samtstern samtstern commented Oct 21, 2020

Description

Follow up to:
firebase/firebase-admin-node#1044

Scenarios Tested

  • New basic unit test

Logs

When running on current production firebase-admin:

[2020-10-21T16:48:16.955Z] [runtime-status] [91254] auth.setJwtVerificationEnabled not available {"metadata":{"emulator":{"name":"functions"},"message":"[runtime-status] [91254] auth.setJwtVerificationEnabled not available"}}

When running on firebase-admin@HEAD:

[2020-10-21T16:56:47.271Z] [runtime-status] [92888] auth.setJwtVerificationEnabled(false) {"metadata":{"emulator":{"name":"functions"},"message":"[runtime-status] [92888] auth.setJwtVerificationEnabled(false)"}}

E2E

I wrote this function:

const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();

exports.helloWorld = functions.https.onRequest(async (request, response) => {
  console.log('env', process.env.FIREBASE_AUTH_EMULATOR_HOST);

  const user = await admin.auth().getUserByEmail("[email protected]");
  console.log("user", user);

  response.json({ status: "ok" });
});

And when I run it after making a user in the UI I see these logs:

i  functions: Beginning execution of "helloWorld"
>  env localhost:9099
⚠  Received service account token ya29.A0AfH6SMB4L6I-vs0VCes7TztZ43Pg_IzhiMeiN9ZRuQl6Ts9Adr-g4Pj0pp59tCb6tA7hLqsDew4HuRYEHCv0aHeX4kOO0bfn-HYl5sNQX-z2i9TFffhDaSbYstAtWET75jQi7psocainEOYGktAMXhWQHnmbVrXtabgc8jRiWOE6RyyfSWhS. Assuming that it owns project "fir-dumpster".
>  user UserRecord {
>    uid: 'Jrs4in4o3xOl63JmvflrGNLgYgSg',
>    email: '[email protected]',
>    emailVerified: false,
>    displayName: 'Sam Example',
>    photoURL: '',
>    phoneNumber: undefined,
>    disabled: false,
>    metadata:
>     UserMetadata {
>       creationTime: 'Wed, 21 Oct 2020 17:08:19 GMT',
>       lastSignInTime: 'Wed, 21 Oct 2020 17:08:19 GMT',
>       lastRefreshTime: null },
>    providerData:
>     [ UserInfo {
>         uid: '[email protected]',
>         displayName: 'Sam Example',
>         email: '[email protected]',
>         photoURL: '',
>         providerId: 'password',
>         phoneNumber: undefined } ],
>    passwordHash: 'fakeHash:salt=fakeSaltssM70XPsus7igcpHZ82U:password=samsam',
>    passwordSalt: 'fakeSaltssM70XPsus7igcpHZ82U',
>    tokensValidAfterTime: 'Wed, 21 Oct 2020 17:08:19 GMT',
>    tenantId: undefined }
i  functions: Finished "helloWorld" in ~1s

Sample Commands

N/A

@google-cla google-cla bot added the cla: yes Manual indication that this has passed CLA. label Oct 21, 2020
@samtstern samtstern requested a review from yuchenshi October 21, 2020 17:10
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.

Amazing stuff! Please add some integration tests (or create an issue/bug for follow up, doesn't need to come in this PR)

@samtstern
Copy link
Contributor Author

@yuchenshi integration tests are going to be hard because the Admin SDK with this feature is Node 10+ only but our tests currently run on Node 8+ ... I'll figure that out in a follow up.

@samtstern samtstern merged commit a1fd2ee into master Oct 21, 2020
@bkendall bkendall deleted the ss-auth-emulator-admin-sdk branch August 4, 2021 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Manual indication that this has passed CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants