Skip to content
This repository was archived by the owner on Mar 4, 2026. It is now read-only.

fix: authenticate as admin user when ssl:false is set#1095

Merged
schmidt-sebastian merged 1 commit intogoogleapis:masterfrom
yuchenshi:patch-1
May 30, 2020
Merged

fix: authenticate as admin user when ssl:false is set#1095
schmidt-sebastian merged 1 commit intogoogleapis:masterfrom
yuchenshi:patch-1

Conversation

@yuchenshi
Copy link
Copy Markdown
Contributor

@yuchenshi yuchenshi commented May 29, 2020

This fixes firebase/firebase-js-sdk#3105 (comment).

Before this change, db.settings({..., ssl: false}) will connect but without any credentials (similar to a client device that is not logged in), which causes Firestore Emulator to evaluate security rules for requests. This is surprising for an Admin SDK and it is extremely hard to troubleshoot.

After this change, the same code should correctly behave like admin. This also provides one additional way to get admin privileges in the Firestore Emulator if for some reasons the environment variables is not viable / desirable.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label May 29, 2020
@yuchenshi yuchenshi force-pushed the patch-1 branch 2 times, most recently from 8b2a4bd to 47a2623 Compare May 29, 2020 18:40
Copy link
Copy Markdown
Contributor

@schmidt-sebastian schmidt-sebastian left a comment

Choose a reason for hiding this comment

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

Please verify that it is already not possible to connect to a Firestore backend with grpc.credentials.createInsecure() before merging.

Comment thread dev/src/index.ts Outdated
Copy link
Copy Markdown
Contributor

@schmidt-sebastian schmidt-sebastian left a comment

Choose a reason for hiding this comment

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

Oh, one more thing: Before merging, you need to update your PR title as it will be used to generate release notes. Something like:

fix: authenticate as admin user when ssl:false is set

This fixes firebase/firebase-js-sdk#3105 (comment).

Before this change, `db.settings({..., ssl: false})` will connect but without any credentials (similar to a client device that is not logged in), which causes Firestore Emulator to evaluate security rules for requests. This is surprising for an Admin SDK and it is extremely hard to troubleshoot.

After this change, the same code should correctly behave like admin. This also provides one additional way to get admin privileges in the Firestore Emulator if for some reasons the environment variables is not viable / desirable.
@yuchenshi yuchenshi changed the title Authenticate using fake bearer token when ssl is false. fix: authenticate as admin user when ssl:false is set May 30, 2020
@yuchenshi
Copy link
Copy Markdown
Contributor Author

Oh, one more thing: Before merging, you need to update your PR title as it will be used to generate release notes. Something like:

fix: authenticate as admin user when ssl:false is set

Done.

@yuchenshi
Copy link
Copy Markdown
Contributor Author

Please verify that it is already not possible to connect to a Firestore backend with grpc.credentials.createInsecure() before merging.

Verified that https://grpc.github.io/grpc/node/grpc.credentials.html#.createInsecure also drops all credentials and cannot be combined with other credentials.

@schmidt-sebastian schmidt-sebastian added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 30, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 30, 2020
@schmidt-sebastian schmidt-sebastian merged commit a178556 into googleapis:master May 30, 2020
@samtstern
Copy link
Copy Markdown

This change somehow broke the FIRESTORE_EMULATOR_HOST flow, see:
firebase/firebase-tools#2310

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Timestamp incompatibility between firebase-admin and firebase/testing

5 participants