Add configuration settings for Argon2 password KDF (#217)
* Bump generated proto code * Add argon2 conf sql and proto files * Add generated code for argon2 conf * Add Resources for Argon2 configuration * Add get and set Configuration to repository * Add current config reference to AuthMethod * Fix authmethod_test * Fix TestAccount_New * Add WithConfiguration to options * Add sql views for current configuration * Fix SetTableName * Remove duplicate testAccounts function * Make tests clearer * Fix comment * Rename test variable * Use NewPrivateId function for private Ids * Refactor: rename public_id to private_id for password_conf and password_credential * Remove bad comment * Check if embedded argon2 configuration is nil * Add checks around the WithConfiguration option * Use spaces not tabs in proto file * Add doc to explain choice of oplog ticket * Verify oplog in test
This commit is contained in:
1 parent
c3c07f1556
commit
c163d790a4
23 files changed
+1613
-64
No files matched your search
@@ -0,0 +1,75 @@
|
||||
begin;
|
||||
|
||||
create table auth_password_argon2_conf (
|
||||
private_id wt_private_id primary key
|
||||
references auth_password_conf (private_id)
|
||||
on delete cascade
|
||||
on update cascade,
|
||||
password_method_id wt_public_id not null,
|
||||
create_time wt_timestamp,
|
||||
iterations int not null default 3
|
||||
check(iterations > 0),
|
||||
memory int not null default 65536
|
||||
check(memory > 0),
|
||||
threads int not null default 1
|
||||
check(threads > 0),
|
||||
-- salt_length unit is bytes
|
||||
salt_length int not null default 32
|
||||
-- minimum of 16 bytes (128 bits)
|
||||
check(salt_length >= 16),
|
||||
-- key_length unit is bytes
|
||||
key_length int not null default 32
|
||||
-- minimum of 16 bytes (128 bits)
|
||||
check(key_length >= 16),
|
||||
unique(password_method_id, iterations, memory, threads, salt_length, key_length),
|
||||
unique (password_method_id, private_id),
|
||||
foreign key (password_method_id, private_id)
|
||||
references auth_password_conf (password_method_id, private_id)
|
||||
on delete cascade
|
||||
on update cascade
|
||||
deferrable initially deferred
|
||||
);
|
||||
create or replace function
|
||||
read_only_auth_password_argon2_conf()
|
||||
returns trigger
|
||||
as $$
|
||||
begin
|
||||
raise exception 'auth_password_argon2_conf is read-only';
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
create trigger
|
||||
read_only_auth_password_argon2_conf
|
||||
before
|
||||
update on auth_password_argon2_conf
|
||||
for each row execute procedure read_only_auth_password_argon2_conf();
|
||||
|
||||
create trigger
|
||||
insert_auth_password_conf_subtype
|
||||
before insert on auth_password_argon2_conf
|
||||
for each row execute procedure insert_auth_password_conf_subtype();
|
||||
|
||||
--
|
||||
-- triggers for time columns
|
||||
--
|
||||
create trigger
|
||||
immutable_create_time
|
||||
before
|
||||
update on auth_password_argon2_conf
|
||||
for each row execute procedure immutable_create_time_func();
|
||||
|
||||
create trigger
|
||||
default_create_time_column
|
||||
before
|
||||
insert on auth_password_argon2_conf
|
||||
for each row execute procedure default_create_time();
|
||||
|
||||
-- The tickets for oplog are the subtypes not the base types because no updates
|
||||
-- are done to any values in the base types.
|
||||
insert into oplog_ticket
|
||||
(name, version)
|
||||
values
|
||||
('auth_password_argon2_conf', 1),
|
||||
('auth_password_argon2_cred', 1);
|
||||
|
||||
commit;
|
||||
Reference in new issue
Block a user