`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?)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- firebase, react, typescript
- Lĩnh vực
- authentication, frontend
Hướng nghiên cứu
Bắt đầu với CodeSandbox được liên kết, đặc biệt là App và ComponentForSuperadminOnly, sau đó đọc entry point useSigninCheck và so sánh validateCustomClaims với requiredClaims. Xác nhận cách các kiểm tra claim khác nhau được xử lý qua các lần gọi; công việc được hoàn tất khi các kiểm tra admin và superadmin lần lượt trả về kết quả phù hợp, thay vì sử dụng lại kết quả đầu tiên.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- TypeScript
- Star
- 3.6k
- Fork
- 403
- Merge trung bình
- 5 ngày 1 giờ
- Pull request đã merge (30 ngày)
- 10
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của FirebaseExtended/reactfire
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 38/100
FirebaseExtended/reactfire#801 ·
-
v5
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
FirebaseExtended/reactfire#793 ·
-
v5
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
FirebaseExtended/reactfire#790 · 2 bình luận ·
-
v5
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
FirebaseExtended/reactfire#789 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
FirebaseExtended/reactfire#788 ·
Tất cả issue của FirebaseExtended/reactfire
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
bcgov/bc-wallet-mobile#4761 · 1 bình luận ·
-
external-issue to-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
area-deployment area-integrations triage:bot-seen
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 86/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
refactor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100