Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[Bug] Unable to use custom claims in firestore security rule when querying from C++ SDK

Open
#1,783 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp, firebase

Research direction

Start by reproducing the 100% failure with Firebase C++ SDK 13.0.0 on Mac, targeting desktop or iOS, using the shown Firestore rule and a query on subscriptions. Check the Auth and Firestore request path, including the custom claim fetched through Firebase Functions. Done means determining whether the claim reaches the security rule for C++ SDK queries and documenting or fixing the cause of the permission error.

Written by the indexing model from the issue text.

Description

api: auth new type: question
[REQUIRED] Please fill in the following fields:
  • Pre-built SDK from the website
  • Firebase C++ SDK version: 13.0.0
  • Problematic Firebase Component: Auth and Firestore
  • Other Firebase Components in use: Functions, Storage
  • Platform you are using the C++ SDK on: Mac
  • Platform you are targeting: Desktop and iOS
[REQUIRED] Please describe the issue here:

I get Missing or insufficient permissions when querying firestore collection that has a security rule that looks like:

match /subscriptions/{subscriptionId} {
    allow read: if request.auth != null && request.auth.token.legacy_id == resource.data.user_id; 
} 

I am using the C++ SDK, which doesn't give direct access to the auth custom claims, but I am able to fetch custom claims via a Firebase function, and see the values correctly in the client after those are fetched.

If I write a security rule that depends on those claims, it fails. Does writing a rule that uses request.auth.token.legacy_id work when the request comes from the C++ SDK?

Steps to reproduce:

What's the issue repro rate? 100%

It appears that using a custom claim (say, a numeric secondary ID) and requiring that to match a field on a document doesn't work when the query is run from the C++ SDK.

Dominant language
C++
Stars
326
Forks
138
Avg merge
2d 16h
Merged PRs (30d)
3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from firebase/firebase-cpp-sdk

All issues in firebase/firebase-cpp-sdk

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.