@wtfalch/keys 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ pnpm test
|
|
|
22
22
|
|
|
23
23
|
## Security upgrade
|
|
24
24
|
|
|
25
|
-
Apply the additive `0004_keys_security.sql` migration in every consumer database before relying on the updated guards. All issuer processes must upgrade together for issuance/cascade serialization. See [the remediation and rollout notes](../../security/REMEDIATION.md).
|
|
25
|
+
Apply the additive `0004_keys_security.sql` migration in every consumer database before relying on the updated guards. A host that uses only the issued module (no `0002`/`0003` held tables) cannot apply `0004`; it applies `0009_keys_issued_guard.sql` instead, which carries `0004`'s issued-credential guard alone and is a no-op where `0004` already ran. All issuer processes must upgrade together for issuance/cascade serialization. See [the remediation and rollout notes](../../security/REMEDIATION.md).
|
|
26
26
|
|
|
27
27
|
New bearer secrets have a 32-character base32 tail (160 random bits). Existing 20-character tails remain accepted. Rotation refuses invalid stored signatures and returns `conflict` if the row changes during signing.
|
|
28
28
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
-- The issued-credential guard from 0004_keys_security.sql (K03), on its own.
|
|
2
|
+
-- Additive; do not edit copied migrations.
|
|
3
|
+
--
|
|
4
|
+
-- 0004 also changes triggers on keys_held_versions, so a host that uses only
|
|
5
|
+
-- the issued module (0001, 0005-0008, no 0002/0003) cannot apply it. Without
|
|
6
|
+
-- this file such a host has no guard: a revoked credential could be
|
|
7
|
+
-- un-revoked, or deleted and inserted again. The function body is 0005's, the
|
|
8
|
+
-- newest (it also freezes environment), so this needs 0005 first. The
|
|
9
|
+
-- triggers and the revoke are 0004's. Running it after 0004 and 0005 changes
|
|
10
|
+
-- nothing.
|
|
11
|
+
create or replace function public.keys_issued_guard() returns trigger
|
|
12
|
+
language plpgsql
|
|
13
|
+
set search_path = pg_catalog, public, pg_temp
|
|
14
|
+
as $$
|
|
15
|
+
begin
|
|
16
|
+
if tg_op in ('DELETE', 'TRUNCATE') then
|
|
17
|
+
raise exception 'keys_issued_credentials: delete and truncate refused';
|
|
18
|
+
end if;
|
|
19
|
+
if tg_op = 'UPDATE' then
|
|
20
|
+
if new.id is distinct from old.id or new.issued_by_id is distinct from old.issued_by_id
|
|
21
|
+
or new.key_prefix is distinct from old.key_prefix
|
|
22
|
+
or new.environment is distinct from old.environment then
|
|
23
|
+
raise exception 'keys_issued_credentials: identity, lineage and environment are immutable';
|
|
24
|
+
end if;
|
|
25
|
+
if old.revoked_at is not null and new.revoked_at is distinct from old.revoked_at then
|
|
26
|
+
raise exception 'keys_issued_credentials: revocation is permanent';
|
|
27
|
+
end if;
|
|
28
|
+
end if;
|
|
29
|
+
return new;
|
|
30
|
+
end
|
|
31
|
+
$$;
|
|
32
|
+
drop trigger if exists keys_issued_guard_update on public.keys_issued_credentials;
|
|
33
|
+
create trigger keys_issued_guard_update before update or delete on public.keys_issued_credentials
|
|
34
|
+
for each row execute function public.keys_issued_guard();
|
|
35
|
+
drop trigger if exists keys_issued_guard_truncate on public.keys_issued_credentials;
|
|
36
|
+
create trigger keys_issued_guard_truncate before truncate on public.keys_issued_credentials
|
|
37
|
+
for each statement execute function public.keys_issued_guard();
|
|
38
|
+
|
|
39
|
+
do $$
|
|
40
|
+
declare rt text := current_database() || '_rt';
|
|
41
|
+
begin
|
|
42
|
+
if exists (select 1 from pg_roles where rolname = rt) then
|
|
43
|
+
execute format('revoke delete, truncate on public.keys_issued_credentials from %I', rt);
|
|
44
|
+
end if;
|
|
45
|
+
end
|
|
46
|
+
$$;
|
package/package.json
CHANGED