firebase / firebase/firebase-admin-node

[FR] Indexing Auth data and ListUsers with query

Đang mở
#2,068 0 bình luận 2 reaction 0 người được giao Xem trên GitHub
type: feature request
Ngôn ngữ chính
TypeScript
Star
1.7k
Fork
419
Merge trung bình
3 ngày 10 giờ
Pull request đã merge (30 ngày)
16

Mô tả

**Is your feature request related to a problem? Please describe.**
FirebaseAuth custom claim is a great and officially recommended way to support Access Control with Rules and many features across multiple firebase modules. Yet all the auth users in firebase auth system are not distinguishable. We cannot easily control or even annotate user

Simplest use case is, we might have privilege system with firebase auth's custom claims as suggest in https://firebase.google.com/docs/auth/admin/custom-claims. But then we might want to list all the admin in our system. We need to create table for storing duplicate auth data in firestore that need to be perfectly sync with auth system just for indexing auth claims

**Describe the solution you'd like**
`listUsers` api should have more functionality. Especially filter or query by custom claims and provider (and the lack of, if possible). So we can list and manage specific users

```js
var maxResult = 100;
var allAdmins = await firebaseAdmin.auth().listUsers(maxResult,{ "claims.admin": { "equal": true } },pageToken);

var allPrivilegeUsers = await firebaseAdmin.auth().listUsers(maxResult,{ "claims.level": { "greaterThanOrEqual": 2 } },pageToken);

var allUserWithClaims = await firebaseAdmin.auth().listUsers(maxResult,{ "claims": { "greaterThan": null } },pageToken);

var allFacebookUsers = await firebaseAdmin.auth().listUsers(maxResult,{ "providers.`facebook.com`": { "greaterThan": null } },pageToken);
```

I think firestore query is the most familiar and sensible which should be available

**Describe alternatives you've considered**
Making firestore data working across storage and functions maybe? We can skip setting custom claims to user and use only firestore collection in storage and datastore rules, claims will then be used only in custom token for temporary session

**Additional context**
I don't even know the order of `listUsers` api will return back. Is it ordered by creation times? Is the last user would be returned in the last batch? I wish there would be filter by creation time such as

```js
var maxResult = 100;
var year2021 = new Date("2021-01-01");
var year2023 = new Date("2023-01-01");
var result = await firebaseAdmin.auth().listUsers(maxResult,{ createdAfter: year2021,createdBefore: year2023 },pageToken);
```

Also it should have option to orderby ascending and descending if the `listUsers` was sorted by its creation time. All of these would also let us manage user's data in firestore and datastore a lot more easier

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.