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

WIP authIdTokenVerified #8008

Draft
wants to merge 30 commits into
base: main
Choose a base branch
from

Conversation

jamesdaniels
Copy link
Member

@jamesdaniels jamesdaniels commented Feb 3, 2024

WIP of FirebaseServerApp.authIdTokenVerified FYI @DellaBitta

TODO:

  • tests
  • handle emulated credentials
  • cleanup
  • add rejection reasons
  • reject rather than throw on shape of jwt
  • trigger rejection/resolution of the promise from Firebase Auth (reload)
  • make it work in non-node environments (subtle)
  • switch to jwks

DellaBitta and others added 8 commits January 8, 2024 14:32
Baseline addition of the FirebaseServerApp object.
…IdToken (#7944)

Add support for logging-in users with the FirebaseServerApp's authIdToken.

### Testing

Local project testing client-side created users, passing idTokens to serverApps, and logging in the user. Tested with multiple users and multiple instances of FirebaseServerApps w/ Auth.

CI tests (added integration tests).

### API Changes

N/A
…ck later (#7989)

Removed the appCheck and installations token parameters in FirebaseServerAppSettings as they won't be part of our initial launch. Additionally, update the the doxgen comments to no longer refer to these parameters, and to inform users that the User refreshToken will not work for User objects signed in with the authIdToken.
Mangle the name of the ServerAap based on the hash of the parameters passed in.
In addition, return the same instance of app when the same parameters are used.
Update the `FirebaseServerApp` creation to return the same object if an existing object exists with the same configuration. However, the `deleteOnDeref` field is ignored when detecting duplicate apps, since that object reference could vary across multiple SSR rendering passes.

The hope is that a `FirebaseServerApp` instance awaiting deletion from a the `deleteOnDeref` feature maybe be reused if another SSR pass occurs in rapid succession, there by speeding up the SSR code.
Copy link

changeset-bot bot commented Feb 3, 2024

⚠️ No Changeset found

Latest commit: 27a0ac7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Feb 3, 2024

Size Report 1

Affected Products

  • @firebase/app

    TypeBase (e3e3339)Merge (96c5505)Diff
    browser18.1 kB20.8 kB+2.77 kB (+15.3%)
    esm523.6 kB27.6 kB+3.91 kB (+16.5%)
    main24.7 kB28.6 kB+3.95 kB (+16.0%)
    module18.1 kB20.8 kB+2.77 kB (+15.3%)
  • @firebase/auth

    TypeBase (e3e3339)Merge (96c5505)Diff
    browser182 kB182 kB+320 B (+0.2%)
    cordova210 kB210 kB+322 B (+0.2%)
    esm5236 kB237 kB+322 B (+0.1%)
    main179 kB179 kB+330 B (+0.2%)
    module182 kB182 kB+320 B (+0.2%)
    react-native199 kB199 kB+334 B (+0.2%)
  • @firebase/auth/cordova

    TypeBase (e3e3339)Merge (96c5505)Diff
    browser210 kB210 kB+322 B (+0.2%)
    module210 kB210 kB+322 B (+0.2%)
  • @firebase/auth/internal

    TypeBase (e3e3339)Merge (96c5505)Diff
    browser193 kB193 kB+320 B (+0.2%)
    esm5250 kB250 kB+322 B (+0.1%)
    main215 kB215 kB+334 B (+0.2%)
    module193 kB193 kB+320 B (+0.2%)
  • @firebase/auth/web-extension

    TypeBase (e3e3339)Merge (96c5505)Diff
    browser137 kB137 kB+320 B (+0.2%)
    main152 kB152 kB+332 B (+0.2%)
    module137 kB137 kB+320 B (+0.2%)
  • @firebase/util

    TypeBase (e3e3339)Merge (96c5505)Diff
    browser23.1 kB23.8 kB+742 B (+3.2%)
    esm524.7 kB25.5 kB+757 B (+3.1%)
    main30.5 kB31.0 kB+513 B (+1.7%)
    module23.1 kB23.8 kB+742 B (+3.2%)
  • bundle

    46 size changes

    TypeBase (e3e3339)Merge (96c5505)Diff
    analytics (logEvent)44.4 kB45.2 kB+802 B (+1.8%)
    app-check (CustomProvider)37.3 kB38.1 kB+802 B (+2.2%)
    app-check (ReCaptchaEnterpriseProvider)39.8 kB40.6 kB+802 B (+2.0%)
    app-check (ReCaptchaV3Provider)39.8 kB40.6 kB+802 B (+2.0%)
    auth (Anonymous)76.0 kB77.1 kB+1.08 kB (+1.4%)
    auth (EmailAndPassword)84.3 kB85.4 kB+1.08 kB (+1.3%)
    auth (GoogleFBTwitterGitHubPopup)103 kB104 kB+1.08 kB (+1.0%)
    auth (GooglePopup)100 kB101 kB+1.08 kB (+1.1%)
    auth (GoogleRedirect)101 kB102 kB+1.08 kB (+1.1%)
    auth (Phone)86.6 kB87.7 kB+1.08 kB (+1.2%)
    database (Append to a list of data)149 kB150 kB+802 B (+0.5%)
    database (Filtering data)148 kB149 kB+802 B (+0.5%)
    database (Listen for child events)164 kB165 kB+802 B (+0.5%)
    database (Listen for value events + Detach listeners)164 kB165 kB+802 B (+0.5%)
    database (Listen for value events)164 kB165 kB+802 B (+0.5%)
    database (Read data once)164 kB164 kB+802 B (+0.5%)
    database (Save data as transactions)166 kB167 kB+802 B (+0.5%)
    database (Sort data)149 kB150 kB+802 B (+0.5%)
    database (Write data)148 kB149 kB+802 B (+0.5%)
    firestore (CSI Auto Indexing Disable and Delete)268 kB269 kB+804 B (+0.3%)
    firestore (CSI Auto Indexing Enable)268 kB269 kB+804 B (+0.3%)
    firestore (Persistence)303 kB304 kB+804 B (+0.3%)
    firestore (Query Cursors)247 kB248 kB+802 B (+0.3%)
    firestore (Query)245 kB245 kB+802 B (+0.3%)
    firestore (Read data once)233 kB234 kB+802 B (+0.3%)
    firestore (Read Write w Persistence)323 kB323 kB+802 B (+0.2%)
    firestore (Realtime updates)235 kB236 kB+802 B (+0.3%)
    firestore (Transaction)212 kB213 kB+802 B (+0.4%)
    firestore (Write data)212 kB212 kB+802 B (+0.4%)
    firestore-lite (Query Cursors)89.8 kB90.6 kB+802 B (+0.9%)
    firestore-lite (Query)85.9 kB86.7 kB+802 B (+0.9%)
    firestore-lite (Read data once)62.1 kB62.9 kB+802 B (+1.3%)
    firestore-lite (Transaction)87.0 kB87.8 kB+802 B (+0.9%)
    firestore-lite (Write data)71.6 kB72.4 kB+802 B (+1.1%)
    functions (call)31.8 kB32.6 kB+802 B (+2.5%)
    messaging (send + receive)47.2 kB48.0 kB+810 B (+1.7%)
    performance (trace)51.6 kB52.4 kB+809 B (+1.6%)
    remote-config (getAndFetch)46.2 kB47.0 kB+804 B (+1.7%)
    storage (getBytes)42.0 kB42.8 kB+802 B (+1.9%)
    storage (getDownloadURL)44.0 kB44.8 kB+802 B (+1.8%)
    storage (getMetadata)43.5 kB44.3 kB+802 B (+1.8%)
    storage (list + listAll)42.9 kB43.7 kB+802 B (+1.9%)
    storage (updateMetadata)43.7 kB44.5 kB+802 B (+1.8%)
    storage (uploadBytes)48.6 kB49.4 kB+802 B (+1.7%)
    storage (uploadBytesResumable)58.5 kB59.3 kB+802 B (+1.4%)
    storage (uploadString)48.8 kB49.6 kB+802 B (+1.6%)

  • firebase

    TypeBase (e3e3339)Merge (96c5505)Diff
    firebase-app-compat.js31.4 kB33.6 kB+2.14 kB (+6.8%)
    firebase-app.js102 kB107 kB+5.42 kB (+5.3%)
    firebase-auth-compat.js140 kB140 kB+309 B (+0.2%)
    firebase-auth-cordova.js177 kB178 kB+269 B (+0.2%)
    firebase-auth-web-extension.js117 kB117 kB+267 B (+0.2%)
    firebase-auth.js151 kB151 kB+267 B (+0.2%)
    firebase-compat.js786 kB788 kB+2.46 kB (+0.3%)
    firebase-performance-standalone-compat.es2017.js93.3 kB96.2 kB+2.89 kB (+3.1%)
    firebase-performance-standalone-compat.js70.4 kB73.3 kB+2.95 kB (+4.2%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/oGZiaQwonC.html

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Feb 3, 2024

Size Analysis Report 1

This report is too large (199,126 characters) to be displayed here in a GitHub comment. Please use the below link to see the full report on Google Cloud Storage.

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/kzzyTEg3Ro.html

@jamesdaniels jamesdaniels changed the title WIP WIP authIdTokenVerified Feb 3, 2024
return memoizedPublicKeys;
}

function base64decode(base64Contents: string): string {
Copy link
Member Author

Choose a reason for hiding this comment

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

are there already utils for this ops? look into

Copy link
Contributor

Choose a reason for hiding this comment

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

And if not, then add this to the util file.

jamesdaniels and others added 5 commits February 5, 2024 15:08
Updates FirebaseServerApp implementation in Auth to prevent operations that would change the currently logged in user. The user should be that of the authIdToken provided to FirebaseServerApp only.

Note: some of the method implementations currently reside in browser-only files. I added safe guards to these methods even though FirebaseServerApp is not supported in browser enviornments.  These guards protect us in case the methods are later adapted to other environments and/or migrated to other files that are not browser-only. The changes to the browser implementations produce little overhead, so I thought that safety first was the correct call here.
jamesdaniels and others added 5 commits March 20, 2024 17:35
It turns out the FirebaseServerApp implementation in #8005 was not blocking auth initialization, so when testing end-to-end we were seeing race conditions with auth state. In this PR I address by awaiting the user fetch and moving the implementation into AuthImpl#initializeCurrentUser for cleanliness.
Base automatically changed from feature-firebaseserverapp to master March 23, 2024 12:11
@jamesdaniels jamesdaniels mentioned this pull request Mar 10, 2025
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants