865 BRaw
| 1 | -- Personal access tokens: the credential a git client presents over HTTP Basic. |
| 2 | -- |
| 3 | -- Only the SHA-256 of a token is stored, so a dumped database contains nothing anyone |
| 4 | -- could present. `prefix` is the first eight characters kept in the clear, which is what |
| 5 | -- lets a management UI name a token it can no longer show. |
| 6 | -- |
| 7 | -- Indexed by hash because that is the lookup authentication performs: a client presents |
| 8 | -- the token itself, never its id. Revocation deletes the row rather than flagging it, so |
| 9 | -- there is no flag a future read can forget to check. |
| 10 | create table tokens ( |
| 11 | id text primary key, |
| 12 | user_id text not null references users (id) on delete cascade, |
| 13 | name text not null, |
| 14 | prefix text not null, |
| 15 | token_hash text not null unique, |
| 16 | created_at integer not null |
| 17 | ); |
| 18 | |
| 19 | create index tokens_user_id on tokens (user_id); |