Reimplemented access and refresh tokens.

This commit is contained in:
2026-10-18 13:21:48 +02:00
parent 4343959c74
commit 26999d690f
28 changed files with 1510 additions and 480 deletions
@@ -0,0 +1,93 @@
{
"db_name": "PostgreSQL",
"query": "\n\t\tINSERT INTO access_tokens (id, user_id, user_app_id, secret_hash, expires_at, issued_at)\n\t\tVALUES ($1, $2, $3, $4, $5, $6)\n\t\tRETURNING id, user_id, user_app_id, secret_hash, expires_at, issued_at\n\t\t",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id",
"type_info": "Uuid",
"origin": {
"Table": {
"table": "access_tokens",
"name": "id"
}
}
},
{
"ordinal": 1,
"name": "user_id",
"type_info": "Uuid",
"origin": {
"Table": {
"table": "access_tokens",
"name": "user_id"
}
}
},
{
"ordinal": 2,
"name": "user_app_id",
"type_info": "Uuid",
"origin": {
"Table": {
"table": "access_tokens",
"name": "user_app_id"
}
}
},
{
"ordinal": 3,
"name": "secret_hash",
"type_info": "Bytea",
"origin": {
"Table": {
"table": "access_tokens",
"name": "secret_hash"
}
}
},
{
"ordinal": 4,
"name": "expires_at",
"type_info": "Timestamptz",
"origin": {
"Table": {
"table": "access_tokens",
"name": "expires_at"
}
}
},
{
"ordinal": 5,
"name": "issued_at",
"type_info": "Timestamptz",
"origin": {
"Table": {
"table": "access_tokens",
"name": "issued_at"
}
}
}
],
"parameters": {
"Left": [
"Uuid",
"Uuid",
"Uuid",
"Bytea",
"Timestamptz",
"Timestamptz"
]
},
"nullable": [
false,
false,
true,
false,
false,
false
]
},
"hash": "0d7964d66f11a466461a5938ef1a0aa89ba9e99d8f22b06343ab27188233ec22"
}
@@ -0,0 +1,79 @@
{
"db_name": "PostgreSQL",
"query": "\n UPDATE refresh_tokens\n SET secret_hash = $2,\n expires_at = $3,\n issued_at = $4\n WHERE secret_hash = $1\n RETURNING id, access_token_id, secret_hash, expires_at, issued_at\n ",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id",
"type_info": "Uuid",
"origin": {
"Table": {
"table": "refresh_tokens",
"name": "id"
}
}
},
{
"ordinal": 1,
"name": "access_token_id",
"type_info": "Uuid",
"origin": {
"Table": {
"table": "refresh_tokens",
"name": "access_token_id"
}
}
},
{
"ordinal": 2,
"name": "secret_hash",
"type_info": "Bytea",
"origin": {
"Table": {
"table": "refresh_tokens",
"name": "secret_hash"
}
}
},
{
"ordinal": 3,
"name": "expires_at",
"type_info": "Timestamptz",
"origin": {
"Table": {
"table": "refresh_tokens",
"name": "expires_at"
}
}
},
{
"ordinal": 4,
"name": "issued_at",
"type_info": "Timestamptz",
"origin": {
"Table": {
"table": "refresh_tokens",
"name": "issued_at"
}
}
}
],
"parameters": {
"Left": [
"Bytea",
"Bytea",
"Timestamptz",
"Timestamptz"
]
},
"nullable": [
false,
false,
false,
false,
false
]
},
"hash": "4b8559a53ceed6a384e287d52dcb67edcae1bb076099c81637f2b882637419b7"
}
@@ -0,0 +1,88 @@
{
"db_name": "PostgreSQL",
"query": "\n SELECT\n id,\n user_id,\n user_app_id,\n secret_hash,\n expires_at,\n issued_at\n FROM access_tokens\n WHERE secret_hash = $1\n AND expires_at > now()\n ",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id",
"type_info": "Uuid",
"origin": {
"Table": {
"table": "access_tokens",
"name": "id"
}
}
},
{
"ordinal": 1,
"name": "user_id",
"type_info": "Uuid",
"origin": {
"Table": {
"table": "access_tokens",
"name": "user_id"
}
}
},
{
"ordinal": 2,
"name": "user_app_id",
"type_info": "Uuid",
"origin": {
"Table": {
"table": "access_tokens",
"name": "user_app_id"
}
}
},
{
"ordinal": 3,
"name": "secret_hash",
"type_info": "Bytea",
"origin": {
"Table": {
"table": "access_tokens",
"name": "secret_hash"
}
}
},
{
"ordinal": 4,
"name": "expires_at",
"type_info": "Timestamptz",
"origin": {
"Table": {
"table": "access_tokens",
"name": "expires_at"
}
}
},
{
"ordinal": 5,
"name": "issued_at",
"type_info": "Timestamptz",
"origin": {
"Table": {
"table": "access_tokens",
"name": "issued_at"
}
}
}
],
"parameters": {
"Left": [
"Bytea"
]
},
"nullable": [
false,
false,
true,
false,
false,
false
]
},
"hash": "50a9f81495657e35bedbf7fa3107f63c401aea690fdae95d74d03d86bdaa2a56"
}
@@ -0,0 +1,76 @@
{
"db_name": "PostgreSQL",
"query": "\n DELETE FROM refresh_tokens\n WHERE secret_hash = $1\n RETURNING id, access_token_id, secret_hash, expires_at, issued_at\n ",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id",
"type_info": "Uuid",
"origin": {
"Table": {
"table": "refresh_tokens",
"name": "id"
}
}
},
{
"ordinal": 1,
"name": "access_token_id",
"type_info": "Uuid",
"origin": {
"Table": {
"table": "refresh_tokens",
"name": "access_token_id"
}
}
},
{
"ordinal": 2,
"name": "secret_hash",
"type_info": "Bytea",
"origin": {
"Table": {
"table": "refresh_tokens",
"name": "secret_hash"
}
}
},
{
"ordinal": 3,
"name": "expires_at",
"type_info": "Timestamptz",
"origin": {
"Table": {
"table": "refresh_tokens",
"name": "expires_at"
}
}
},
{
"ordinal": 4,
"name": "issued_at",
"type_info": "Timestamptz",
"origin": {
"Table": {
"table": "refresh_tokens",
"name": "issued_at"
}
}
}
],
"parameters": {
"Left": [
"Bytea"
]
},
"nullable": [
false,
false,
false,
false,
false
]
},
"hash": "6262f385b10112a7d3cc98121c8ba104132c065ac1c1522c3dd80b4284faf1a1"
}
@@ -1,136 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "\n SELECT\n id,\n user_id,\n user_app_id,\n access_token_hash,\n refresh_token_hash,\n access_expires_at,\n refresh_expires_at,\n refreshed_at,\n revoked_at,\n created_at\n FROM tokens\n WHERE access_token_hash = $1\n AND access_expires_at > now()\n AND revoked_at IS NULL\n ",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id",
"type_info": "Uuid",
"origin": {
"Table": {
"table": "tokens",
"name": "id"
}
}
},
{
"ordinal": 1,
"name": "user_id",
"type_info": "Uuid",
"origin": {
"Table": {
"table": "tokens",
"name": "user_id"
}
}
},
{
"ordinal": 2,
"name": "user_app_id",
"type_info": "Uuid",
"origin": {
"Table": {
"table": "tokens",
"name": "user_app_id"
}
}
},
{
"ordinal": 3,
"name": "access_token_hash",
"type_info": "Bytea",
"origin": {
"Table": {
"table": "tokens",
"name": "access_token_hash"
}
}
},
{
"ordinal": 4,
"name": "refresh_token_hash",
"type_info": "Bytea",
"origin": {
"Table": {
"table": "tokens",
"name": "refresh_token_hash"
}
}
},
{
"ordinal": 5,
"name": "access_expires_at",
"type_info": "Timestamptz",
"origin": {
"Table": {
"table": "tokens",
"name": "access_expires_at"
}
}
},
{
"ordinal": 6,
"name": "refresh_expires_at",
"type_info": "Timestamptz",
"origin": {
"Table": {
"table": "tokens",
"name": "refresh_expires_at"
}
}
},
{
"ordinal": 7,
"name": "refreshed_at",
"type_info": "Timestamptz",
"origin": {
"Table": {
"table": "tokens",
"name": "refreshed_at"
}
}
},
{
"ordinal": 8,
"name": "revoked_at",
"type_info": "Timestamptz",
"origin": {
"Table": {
"table": "tokens",
"name": "revoked_at"
}
}
},
{
"ordinal": 9,
"name": "created_at",
"type_info": "Timestamptz",
"origin": {
"Table": {
"table": "tokens",
"name": "created_at"
}
}
}
],
"parameters": {
"Left": [
"Bytea"
]
},
"nullable": [
false,
false,
true,
false,
false,
false,
false,
true,
true,
false
]
},
"hash": "755b789df9d3d7f92243481e8fc8b724cae757c55579da8f86adb778eefdbc48"
}
@@ -1,23 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "\n INSERT INTO tokens (\n id,\n user_id,\n user_app_id,\n access_token_hash,\n refresh_token_hash,\n access_expires_at,\n refresh_expires_at,\n refreshed_at,\n revoked_at,\n created_at\n )\n VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)\n ",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Uuid",
"Uuid",
"Uuid",
"Bytea",
"Bytea",
"Timestamptz",
"Timestamptz",
"Timestamptz",
"Timestamptz",
"Timestamptz"
]
},
"nullable": []
},
"hash": "768ccffe4387ae725e2e2ab1f5544f7536d0b7c0c657aa87dc7539dcdbbc5014"
}
@@ -0,0 +1,76 @@
{
"db_name": "PostgreSQL",
"query": "\n SELECT\n id,\n access_token_id,\n secret_hash,\n expires_at,\n issued_at\n FROM refresh_tokens\n WHERE secret_hash = $1\n AND expires_at > now()\n ",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id",
"type_info": "Uuid",
"origin": {
"Table": {
"table": "refresh_tokens",
"name": "id"
}
}
},
{
"ordinal": 1,
"name": "access_token_id",
"type_info": "Uuid",
"origin": {
"Table": {
"table": "refresh_tokens",
"name": "access_token_id"
}
}
},
{
"ordinal": 2,
"name": "secret_hash",
"type_info": "Bytea",
"origin": {
"Table": {
"table": "refresh_tokens",
"name": "secret_hash"
}
}
},
{
"ordinal": 3,
"name": "expires_at",
"type_info": "Timestamptz",
"origin": {
"Table": {
"table": "refresh_tokens",
"name": "expires_at"
}
}
},
{
"ordinal": 4,
"name": "issued_at",
"type_info": "Timestamptz",
"origin": {
"Table": {
"table": "refresh_tokens",
"name": "issued_at"
}
}
}
],
"parameters": {
"Left": [
"Bytea"
]
},
"nullable": [
false,
false,
false,
false,
false
]
},
"hash": "8a5728429d71470fc276d2572f9b36d316eca63173b1463d5b3bed3e08d7ab19"
}
@@ -1,14 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "\n UPDATE tokens\n SET revoked_at = COALESCE(revoked_at, now())\n WHERE access_token_hash = $1 OR refresh_token_hash = $1\n ",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Bytea"
]
},
"nullable": []
},
"hash": "9f8fc6351a1261dcb91eb6f2bfe182a94adf1952a800371e668aeab6897c94c5"
}
@@ -0,0 +1,80 @@
{
"db_name": "PostgreSQL",
"query": "\n\t\tINSERT INTO refresh_tokens (id, access_token_id, secret_hash, expires_at, issued_at)\n\t\tVALUES ($1, $2, $3, $4, $5)\n\t\tRETURNING id, access_token_id, secret_hash, expires_at, issued_at\n\t\t",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id",
"type_info": "Uuid",
"origin": {
"Table": {
"table": "refresh_tokens",
"name": "id"
}
}
},
{
"ordinal": 1,
"name": "access_token_id",
"type_info": "Uuid",
"origin": {
"Table": {
"table": "refresh_tokens",
"name": "access_token_id"
}
}
},
{
"ordinal": 2,
"name": "secret_hash",
"type_info": "Bytea",
"origin": {
"Table": {
"table": "refresh_tokens",
"name": "secret_hash"
}
}
},
{
"ordinal": 3,
"name": "expires_at",
"type_info": "Timestamptz",
"origin": {
"Table": {
"table": "refresh_tokens",
"name": "expires_at"
}
}
},
{
"ordinal": 4,
"name": "issued_at",
"type_info": "Timestamptz",
"origin": {
"Table": {
"table": "refresh_tokens",
"name": "issued_at"
}
}
}
],
"parameters": {
"Left": [
"Uuid",
"Uuid",
"Bytea",
"Timestamptz",
"Timestamptz"
]
},
"nullable": [
false,
false,
false,
false,
false
]
},
"hash": "a1d81c17935a785a1001ee0673e1bbb02a64b5743406428dd18f8199ad8fb77b"
}
@@ -0,0 +1,88 @@
{
"db_name": "PostgreSQL",
"query": "\n SELECT\n a.id,\n a.user_id,\n a.user_app_id,\n a.secret_hash,\n a.expires_at,\n a.issued_at\n FROM access_tokens a\n JOIN refresh_tokens r ON r.access_token_id = a.id\n WHERE r.secret_hash = $1\n AND r.expires_at > now()\n ",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id",
"type_info": "Uuid",
"origin": {
"Table": {
"table": "access_tokens",
"name": "id"
}
}
},
{
"ordinal": 1,
"name": "user_id",
"type_info": "Uuid",
"origin": {
"Table": {
"table": "access_tokens",
"name": "user_id"
}
}
},
{
"ordinal": 2,
"name": "user_app_id",
"type_info": "Uuid",
"origin": {
"Table": {
"table": "access_tokens",
"name": "user_app_id"
}
}
},
{
"ordinal": 3,
"name": "secret_hash",
"type_info": "Bytea",
"origin": {
"Table": {
"table": "access_tokens",
"name": "secret_hash"
}
}
},
{
"ordinal": 4,
"name": "expires_at",
"type_info": "Timestamptz",
"origin": {
"Table": {
"table": "access_tokens",
"name": "expires_at"
}
}
},
{
"ordinal": 5,
"name": "issued_at",
"type_info": "Timestamptz",
"origin": {
"Table": {
"table": "access_tokens",
"name": "issued_at"
}
}
}
],
"parameters": {
"Left": [
"Bytea"
]
},
"nullable": [
false,
false,
true,
false,
false,
false
]
},
"hash": "e5c0bc537264fb01e0eaca622ccac4f7b0ee2940954d7e902e6952488b9cb18a"
}
@@ -0,0 +1,91 @@
{
"db_name": "PostgreSQL",
"query": "\n UPDATE access_tokens\n SET secret_hash = $2,\n expires_at = $3,\n issued_at = $4\n WHERE secret_hash = $1\n RETURNING id, user_id, user_app_id, secret_hash, expires_at, issued_at\n ",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id",
"type_info": "Uuid",
"origin": {
"Table": {
"table": "access_tokens",
"name": "id"
}
}
},
{
"ordinal": 1,
"name": "user_id",
"type_info": "Uuid",
"origin": {
"Table": {
"table": "access_tokens",
"name": "user_id"
}
}
},
{
"ordinal": 2,
"name": "user_app_id",
"type_info": "Uuid",
"origin": {
"Table": {
"table": "access_tokens",
"name": "user_app_id"
}
}
},
{
"ordinal": 3,
"name": "secret_hash",
"type_info": "Bytea",
"origin": {
"Table": {
"table": "access_tokens",
"name": "secret_hash"
}
}
},
{
"ordinal": 4,
"name": "expires_at",
"type_info": "Timestamptz",
"origin": {
"Table": {
"table": "access_tokens",
"name": "expires_at"
}
}
},
{
"ordinal": 5,
"name": "issued_at",
"type_info": "Timestamptz",
"origin": {
"Table": {
"table": "access_tokens",
"name": "issued_at"
}
}
}
],
"parameters": {
"Left": [
"Bytea",
"Bytea",
"Timestamptz",
"Timestamptz"
]
},
"nullable": [
false,
false,
true,
false,
false,
false
]
},
"hash": "e9ab22c5b968148c8b1eeb03a120863e865e799bd347d84885e563e7761d2e06"
}
@@ -0,0 +1,88 @@
{
"db_name": "PostgreSQL",
"query": "\n DELETE FROM access_tokens\n WHERE secret_hash = $1\n RETURNING id, user_id, user_app_id, secret_hash, expires_at, issued_at\n ",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id",
"type_info": "Uuid",
"origin": {
"Table": {
"table": "access_tokens",
"name": "id"
}
}
},
{
"ordinal": 1,
"name": "user_id",
"type_info": "Uuid",
"origin": {
"Table": {
"table": "access_tokens",
"name": "user_id"
}
}
},
{
"ordinal": 2,
"name": "user_app_id",
"type_info": "Uuid",
"origin": {
"Table": {
"table": "access_tokens",
"name": "user_app_id"
}
}
},
{
"ordinal": 3,
"name": "secret_hash",
"type_info": "Bytea",
"origin": {
"Table": {
"table": "access_tokens",
"name": "secret_hash"
}
}
},
{
"ordinal": 4,
"name": "expires_at",
"type_info": "Timestamptz",
"origin": {
"Table": {
"table": "access_tokens",
"name": "expires_at"
}
}
},
{
"ordinal": 5,
"name": "issued_at",
"type_info": "Timestamptz",
"origin": {
"Table": {
"table": "access_tokens",
"name": "issued_at"
}
}
}
],
"parameters": {
"Left": [
"Bytea"
]
},
"nullable": [
false,
false,
true,
false,
false,
false
]
},
"hash": "f052080688bdab0724707575aa61dfccde168a6ce21992c556938940f8f49b91"
}
@@ -1,32 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "\n UPDATE tokens\n SET access_token_hash = $2,\n refresh_token_hash = $3,\n access_expires_at = $4,\n refresh_expires_at = $5,\n refreshed_at = now()\n WHERE refresh_token_hash = $1\n AND revoked_at IS NULL\n AND refresh_expires_at > now()\n RETURNING id\n ",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id",
"type_info": "Uuid",
"origin": {
"Table": {
"table": "tokens",
"name": "id"
}
}
}
],
"parameters": {
"Left": [
"Bytea",
"Bytea",
"Bytea",
"Timestamptz",
"Timestamptz"
]
},
"nullable": [
false
]
},
"hash": "f90d488ec2fff2e09bfbc83c287313aaeaa275cf6e41272347821735d4b401d6"
}