import HMAC1 users with different hash algorithm keys one after another not setting correct passwords
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
- 38/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- firebase, javascript, nodejs
- Lĩnh vực
- authentication, backend
Hướng nghiên cứu
Bắt đầu từ điểm đầu vào admin.auth().importUsers và theo dõi cách tùy chọn hash cùng khóa HMAC_SHA1 riêng cho từng người dùng được xử lý qua các lần nhập tuần tự. Tái hiện script được cung cấp, sau đó xác minh rằng tất cả người dùng được nhập bằng các khóa khác nhau đều xác thực bằng mật khẩu tương ứng và kết quả nhập vẫn thành công.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
[READ] Step 1: Are you in the right place?
- For issues related to the code in this repository file a Github issue.
- If the issue pertains to Cloud Firestore, read the instructions in the "Firestore issue"
template. - For general technical questions, post a question on StackOverflow
with the firebase tag. - For general Firebase discussion, use the firebase-talk
google group. - For help troubleshooting your application that does not fall under one
of the above categories, reach out to the personalized
Firebase support channel.
[REQUIRED] Step 2: Describe your environment
- Operating System version: windows 10
- Firebase SDK version: 12.1.1
- Firebase Product: admin
- Node.js version: 20.11.0
- NPM version: 10.2.4
[REQUIRED] Step 3: Describe the problem
When using the importUsers function, it is not correctly importing users where each one has a different hash key.
I am importing users where each user's password was created using HMAC sha1 but each user had its own key. I was trying to import 1 user per function call but when I import say 100 users one at a time, the majority of them import incorrectly(code below should make this easy to understand) . If I rerun a subset of around 10 users using the exact same information passed in they then will login correctly.
Is there some internal limitation or batching happening? I am importing users one at a time and respecting the API quotas and they are successful imports. This has been very confusing to understand the correct way to handle this scenario is and it feels difficult to understand a pattern.
Given they all import with no issues but only some actually log in correctly and when I rerun then more will work, tells me I am not passing in bad data but something about how they process is different each time.
Steps to reproduce:
What happened? How can we make the problem occur?
This could be a description, log/console output, etc.
Relevant Code:
The code below will generate 100 users and import them one at a time and then when I attempt to log in, only the last 10 ish will even work, all others get incorrect password errors.
const crypto = require('crypto');
const admin = require('firebase-admin');
var serviceAccount = require(".\\key.json");
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
});
const randomString = (length) => {
return Math.random().toString(36).slice(2, length + 2)
}
const users = [];
for(let i = 0; i <= 100; i++) {
const text = 'password'
const key = randomString(12);
const passwordHash = crypto.createHmac('sha1', key)
.update(text)
.digest('hex')
users.push({
plainPassword: text,
passwordHash,
key,
email_address: `${i}@gmail.com`,
id: i.toString()
})
}
async function start() {
for (const user of users) {
const result = await admin.auth().importUsers([
{
uid: user.id,
email: user.email_address,
passwordHash: Buffer.from(user.passwordHash, 'hex'),
emailVerified: true
}
], {
hash: {
algorithm: "HMAC_SHA1",
key: Buffer.from(user.key)
}
})
console.log(result.errors[0]);
}
}
start();
- Ngôn ngữ chính
- TypeScript
- Star
- 1.7k
- Fork
- 419
- Merge trung bình
- 4 ngày 20 giờ
- Pull request đã merge (30 ngày)
- 16
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 firebase/firebase-admin-node
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
firebase/firebase-admin-node#3234 ·
-
firebase/firebase-admin-node#3221 · 3 bình luận · 1 người được giao ·
-
api: messaging
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 70/100
firebase/firebase-admin-node#3215 ·
-
api: messaging
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 28/100
firebase/firebase-admin-node#3214 ·
-
api: firestore type: feature request
firebase/firebase-admin-node#3183 · 1 bình luận · 1 người được giao ·
Tất cả issue của firebase/firebase-admin-node
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