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

Added Firebase App Check support to Firebase Auth. #7191

Merged
merged 3 commits into from
Apr 10, 2023

Conversation

lisajian
Copy link
Contributor

@lisajian lisajian commented Apr 3, 2023

Discussion

As the title implies

Internal tracking bug: b/265453815

Testing

Unit tests pass and manually tested endpoints as part of go/gcip-app-check-bug-bash

API Changes

N/A

@changeset-bot
Copy link

changeset-bot bot commented Apr 3, 2023

🦋 Changeset detected

Latest commit: 2338348

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@firebase/auth Minor
@firebase/auth-compat Minor
firebase Patch

Not sure what this means? Click here to learn what changesets are.

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

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Apr 3, 2023

Size Report 1

Affected Products

  • @firebase/auth

    TypeBase (fb6df83)Merge (43657de)Diff
    browser160 kB162 kB+1.08 kB (+0.7%)
    cordova185 kB186 kB+1.59 kB (+0.9%)
    esm5210 kB212 kB+1.68 kB (+0.8%)
    main154 kB155 kB+1.14 kB (+0.7%)
    module160 kB162 kB+1.08 kB (+0.7%)
    react-native170 kB171 kB+1.15 kB (+0.7%)
  • @firebase/auth/cordova

    TypeBase (fb6df83)Merge (43657de)Diff
    browser185 kB186 kB+1.59 kB (+0.9%)
    module185 kB186 kB+1.59 kB (+0.9%)
  • @firebase/auth/internal

    TypeBase (fb6df83)Merge (43657de)Diff
    browser171 kB172 kB+1.08 kB (+0.6%)
    esm5223 kB225 kB+1.68 kB (+0.8%)
    main190 kB191 kB+1.64 kB (+0.9%)
    module171 kB172 kB+1.08 kB (+0.6%)
  • @firebase/auth/react-native

    TypeBase (fb6df83)Merge (43657de)Diff
    browser170 kB171 kB+1.15 kB (+0.7%)
    module170 kB171 kB+1.15 kB (+0.7%)
  • bundle

    TypeBase (fb6df83)Merge (43657de)Diff
    auth (Anonymous)67.6 kB68.1 kB+498 B (+0.7%)
    auth (EmailAndPassword)71.7 kB72.2 kB+498 B (+0.7%)
    auth (GoogleFBTwitterGitHubPopup)94.0 kB94.7 kB+648 B (+0.7%)
    auth (GooglePopup)91.3 kB91.9 kB+648 B (+0.7%)
    auth (GoogleRedirect)91.5 kB92.2 kB+648 B (+0.7%)
    auth (Phone)77.7 kB78.2 kB+498 B (+0.6%)
  • firebase

    TypeBase (fb6df83)Merge (43657de)Diff
    firebase-auth-compat.js126 kB127 kB+565 B (+0.4%)
    firebase-auth-cordova.js138 kB139 kB+934 B (+0.7%)
    firebase-auth-react-native.js150 kB151 kB+745 B (+0.5%)
    firebase-auth.js120 kB120 kB+589 B (+0.5%)
    firebase-compat.js751 kB751 kB+555 B (+0.1%)

Test Logs

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

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Apr 3, 2023

Size Analysis Report 1

This report is too large (235,243 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/gFy3sw0KFT.html

Copy link
Contributor

@prameshj prameshj left a comment

Choose a reason for hiding this comment

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

LGTM. Will let @sam-gc and @renkelvin take a look too.

config
);
_initializeAuthInstance(authInstance, deps);
_assert(
Copy link
Contributor

Choose a reason for hiding this comment

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

We were previously wrapping it as an anonymous function and invoking it right away, now we are just invoking it without that wrapper, correct?

Adding @sam-gc to look at this section, since we had some past discussion about whether initializeAuthInstance needs to be invoked 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.

Yep, just invoking without that wrapper - no changes have been made since https://github.com/firebase/firebase-js-sdk/pull/6982/files#r1089404274. _initializeAuthInstance() is called on line 95

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I think this is fine to do. It was unnecessarily complicated creating a throwaway anonymous function that's immediately called.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool thanks

return `${getHandlerBase(auth)}?${querystring(paramsDict).slice(1)}`;

// Sets the App Check token to pass to the widget
const appCheckToken = await auth._getAppCheckToken();

Choose a reason for hiding this comment

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

What will happen if _getAppCheckToken() failed? Should we return a url without an app check token, or throw an exception?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

_getAppCheckToken() will generally return a token (either a real one or a dummy token, for more info see the comment in auth_impl.ts) and we will always pass that real / dummy token to the widget. If there's an error, we simply log it client side, and when the backend receives a dummy token, it would prevent the request from succeeding if App Check is enforced.

Copy link
Contributor

@sam-gc sam-gc left a comment

Choose a reason for hiding this comment

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

LGTM

config
);
_initializeAuthInstance(authInstance, deps);
_assert(
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I think this is fine to do. It was unnecessarily complicated creating a throwaway anonymous function that's immediately called.

expect(matches).to.be.null;
});

it('does not add the App Check token in the url fragment if controller unavailable', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you run yarn lint:fix ? (Or maybe it's yarn format?) to auto-wrap this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, the linter isn't marking this as an issue (neither prettify nor yarn lint:fix)? I'll leave it as is for now

* Add App Check token to headers of Auth requests

* Add App Check token to widget url fragment
@lisajian lisajian force-pushed the lj-appcheck-feature branch from 15badef to 2338348 Compare April 10, 2023 21:20
@lisajian lisajian merged commit b04f040 into master Apr 10, 2023
@lisajian lisajian deleted the lj-appcheck-feature branch April 10, 2023 23:37
@google-oss-bot google-oss-bot mentioned this pull request Apr 13, 2023
@firebase firebase locked and limited conversation to collaborators May 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants