mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: enable key rotation (#15066)
This PR contains the remaining logic necessary to hook up key rotation to the product.
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
-- Step 1: Remove the new entries from crypto_keys table
|
||||
DELETE FROM crypto_keys
|
||||
WHERE feature IN ('workspace_apps_token', 'workspace_apps_api_key');
|
||||
|
||||
CREATE TYPE old_crypto_key_feature AS ENUM (
|
||||
'workspace_apps',
|
||||
'oidc_convert',
|
||||
'tailnet_resume'
|
||||
);
|
||||
|
||||
ALTER TABLE crypto_keys
|
||||
ALTER COLUMN feature TYPE old_crypto_key_feature
|
||||
USING (feature::text::old_crypto_key_feature);
|
||||
|
||||
DROP TYPE crypto_key_feature;
|
||||
|
||||
ALTER TYPE old_crypto_key_feature RENAME TO crypto_key_feature;
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
-- Create a new enum type with the desired values
|
||||
CREATE TYPE new_crypto_key_feature AS ENUM (
|
||||
'workspace_apps_token',
|
||||
'workspace_apps_api_key',
|
||||
'oidc_convert',
|
||||
'tailnet_resume'
|
||||
);
|
||||
|
||||
DELETE FROM crypto_keys WHERE feature = 'workspace_apps';
|
||||
|
||||
-- Drop the old type and rename the new one
|
||||
ALTER TABLE crypto_keys
|
||||
ALTER COLUMN feature TYPE new_crypto_key_feature
|
||||
USING (feature::text::new_crypto_key_feature);
|
||||
|
||||
DROP TYPE crypto_key_feature;
|
||||
|
||||
ALTER TYPE new_crypto_key_feature RENAME TO crypto_key_feature;
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
INSERT INTO crypto_keys (feature, sequence, secret, secret_key_id, starts_at, deletes_at)
|
||||
VALUES (
|
||||
'workspace_apps_token',
|
||||
1,
|
||||
'abc',
|
||||
NULL,
|
||||
'1970-01-01 00:00:00 UTC'::timestamptz,
|
||||
'2100-01-01 00:00:00 UTC'::timestamptz
|
||||
);
|
||||
|
||||
INSERT INTO crypto_keys (feature, sequence, secret, secret_key_id, starts_at, deletes_at)
|
||||
VALUES (
|
||||
'workspace_apps_api_key',
|
||||
1,
|
||||
'def',
|
||||
NULL,
|
||||
'1970-01-01 00:00:00 UTC'::timestamptz,
|
||||
'2100-01-01 00:00:00 UTC'::timestamptz
|
||||
);
|
||||
|
||||
INSERT INTO crypto_keys (feature, sequence, secret, secret_key_id, starts_at, deletes_at)
|
||||
VALUES (
|
||||
'oidc_convert',
|
||||
2,
|
||||
'ghi',
|
||||
NULL,
|
||||
'1970-01-01 00:00:00 UTC'::timestamptz,
|
||||
'2100-01-01 00:00:00 UTC'::timestamptz
|
||||
);
|
||||
|
||||
INSERT INTO crypto_keys (feature, sequence, secret, secret_key_id, starts_at, deletes_at)
|
||||
VALUES (
|
||||
'tailnet_resume',
|
||||
2,
|
||||
'jkl',
|
||||
NULL,
|
||||
'1970-01-01 00:00:00 UTC'::timestamptz,
|
||||
'2100-01-01 00:00:00 UTC'::timestamptz
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user