gray-machine-46287
01/27/2025, 11:34 AMpbkdf2_sha256$600000$NB8zDFPPtzoxMYJCHvl4P0$1Ly+JQBrozvQJVocdc5tbEJfF7PB//NnM6Jq7K5uyLE=
to a format that Kratos would understand?brief-egg-61061
01/27/2025, 11:35 AMbrief-egg-61061
01/27/2025, 11:35 AM$pbkdf2-sha256$i=600000,l=32$NB8zDFPPtzoxMYJCHvl4P0$1Ly+JQBrozvQJVocdc5tbEJfF7PB//NnM6Jq7K5uyLE=
Let's break down the transformation: 1. The format Kratos expects for PBKDF2 hashes is: $pbkdf2-<algorithm>$i=<iteration>,l=<length>$<salt>$<hash>
[Kratos Import Identities - Format](https://www.ory.sh/docs/kratos/manage-identities/import-user-accounts-identities#format-1) 2. From the original hash, we can identify: - Algorithm: sha256 - Iterations: 600000 - Salt: NB8zDFPPtzoxMYJCHvl4P0 - Hash: 1Ly+JQBrozvQJVocdc5tbEJfF7PB//NnM6Jq7K5uyLE= 3. The length parameter (l=32) is derived from the fact that SHA-256 produces a 32-byte (256-bit) hash. By reformatting the original hash into this structure, we've created a version that Ory Kratos can understand and use for password verification. This format allows Kratos to compare stored PBKDF2 hashes and potentially migrate them to the configured hasher algorithm if it's different.gray-machine-46287
01/27/2025, 11:37 AM"credentials": {
"password": {
"config": {
"hashed_password": "$pbkdf2-sha256$i=600000,l=32$NB8zDFPPtzoxMYJCHvl4P0$1Ly+JQBrozvQJVocdc5tbEJfF7PB//NnM6Jq7K5uyLE="
}
}
}
I cannot submit a login flow.gray-machine-46287
01/27/2025, 12:53 PM"credentials": {
"password": {
"config": {
"hashed_password": "$pbkdf2-sha256$i=600000,l=32$NB8zDFPPtzoxMYJCHvl4P0$1Ly+JQBrozvQJVocdc5tbEJfF7PB//NnM6Jq7K5uyLE="
}
}
}
Submitting a login flow gives a 400 error.brief-egg-61061
01/27/2025, 12:53 PMbrief-egg-61061
01/27/2025, 12:53 PM$pbkdf2-sha256$i=600000,l=64$NB8zDFPPtzoxMYJCHvl4P0$1Ly+JQBrozvQJVocdc5tbEJfF7PB//NnM6Jq7K5uyLE=
The key difference here is the l=64
instead of l=32
. This is because the length parameter should represent the length of the hash in bytes, and for PBKDF2-SHA256, the output is typically 64 bytes when encoded in base64. Here's why this might be causing issues: 1. The format is very specific, and any deviation can cause validation errors. 2. The length parameter (l=64) should represent the length of the base64-encoded hash, not the raw byte length of the SHA-256 output. To update the identity, try using this format in your JSON payload: json { "credentials": { "password": { "config": { "hashed_password": "$pbkdf2-sha256$i=600000,l=64$NB8zDFPPtzoxMYJCHvl4P0$1Ly+JQBrozvQJVocdc5tbEJfF7PB//NnM6Jq7K5uyLE=" } } } }
If you're still encountering issues, it might be helpful to: 1. Double-check that the salt and hash parts are correctly base64-encoded. 2. Ensure that you're using the correct endpoint for updating the identity. 3. Verify that the identity exists and you have the necessary permissions to update it. If the problem persists, you might want to check the Ory Kratos logs for more detailed error messages, as they could provide more insight into why the login flow is resulting in a 400 error. [Ory Kratos API Reference](https://www.ory.sh/docs/kratos/reference/api) provides more details on the API endpoints and potential error responses, which might help in troubleshooting this issue further.brief-egg-61061
01/27/2025, 1:17 PMbrief-egg-61061
01/27/2025, 1:17 PM