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

FirbaseAdmin.Auth().verifyIdToken not tenant aware #2803

Open
Penberthy-gossan opened this issue Dec 6, 2024 · 1 comment
Open

FirbaseAdmin.Auth().verifyIdToken not tenant aware #2803

Penberthy-gossan opened this issue Dec 6, 2024 · 1 comment
Assignees

Comments

@Penberthy-gossan
Copy link

  • Operating System version: run.googleapis.com (linux)
  • Firebase SDK version: 5.1.0
  • Firebase Product: Admin auth
  • Node.js version: 20
  • NPM version: 10.8.2

Verify id tokens in firebase functions will fail when using tenants in Google Identity platform

Steps to reproduce:

1 Create a app in Firebase and enable google identitiy platform.
2 Add tenant to identities platform
3 Add user to tenant
4 Log into app using user and tenant id
5 call google function from app
6 in function attempt to verify id token with FirebaseAdmin.auth().verifyIdToken('tokenString')

error
Error: There is no user record corresponding to the provided identifier.

Relevant Code:

  var token = await admin.auth() .verifyIdToken(req.rawRequest.header('Authorization').substring(7),true);

I could use the TenantAuth but to get that I would need the TennantId which is in the token, which you can access by verifying the token but like I said you need to know the tenant for that. I could manually scrape the tenantId from the jet by parsing it myself but then I have to hard code its location in the jwt firebase attribute with could change.

    var tenantAuth = await admin.auth().tenantManager().authForTenant(token.firebase.tenant);
    var token = await tenantAuth.verifyIdToken(req.rawRequest.header('Authorization').substring(7),true);

Expected functionality would be that it detect the presence of a tenant in the firebase attribute and attempt to get the correct tenantAuth instance and use that to verify.

@google-oss-bot
Copy link

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants