mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-05 15:44:28 +00:00
feat(api-token): store API tokens as SHA-256 hashes (#492)
New tokens are 32 random bytes with a shumai_ prefix and are returned only once at creation. The list endpoint returns a 4-character hint instead of the plaintext. A migration hashes existing tokens in place so they keep authenticating.
This commit is contained in:
@@ -1089,7 +1089,10 @@ model Collection {
|
||||
|
||||
model ApiToken {
|
||||
id String @id @default(ulid())
|
||||
token String @unique @default(ulid())
|
||||
/// SHA-256 hex digest of the plaintext token. The plaintext is never stored.
|
||||
tokenHash String @unique @map("token_hash")
|
||||
/// Last characters of the plaintext token, shown in the UI to identify it.
|
||||
tokenHint String @map("token_hint")
|
||||
name String
|
||||
userId String @map("user_id")
|
||||
user User @relation("UserToApiToken", fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
Reference in New Issue
Block a user