-
-
Notifications
You must be signed in to change notification settings - Fork 475
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core,schemas): add support for argon2d and argon2id (#6404)
- Loading branch information
Showing
5 changed files
with
88 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
"@logto/schemas": minor | ||
"@logto/core": minor | ||
--- | ||
|
||
add support for new password digest algorithm argon2d and argon2id | ||
|
||
In `POST /users`, the `passwordAlgorithm` field now accepts `Argon2d` and `Argon2id`. | ||
|
||
Users with those algorithms will be migrated to `Argon2i` upon succussful sign in. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
packages/schemas/alterations/next-1722926389-argon2d-argon2id.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { sql } from '@silverhand/slonik'; | ||
|
||
import type { AlterationScript } from '../lib/types/alteration.js'; | ||
|
||
const alteration: AlterationScript = { | ||
up: async (pool) => { | ||
await pool.query(sql` | ||
alter type users_password_encryption_method add value 'Argon2id'; | ||
alter type users_password_encryption_method add value 'Argon2d'; | ||
`); | ||
}, | ||
down: async (pool) => { | ||
const { rows } = await pool.query(sql` | ||
select id from users | ||
where password_encryption_method = ${'Argon2id'} | ||
or password_encryption_method = ${'Argon2d'} | ||
`); | ||
if (rows.length > 0) { | ||
throw new Error('There are users with password encryption methods Argon2id or Argon2d.'); | ||
} | ||
|
||
await pool.query(sql` | ||
create type users_password_encryption_method_revised as enum ('Argon2i', 'SHA1', 'SHA256', 'MD5', 'Bcrypt'); | ||
alter table users | ||
alter column password_encryption_method type users_password_encryption_method_revised | ||
using password_encryption_method::text::users_password_encryption_method_revised; | ||
drop type users_password_encryption_method; | ||
alter type users_password_encryption_method_revised rename to users_password_encryption_method; | ||
`); | ||
}, | ||
}; | ||
|
||
export default alteration; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters