Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

`validateCustomClaims` only runs once and then returns the same result for every other attempted call even when checking different claims (security flaw or am I using it wrong?)

Aperta
#514 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
firebase, react, typescript

Direzione di ricerca

Inizia con il CodeSandbox collegato, in particolare App e ComponentForSuperadminOnly, poi leggi l’entry point useSigninCheck e confronta validateCustomClaims con requiredClaims. Verifica come vengono gestiti i diversi controlli dei claim tra una chiamata e l’altra; il lavoro è completato quando i controlli admin e superadmin restituiscono ciascuno il risultato appropriato invece di riutilizzare il primo risultato.

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

Descrizione

v5
Version info

React: 17.0.1

Firebase: 9.6.1

ReactFire: 4.2.1

Steps to reproduce

use useSigninCheck with validateCustomClaims at some point in the component tree and then try to use it again later on with different custom claims

Expected behavior

I should be able to pass different custom claims during different calls to show/hide different parts of the UI. validateCustomClaims should run every time I use it and return the appropriate result. For example, if I want to show some components to "admin" users and some other components to "superadmin" users.

Actual behavior

validateCustomClaims only runs the first time you call it and on subsequent calls just returns the same hasRequiredClaims result from the initial run. This seems to be a major security flaw especially if you aren't aware that it's doing this.

Test case

The sandbox below calls validateCustomClaims in the <App /> component and returns a hardcoded true result... Later in the <ComponentForSuperadminOnly /> it tries to validate that the user has superadmin claim and returns true even though it does not have the claim. Additionally, the validateCustomClaims function is not even run in this call as there is no console.log for it.

If you switch the validateCustomClaims check in the <App /> component to use the requiredClaims method then the custom validator does run in the <ComponentForSuperadminOnly /> component.

Lastly, using the requiredClaims property method to check for superadmin instead of a custom validator returns the appropriate result no matter where it is used. I would assume both methods should always return an accurate result no matter where they are used in the tree.

https://codesandbox.io/s/usesignincheckissue-xqwm4u?file=/src/App.js

Lingua principale
TypeScript
Stelle
3.6k
Fork
403
Merge medio
5g 1h
PR unite (30g)
10

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di FirebaseExtended/reactfire

Tutte le issue di FirebaseExtended/reactfire

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.