Rehash credential during authentication if config has change (#234)

This commit is contained in:
Michael Gaffney authored and GitHub committed 2020-07-31 14:42:22 -04:00
1 parent 8f5c364bde
commit 5ceb335466
6 files changed
+209 -5

No files matched your search

@@ -184,6 +184,26 @@ begin;
end;
$$ language plpgsql;
-- update_auth_password_credential_subtype() is an after update trigger
-- function for subtypes of auth_password_credential
create or replace function
update_auth_password_credential_subtype()
returns trigger
as $$
begin
/*
The configuration id of a credential is updated when a credential is
rehashed during authentication.
*/
if new.password_conf_id is distinct from old.password_conf_id then
update auth_password_credential
set password_conf_id = new.password_conf_id
where private_id = new.private_id;
end if;
return null; -- result is ignored since this is an after trigger
end;
$$ language plpgsql;
--
-- triggers for time columns
--
@@ -75,6 +75,7 @@ begin;
references auth_password_credential (password_method_id, password_conf_id, password_account_id)
on delete cascade
on update cascade
deferrable initially deferred
);
create trigger
@@ -82,6 +83,11 @@ begin;
before insert on auth_password_argon2_cred
for each row execute procedure insert_auth_password_credential_subtype();
create trigger
update_auth_password_credential_subtype
after update on auth_password_argon2_cred
for each row execute procedure update_auth_password_credential_subtype();
--
-- triggers for time columns
--