Add account ID templating (#518)

* Remove default role and create via the same mechanism as other initial resources
This commit is contained in:
Jeff Mitchell authored and GitHub committed 2020-10-01 10:51:54 -04:00
1 parent 19aecfefae
commit fa700dc002
24 files changed
+291 -142

No files matched your search

@@ -33,10 +33,10 @@ comment on domain wt_scope_id is
create domain wt_role_id as text
not null
check(
length(trim(value)) > 10 or value = 'r_default'
length(trim(value)) > 10
);
comment on domain wt_scope_id is
'"r_default", or random ID generated with github.com/hashicorp/vault/sdk/helper/base62';
'Random ID generated with github.com/hashicorp/vault/sdk/helper/base62';
create domain wt_timestamp as
timestamp with time zone
@@ -427,24 +427,6 @@ before
insert on iam_role_grant
for each row execute procedure default_create_time();
create or replace function
disallow_r_default_deletion()
returns trigger
as $$
begin
if old.public_id = 'r_default' then
raise exception 'deletion of r_default not allowed';
end if;
return old;
end;
$$ language plpgsql;
create trigger
iam_role_disallow_global_deletion
before
delete on iam_role
for each row execute procedure disallow_r_default_deletion();
create trigger
update_version_column
after update on iam_role
@@ -581,16 +563,6 @@ begin
end;
$$ language plpgsql;
insert into iam_role (public_id, name, description, scope_id)
values('r_default', 'Default Grants', 'Default role created on first instantiation of Boundary. It is meant to provide enough permissions for users to successfully authenticate via various client types.', 'global');
insert into iam_role_grant (role_id, canonical_grant, raw_grant)
values
('r_default', 'type=scope;actions=list', 'type=scope;actions=list'),
('r_default', 'id=*;type=auth-method;actions=authenticate,list', 'id=*;type=auth-method;actions=authenticate,list');
insert into iam_user_role (role_id, principal_id)
values
('r_default', 'u_anon');
-- iam_principle_role provides a consolidated view all principal roles assigned
-- (user and group roles).
create view iam_principal_role as