SPB Git

Repository Public

003_verifications.sql 1.1 KB 20 lines sql

1-- Vérification de numéro par code à usage unique (authentification par SMS pour les applications clientes).2-- Le code n'est jamais stocké : seulement son empreinte HMAC. Le SMS qui le transporte est marqué « sensible ».3alter table messages add column sensitive boolean not null default false;45create table verifications (6  id              text primary key,7  application_id  text not null references applications(id) on delete cascade,8  to_number       text not null,9  code_hash       text not null,10  status          text not null default 'pending' check (status in ('pending', 'approved', 'failed', 'expired', 'cancelled')),11  attempts        integer not null default 0,12  max_attempts    integer not null default 5,13  message_id      text references messages(id) on delete set null,14  created_at      timestamptz not null default now(),15  expires_at      timestamptz not null,16  approved_at     timestamptz17);18create index verifications_recent on verifications(application_id, to_number, created_at desc);19create index verifications_pending on verifications(expires_at) where status = 'pending';20
Files main
Menu

Theme