OXYGENHUB
# 8a3334b7a364 oxygenhub / crates / hub / migrations / 0027_device_codes.sql
781 B · SQL · last changed Device sign-in: approve an app's code on the web, the app gets a scoped token (closes #67) 1 month ago source blame history raw
1
-- Device sign-in (oxygenhub#67, RFC 8628 in shape): an app holds the
2
-- device code (stored as its hash) and polls; the user approves the user
3
-- code on the web, choosing the scopes; the token is made when the app
4
-- next polls, so no token is stored in the clear.
5
CREATE TABLE device_codes (
6
    id              INTEGER PRIMARY KEY,
7
    device_hash     TEXT NOT NULL UNIQUE,
8
    user_code       TEXT NOT NULL UNIQUE,
9
    client          TEXT NOT NULL,
10
    scopes          TEXT NOT NULL,
11
    created_ms      INTEGER NOT NULL,
12
    expires_ms      INTEGER NOT NULL,
13
    last_poll_ms    INTEGER NOT NULL DEFAULT 0,
14
    account_id      INTEGER REFERENCES accounts(id) ON DELETE CASCADE,
15
    approved_scopes TEXT NOT NULL DEFAULT '',
16
    denied          INTEGER NOT NULL DEFAULT 0
17
);