Skip to content

request.auth is null for what should be a valid request with self-made custom token [Firestore emulation] #4795

Closed
@akauppi

Description

@akauppi

[REQUIRED] Describe your environment

  • Operating System version: macOS 11.2.3
  • Browser version: Chrome 89
  • Firebase SDK version: 9.0.0-beta.1
  • Firebase Product: firestore

[REQUIRED] Describe the problem

The context is emulation (development). In production everything is nice.

In my security rules, request.auth is null though it should not.

I've authenticated in web client like this:

 await signInWithCustomToken( auth, JSON.stringify({ uid }) ) .then( creds => { console.debug("Signed in as:", { creds }); }) .catch( err => { console.error("Sign-in failed:", err); }); 

I can see in the browser console that the sign-in is successful.

firestore-debug.log shows this warning:

Apr 15, 2021 1:19:05 PM com.google.net.webchannel.server.common.CorsFilter populateCustomHeaders WARNING: Invalid $httpHeaders: X-Goog-Api-Client:gl-js/ fire/8.4.1 X-Firebase-GMPID: Content-Type:text/plain Authorization:Bearer eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJuYW1lIjoiSnVzdCBNZSIsInBpY3R1cmUiOiJodHRwczovL25vLnN1Y2guZG9tYWluIiwiZW1haWxfdmVyaWZpZWQiOmZhbHNlLCJhdXRoX3RpbWUiOjE2MTg0ODE5NDUsInVzZXJfaWQiOiJkZXYiLCJmaXJlYmFzZSI6eyJpZGVudGl0aWVzIjp7fSwic2lnbl9pbl9wcm92aWRlciI6ImN1c3RvbSJ9LCJpYXQiOjE2MTg0ODE5NDUsImV4cCI6MTYxODQ4NTU0NSwiYXVkIjoiYXBwIiwiaXNzIjoiaHR0cHM6Ly9zZWN1cmV0b2tlbi5nb29nbGUuY29tL2FwcCIsInN1YiI6ImRldiJ9. 

Can I do something about that?

But the real problem is that I cannot subscribe to changes of the connection guarded by a rule that uses request.auth.uid. I've established that request.auth is null, by playing with the rule.

Steps to reproduce:

$ git clone git@github.com:akauppi/GroundLevel-firebase-es.git $ cd GroundLevel-firebase-es $ git checkout interim # this branch $ npm install 
$ cd packages/app $ npm install $ npm run dev 

Open http://localhost:3000/?user=dev and observe the contents of the firestore-debug.log

Expected:

jolly-is-missing

Actual:

As above, without the project entry.

This looks like a bug or two, to me. Things used to work long ago. The current code is based on 9.0.0-beta.1 and I'm no longer able to try with 8.x APIs. Not sure which change has started this problem.

Thanks for any help!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      close