firebase / firebase/firebase-cpp-sdk

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

Aperta
#1,783 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
api: auth new type: question
Lingua principale
C++
Stelle
326
Fork
137
Merge medio
3g 9h
PR unite (30g)
5

Descrizione

### [REQUIRED] Please fill in the following fields:

* Pre-built SDK from the [website](https://firebase.google.com/download/cpp)
* 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.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia riproducendo il fallimento al 100% con Firebase C++ SDK 13.0.0 su Mac, con target desktop o iOS, usando la regola Firestore mostrata e una query su subscriptions. Controlla il percorso delle richieste Auth e Firestore, inclusa la custom claim recuperata tramite Firebase Functions. Il lavoro è completato quando viene determinato se la claim raggiunge la regola di sicurezza per le query del C++ SDK e viene documentata o corretta la causa dell’errore di autorizzazione.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
cpp, firebase
Ambito
authentication, databases, security
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.