mirror of
https://github.com/coder/coder.git
synced 2026-06-03 04:58:23 +00:00
170c33a475
Adds an optional dbcrypt wrapper around gitsshkeys.private_key. The column is encrypted on insert and update through enterprise/dbcrypt when external token encryption is configured, and decrypted on read. A new private_key_key_id column references dbcrypt_keys(active_key_digest) so revocation safety is enforced by the existing foreign key. Rows with a NULL key_id stay plaintext and remain readable. Existing plaintext rows can be backfilled by running `coder server dbcrypt rotate`. Generated with assistance from Coder Agents.
34 lines
438 B
SQL
34 lines
438 B
SQL
-- name: InsertGitSSHKey :one
|
|
INSERT INTO
|
|
gitsshkeys (
|
|
user_id,
|
|
created_at,
|
|
updated_at,
|
|
private_key,
|
|
private_key_key_id,
|
|
public_key
|
|
)
|
|
VALUES
|
|
($1, $2, $3, $4, $5, $6) RETURNING *;
|
|
|
|
-- name: GetGitSSHKey :one
|
|
SELECT
|
|
*
|
|
FROM
|
|
gitsshkeys
|
|
WHERE
|
|
user_id = $1;
|
|
|
|
-- name: UpdateGitSSHKey :one
|
|
UPDATE
|
|
gitsshkeys
|
|
SET
|
|
updated_at = $2,
|
|
private_key = $3,
|
|
private_key_key_id = $4,
|
|
public_key = $5
|
|
WHERE
|
|
user_id = $1
|
|
RETURNING
|
|
*;
|