diff --git a/server/.sqlx/query-3fcfa5b534e0ad39d2daecd9654ed22c38da844dbe7044cafc683bbcacb79d7a.json b/server/.sqlx/query-3fcfa5b534e0ad39d2daecd9654ed22c38da844dbe7044cafc683bbcacb79d7a.json deleted file mode 100644 index 6317db8..0000000 --- a/server/.sqlx/query-3fcfa5b534e0ad39d2daecd9654ed22c38da844dbe7044cafc683bbcacb79d7a.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n INSERT INTO tokens (\n id, app_id, access_token_hash, refresh_token_hash,\n access_expires_at, refresh_expires_at, revoked_at, created_at\n )\n VALUES ($1, $2, $3, $4, $5, $6, $7, $8)\n ", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Uuid", - "Uuid", - "Bytea", - "Bytea", - "Timestamptz", - "Timestamptz", - "Timestamptz", - "Timestamptz" - ] - }, - "nullable": [] - }, - "hash": "3fcfa5b534e0ad39d2daecd9654ed22c38da844dbe7044cafc683bbcacb79d7a" -} diff --git a/server/.sqlx/query-409368e6023d0e957be632a7d65879c75e1006af498c355a6ac8e5a6144a9dd0.json b/server/.sqlx/query-409368e6023d0e957be632a7d65879c75e1006af498c355a6ac8e5a6144a9dd0.json new file mode 100644 index 0000000..ea9d68c --- /dev/null +++ b/server/.sqlx/query-409368e6023d0e957be632a7d65879c75e1006af498c355a6ac8e5a6144a9dd0.json @@ -0,0 +1,20 @@ +{ + "db_name": "PostgreSQL", + "query": "\n INSERT INTO tokens (\n id, access_token_hash, refresh_token_hash,\n access_expires_at, refresh_expires_at, revoked_at, created_at\n )\n VALUES ($1, $2, $3, $4, $5, $6, $7)\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Bytea", + "Bytea", + "Timestamptz", + "Timestamptz", + "Timestamptz", + "Timestamptz" + ] + }, + "nullable": [] + }, + "hash": "409368e6023d0e957be632a7d65879c75e1006af498c355a6ac8e5a6144a9dd0" +} diff --git a/server/migrations/20261007000002_create_tokens.sql b/server/migrations/20261007000002_create_tokens.sql index 08824de..4ae1b0f 100644 --- a/server/migrations/20261007000002_create_tokens.sql +++ b/server/migrations/20261007000002_create_tokens.sql @@ -1,6 +1,5 @@ CREATE TABLE tokens ( id UUID PRIMARY KEY DEFAULT gen_random_uuid (), - app_id UUID NOT NULL CONSTRAINT fk_tokens_app REFERENCES user_apps (id) ON DELETE CASCADE, access_token_hash BYTEA NOT NULL UNIQUE CHECK ( octet_length(access_token_hash) = 32 ), diff --git a/server/src/database/dtos/token.rs b/server/src/database/dtos/token.rs index 96ac13a..6a7d04e 100644 --- a/server/src/database/dtos/token.rs +++ b/server/src/database/dtos/token.rs @@ -3,7 +3,6 @@ use uuid::Uuid; pub struct TokenRow { pub id: Uuid, - pub app_id: Uuid, pub access_token_hash: Vec, pub refresh_token_hash: Vec, pub access_expires_at: DateTime, diff --git a/server/src/database/tokens.rs b/server/src/database/tokens.rs index 8f20500..cf16261 100644 --- a/server/src/database/tokens.rs +++ b/server/src/database/tokens.rs @@ -9,13 +9,12 @@ where sqlx::query!( r#" INSERT INTO tokens ( - id, app_id, access_token_hash, refresh_token_hash, + id, access_token_hash, refresh_token_hash, access_expires_at, refresh_expires_at, revoked_at, created_at ) - VALUES ($1, $2, $3, $4, $5, $6, $7, $8) + VALUES ($1, $2, $3, $4, $5, $6, $7) "#, token.id, - token.app_id, token.access_token_hash, token.refresh_token_hash, token.access_expires_at, diff --git a/server/src/domain/token.rs b/server/src/domain/token.rs index 58581ea..d5d1679 100644 --- a/server/src/domain/token.rs +++ b/server/src/domain/token.rs @@ -4,7 +4,6 @@ use uuid::Uuid; #[derive(Clone, PartialEq, Eq)] pub struct Token { pub id: Uuid, - pub app_id: Uuid, pub access_token_hash: Vec, pub refresh_token_hash: Vec, pub access_expires_at: DateTime, diff --git a/server/src/repository/tokens.rs b/server/src/repository/tokens.rs index 965f49c..6e10c09 100644 --- a/server/src/repository/tokens.rs +++ b/server/src/repository/tokens.rs @@ -45,7 +45,6 @@ where fn encode(token: Token) -> TokenRow { TokenRow { id: token.id, - app_id: token.app_id, access_token_hash: token.access_token_hash, refresh_token_hash: token.refresh_token_hash, access_expires_at: token.access_expires_at, diff --git a/server/src/routes/auth_token.rs b/server/src/routes/auth_token.rs index f990618..01596ed 100644 --- a/server/src/routes/auth_token.rs +++ b/server/src/routes/auth_token.rs @@ -40,7 +40,7 @@ async fn issue_token( } let generated = generate_token_pair()?; - repository::tokens::issue(&pool, token(client_id, &generated)).await?; + repository::tokens::issue(&pool, token(&generated)).await?; Ok(Json(token_response( generated.access_token, @@ -110,10 +110,9 @@ fn generate_token_pair() -> Result { }) } -fn token(app_id: Uuid, generated: &GeneratedTokenPair) -> Token { +fn token(generated: &GeneratedTokenPair) -> Token { Token { id: Uuid::new_v4(), - app_id, access_token_hash: generated.access_token_hash.clone(), refresh_token_hash: generated.refresh_token_hash.clone(), access_expires_at: generated.access_expires_at,