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:
Michael Gaffney authored and GitHub committed 2020-07-29 07:58:19 -04:00
1 parent c3c07f1556
commit c163d790a4
23 files changed
+1613 -64

No files matched your search

@@ -5,7 +5,7 @@ begin;
┌────────────────┐ ┌──────────────────────┐ ┌────────────────────────────┐
│ auth_method │ │ auth_password_method │ │ auth_password_conf │
├────────────────┤ ├──────────────────────┤ ├────────────────────────────┤
│ public_id (pk) │ │ public_id (pk,fk) │ ╱│ public_id (pk,fk) │
│ public_id (pk) │ │ public_id (pk,fk) │ ╱│ private_id (pk,fk) │
│ scope_id (fk) │┼┼─────────────○┼│ scope_id (fk) │┼┼─────────○─│ password_method_id (fk) │
│ │ │ ... │ ╲│ │
└────────────────┘ └──────────────────────┘ └────────────────────────────┘
@@ -19,7 +19,7 @@ begin;
┌──────────────────────────┐ ┌──────────────────────────┐ ┌───────────────────────────────┐
│ auth_account │ │ auth_password_account │ │ auth_password_credential │
├──────────────────────────┤ ├──────────────────────────┤ ├───────────────────────────────┤
│ public_id (pk) │ │ public_id (pk,fk2) │ │ public_id (pk) │
│ public_id (pk) │ │ public_id (pk,fk2) │ │ private_id (pk) │
│ scope_id (fk1,fk2) │ ◀fk2 │ scope_id (fk1,fk2) │ ◀fk2 │ password_method_id (fk1,fk2) │
│ auth_method_id (fk1) │┼┼──────○┼│ auth_method_id (fk1,fk2) │┼┼──────○┼│ password_conf_id (fk1) │
│ iam_user_id (fk2) │ │ ... │ │ password_account_id (fk2) │
@@ -59,6 +59,7 @@ begin;
create table auth_password_method (
public_id wt_public_id primary key,
scope_id wt_scope_id not null,
password_conf_id wt_private_id not null, -- FK to auth_password_conf added below
name text,
description text,
create_time wt_timestamp,
@@ -114,15 +115,23 @@ begin;
for each row execute procedure insert_auth_account_subtype();
create table auth_password_conf (
public_id wt_public_id primary key,
private_id wt_private_id primary key,
password_method_id wt_public_id not null
references auth_password_method (public_id)
on delete cascade
on update cascade
deferrable initially deferred,
unique(password_method_id, public_id)
unique(password_method_id, private_id)
);
alter table auth_password_method
add constraint current_conf_fkey
foreign key (public_id, password_conf_id)
references auth_password_conf (password_method_id, private_id)
on delete cascade
on update cascade
deferrable initially deferred;
-- insert_auth_password_conf_subtype() is a trigger function for subtypes of
-- auth_password_conf
create or replace function
@@ -131,20 +140,20 @@ begin;
as $$
begin
insert into auth_password_conf
(public_id, password_method_id)
(private_id, password_method_id)
values
(new.public_id, new.password_method_id);
(new.private_id, new.password_method_id);
return new;
end;
$$ language plpgsql;
create table auth_password_credential (
public_id wt_public_id primary key,
private_id wt_private_id primary key,
password_account_id wt_public_id not null unique,
password_conf_id wt_public_id not null,
password_conf_id wt_private_id not null,
password_method_id wt_public_id not null,
foreign key (password_method_id, password_conf_id)
references auth_password_conf (password_method_id, public_id)
references auth_password_conf (password_method_id, private_id)
on delete cascade
on update cascade,
foreign key (password_method_id, password_account_id)
@@ -168,16 +177,16 @@ begin;
where auth_password_account.public_id = new.password_account_id;
insert into auth_password_credential
(public_id, password_account_id, password_conf_id, password_method_id)
(private_id, password_account_id, password_conf_id, password_method_id)
values
(new.public_id, new.password_account_id, new.password_conf_id, new.password_method_id);
(new.private_id, new.password_account_id, new.password_conf_id, new.password_method_id);
return new;
end;
$$ language plpgsql;
--
-- triggers for time columns
---
--
create trigger
update_time_column
@@ -215,7 +224,10 @@ begin;
insert on auth_password_account
for each row execute procedure default_create_time();
insert into oplog_ticket (name, version)
-- 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_method', 1),
('auth_password_account', 1);