feat(wh): Support vault ssh certificate credentials
This expands the wh_credential_dimension to include fields for the new vault ssh certificate credential library.
This commit is contained in:
11 files changed
+525
-75
No files matched your search
@@ -65,6 +65,7 @@ begin;
|
||||
and o.public_id = p.parent_id
|
||||
and o.type = 'org';
|
||||
|
||||
-- Replaced in 63/03_wh_ssh_cert_library.up.sql
|
||||
create view whx_credential_dimension_target as
|
||||
select key,
|
||||
credential_purpose,
|
||||
|
||||
@@ -4,6 +4,7 @@ begin;
|
||||
-- with the current values in the operational tables for the given parameters. IF the values
|
||||
-- between operational tables and the wh_credential_dimension differ, a new row is inserted in
|
||||
-- the wh_credential_dimension to match the current values in the operational tables.
|
||||
-- Replaced in 63/03_wh_ssh_cert_library.up.sql
|
||||
create function wh_upsert_credential_dimension(p_session_id wt_public_id, p_library_id wt_public_id, p_credential_purpose wh_dim_text) returns wh_dim_key
|
||||
as $$
|
||||
declare
|
||||
|
||||
@@ -157,6 +157,7 @@ begin;
|
||||
-- The whx_credential_dimension_source view shows the current values in the
|
||||
-- operational tables of the credential dimension.
|
||||
-- Replaces whx_credential_dimension_source defined in 16/02_wh_credential_dimension.up.sql
|
||||
-- Replaced in 63/03_wh_ssh_cert_library.up.sql
|
||||
drop view whx_credential_dimension_source;
|
||||
create view whx_credential_dimension_source as
|
||||
select -- id is the first column in the target view
|
||||
|
||||
@@ -0,0 +1,254 @@
|
||||
begin;
|
||||
alter table wh_credential_dimension
|
||||
add column credential_library_username text,
|
||||
add column credential_library_key_type_and_bits text
|
||||
;
|
||||
|
||||
update wh_credential_dimension set
|
||||
credential_library_username = 'Not Applicable',
|
||||
credential_library_key_type_and_bits = 'Not Applicable';
|
||||
|
||||
update wh_credential_dimension set
|
||||
credential_library_vault_http_request_body = 'Not Applicable'
|
||||
where
|
||||
credential_library_vault_http_method = 'GET'
|
||||
and
|
||||
credential_library_vault_http_request_body = 'None';
|
||||
|
||||
|
||||
alter table wh_credential_dimension
|
||||
alter column credential_library_username type wh_dim_text,
|
||||
alter column credential_library_key_type_and_bits type wh_dim_text
|
||||
;
|
||||
|
||||
update wh_credential_dimension set
|
||||
credential_library_type = 'vault generic credential library'
|
||||
where
|
||||
credential_library_type = 'vault credential library';
|
||||
|
||||
-- The whx_credential_dimension_source view shows the current values in the
|
||||
-- operational tables of the credential dimension.
|
||||
-- Replaces whx_credential_dimension_source defined in 44/03_targets.up.sql
|
||||
drop view whx_credential_dimension_source;
|
||||
create view whx_credential_dimension_source as
|
||||
with vault_generic_library as (
|
||||
select vcl.public_id as public_id,
|
||||
'vault generic credential library' as type,
|
||||
coalesce(vcl.name, 'None') as name,
|
||||
coalesce(vcl.description, 'None') as description,
|
||||
vcl.vault_path as vault_path,
|
||||
vcl.http_method as http_method,
|
||||
case
|
||||
when vcl.http_method = 'GET' then 'Not Applicable'
|
||||
else coalesce(vcl.http_request_body::text, 'None')
|
||||
end as http_request_body,
|
||||
'Not Applicable' as username,
|
||||
'Not Applicable' as key_type_and_bits
|
||||
from credential_vault_library as vcl
|
||||
),
|
||||
vault_ssh_cert_library as (
|
||||
select vsccl.public_id as public_id,
|
||||
'vault ssh certificate credential library' as type,
|
||||
coalesce(vsccl.name, 'None') as name,
|
||||
coalesce(vsccl.description, 'None') as description,
|
||||
vsccl.vault_path as vault_path,
|
||||
'Not Applicable' as http_method,
|
||||
'Not Applicable' as http_request_body,
|
||||
vsccl.username as username,
|
||||
case
|
||||
when vsccl.key_type = 'ed25519' then vsccl.key_type
|
||||
else vsccl.key_type || '-' || vsccl.key_bits::text
|
||||
end as key_type_and_bits
|
||||
from credential_vault_ssh_cert_library as vsccl
|
||||
),
|
||||
final as (
|
||||
select s.public_id as session_id,
|
||||
scd.credential_purpose as credential_purpose,
|
||||
cl.public_id as credential_library_id,
|
||||
coalesce(vcl.type, vsccl.type) as credential_library_type,
|
||||
coalesce(vcl.name, vsccl.name) as credential_library_name,
|
||||
coalesce(vcl.description, vsccl.description) as credential_library_description,
|
||||
coalesce(vcl.vault_path, vsccl.vault_path) as credential_library_vault_path,
|
||||
coalesce(vcl.http_method, vsccl.http_method) as credential_library_vault_http_method,
|
||||
coalesce(vcl.http_request_body, vsccl.http_request_body) as credential_library_vault_http_request_body,
|
||||
coalesce(vcl.username, vsccl.username) as credential_library_username,
|
||||
coalesce(vcl.key_type_and_bits, vsccl.key_type_and_bits) as credential_library_key_type_and_bits,
|
||||
cs.public_id as credential_store_id,
|
||||
case
|
||||
when vcs is null then 'None'
|
||||
else 'vault credential store'
|
||||
end as credential_store_type,
|
||||
coalesce(vcs.name, 'None') as credential_store_name,
|
||||
coalesce(vcs.description, 'None') as credential_store_description,
|
||||
coalesce(vcs.namespace, 'None') as credential_store_vault_namespace,
|
||||
coalesce(vcs.vault_address, 'None') as credential_store_vault_address,
|
||||
t.public_id as target_id,
|
||||
'tcp target' as target_type,
|
||||
coalesce(tt.name, 'None') as target_name,
|
||||
coalesce(tt.description, 'None') as target_description,
|
||||
coalesce(tt.default_port, 0) as target_default_port_number,
|
||||
tt.session_max_seconds as target_session_max_seconds,
|
||||
tt.session_connection_limit as target_session_connection_limit,
|
||||
p.public_id as project_id,
|
||||
coalesce(p.name, 'None') as project_name,
|
||||
coalesce(p.description, 'None') as project_description,
|
||||
o.public_id as organization_id,
|
||||
coalesce(o.name, 'None') as organization_name,
|
||||
coalesce(o.description, 'None') as organization_description
|
||||
from session_credential_dynamic as scd
|
||||
join session as s on scd.session_id = s.public_id
|
||||
join credential_library as cl on scd.library_id = cl.public_id
|
||||
join credential_store as cs on cl.store_id = cs.public_id
|
||||
join target as t on s.target_id = t.public_id
|
||||
join iam_scope as p on p.public_id = t.project_id and p.type = 'project'
|
||||
join iam_scope as o on p.parent_id = o.public_id and o.type = 'org'
|
||||
left join vault_generic_library as vcl on cl.public_id = vcl.public_id
|
||||
left join vault_ssh_cert_library as vsccl on cl.public_id = vsccl.public_id
|
||||
left join credential_vault_store as vcs on cs.public_id = vcs.public_id
|
||||
left join target_tcp as tt on t.public_id = tt.public_id
|
||||
)
|
||||
select session_id,
|
||||
credential_purpose,
|
||||
credential_library_id,
|
||||
credential_library_type,
|
||||
credential_library_name,
|
||||
credential_library_description,
|
||||
credential_library_vault_path,
|
||||
credential_library_vault_http_method,
|
||||
credential_library_vault_http_request_body,
|
||||
credential_library_username,
|
||||
credential_library_key_type_and_bits,
|
||||
credential_store_id,
|
||||
credential_store_type,
|
||||
credential_store_name,
|
||||
credential_store_description,
|
||||
credential_store_vault_namespace,
|
||||
credential_store_vault_address,
|
||||
target_id,
|
||||
target_type,
|
||||
target_name,
|
||||
target_description,
|
||||
target_default_port_number,
|
||||
target_session_max_seconds,
|
||||
target_session_connection_limit,
|
||||
project_id,
|
||||
project_name,
|
||||
project_description,
|
||||
organization_id,
|
||||
organization_name,
|
||||
organization_description
|
||||
from final;
|
||||
|
||||
-- Replaces view in 16/02_wh_credential_dimension.up.sql
|
||||
drop view whx_credential_dimension_target;
|
||||
create view whx_credential_dimension_target as
|
||||
select key,
|
||||
credential_purpose,
|
||||
credential_library_id,
|
||||
credential_library_type,
|
||||
credential_library_name,
|
||||
credential_library_description,
|
||||
credential_library_vault_path,
|
||||
credential_library_vault_http_method,
|
||||
credential_library_vault_http_request_body,
|
||||
credential_library_username,
|
||||
credential_library_key_type_and_bits,
|
||||
credential_store_id,
|
||||
credential_store_type,
|
||||
credential_store_name,
|
||||
credential_store_description,
|
||||
credential_store_vault_namespace,
|
||||
credential_store_vault_address,
|
||||
target_id,
|
||||
target_type,
|
||||
target_name,
|
||||
target_description,
|
||||
target_default_port_number,
|
||||
target_session_max_seconds,
|
||||
target_session_connection_limit,
|
||||
project_id,
|
||||
project_name,
|
||||
project_description,
|
||||
organization_id,
|
||||
organization_name,
|
||||
organization_description
|
||||
from wh_credential_dimension
|
||||
where current_row_indicator = 'Current'
|
||||
;
|
||||
|
||||
-- Replaces function in 16/03_wh_credential_dimension.up.sql
|
||||
drop function wh_upsert_credential_dimension;
|
||||
create function wh_upsert_credential_dimension(p_session_id wt_public_id, p_library_id wt_public_id, p_credential_purpose wh_dim_text) returns wh_dim_key
|
||||
as $$
|
||||
declare
|
||||
src whx_credential_dimension_target%rowtype;
|
||||
target whx_credential_dimension_target%rowtype;
|
||||
new_row wh_credential_dimension%rowtype;
|
||||
t_id wt_public_id;
|
||||
begin
|
||||
select s.target_id into strict t_id
|
||||
from session as s
|
||||
where s.public_id = p_session_id;
|
||||
|
||||
select * into target
|
||||
from whx_credential_dimension_target as t
|
||||
where t.credential_library_id = p_library_id
|
||||
and t.target_id = t_id
|
||||
and t.credential_purpose = p_credential_purpose;
|
||||
|
||||
select
|
||||
target.key, t.credential_purpose,
|
||||
t.credential_library_id, t.credential_library_type, t.credential_library_name, t.credential_library_description, t.credential_library_vault_path, t.credential_library_vault_http_method, t.credential_library_vault_http_request_body,
|
||||
t.credential_library_username, t.credential_library_key_type_and_bits,
|
||||
t.credential_store_id, t.credential_store_type, t.credential_store_name, t.credential_store_description, t.credential_store_vault_namespace, t.credential_store_vault_address,
|
||||
t.target_id, t.target_type, t.target_name, t.target_description, t.target_default_port_number, t.target_session_max_seconds, t.target_session_connection_limit,
|
||||
t.project_id, t.project_name, t.project_description,
|
||||
t.organization_id, t.organization_name, t.organization_description
|
||||
into src
|
||||
from whx_credential_dimension_source as t
|
||||
where t.credential_library_id = p_library_id
|
||||
and t.session_id = p_session_id
|
||||
and t.target_id = t_id
|
||||
and t.credential_purpose = p_credential_purpose;
|
||||
|
||||
if src is distinct from target then
|
||||
update wh_credential_dimension
|
||||
set current_row_indicator = 'Expired',
|
||||
row_expiration_time = current_timestamp
|
||||
where credential_library_id = p_library_id
|
||||
and target_id = t_id
|
||||
and credential_purpose = p_credential_purpose
|
||||
and current_row_indicator = 'Current';
|
||||
|
||||
insert into wh_credential_dimension (
|
||||
credential_purpose,
|
||||
credential_library_id, credential_library_type, credential_library_name, credential_library_description, credential_library_vault_path, credential_library_vault_http_method, credential_library_vault_http_request_body,
|
||||
credential_library_username, credential_library_key_type_and_bits,
|
||||
credential_store_id, credential_store_type, credential_store_name, credential_store_description, credential_store_vault_namespace, credential_store_vault_address,
|
||||
target_id, target_type, target_name, target_description, target_default_port_number, target_session_max_seconds, target_session_connection_limit,
|
||||
project_id, project_name, project_description,
|
||||
organization_id, organization_name, organization_description,
|
||||
current_row_indicator, row_effective_time, row_expiration_time
|
||||
)
|
||||
select credential_purpose,
|
||||
credential_library_id, credential_library_type, credential_library_name, credential_library_description, credential_library_vault_path, credential_library_vault_http_method, credential_library_vault_http_request_body,
|
||||
credential_library_username, credential_library_key_type_and_bits,
|
||||
credential_store_id, credential_store_type, credential_store_name, credential_store_description, credential_store_vault_namespace, credential_store_vault_address,
|
||||
target_id, target_type, target_name, target_description, target_default_port_number, target_session_max_seconds, target_session_connection_limit,
|
||||
project_id, project_name, project_description,
|
||||
organization_id, organization_name, organization_description,
|
||||
'Current', current_timestamp, 'infinity'::timestamptz
|
||||
from whx_credential_dimension_source
|
||||
where credential_library_id = p_library_id
|
||||
and session_id = p_session_id
|
||||
and target_id = t_id
|
||||
and credential_purpose = p_credential_purpose
|
||||
returning * into new_row;
|
||||
|
||||
return new_row.key;
|
||||
end if;
|
||||
|
||||
return target.key;
|
||||
end
|
||||
$$ language plpgsql;
|
||||
commit;
|
||||
@@ -315,7 +315,9 @@ begin;
|
||||
(project_id, public_id, name)
|
||||
values
|
||||
('p____bwidget', 't_________wb', 'Big Widget Target'),
|
||||
('p____swidget', 't_________ws', 'Small Widget Target');
|
||||
('p____swidget', 't_________ws', 'Small Widget Target'),
|
||||
('p____swidget', 't________ws2', 'Small Widget Target 2'),
|
||||
('p____swidget', 't________ws3', 'Small Widget Target 3');
|
||||
|
||||
insert into target_host_set
|
||||
(project_id, target_id, host_set_id)
|
||||
@@ -327,7 +329,9 @@ begin;
|
||||
('p____bwidget', 't_________wb', 's___1wb-plghs'),
|
||||
('p____bwidget', 't_________wb', 's___2wb-plghs'),
|
||||
('p____swidget', 't_________ws', 's___1ws-plghs'),
|
||||
('p____swidget', 't_________ws', 's___2ws-plghs');
|
||||
('p____swidget', 't_________ws', 's___2ws-plghs'),
|
||||
('p____swidget', 't________ws2', 's___1ws-sths'),
|
||||
('p____swidget', 't________ws3', 's___1ws-sths');
|
||||
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
@@ -336,9 +340,10 @@ begin;
|
||||
as $$
|
||||
begin
|
||||
insert into credential_vault_store
|
||||
(project_id, public_id, name, description, vault_address, namespace)
|
||||
(project_id, public_id, name, description, vault_address, namespace)
|
||||
values
|
||||
('p____bwidget', 'vs_______wvs', 'widget vault store', 'None', 'https://vault.widget', 'default');
|
||||
('p____bwidget', 'vs_______wvs', 'widget vault store', 'None', 'https://vault.widget', 'default'),
|
||||
('p____swidget', 'vs______swvs', 'small widget vault store', 'None', 'https://small.vault.widget', 'default');
|
||||
|
||||
insert into credential_vault_token
|
||||
(store_id, key_id, status, token_hmac, token, last_renewal_time, expiration_time)
|
||||
@@ -401,13 +406,23 @@ begin;
|
||||
values
|
||||
('vl______wvl12', 'my_username', 'my_private_key', 'my_passphrase');
|
||||
|
||||
insert into credential_vault_ssh_cert_library
|
||||
(store_id, public_id, name, description, vault_path, username, key_type, key_bits)
|
||||
values
|
||||
('vs______swvs', 'vscl____wvl1', 'widget ssh admin cert', 'None', '/ssh/issue/admin', 'admin', 'rsa', 4096),
|
||||
('vs______swvs', 'vscl____wvl2', 'widget ssh ecdsa', 'None', '/ssh/sign/user', 'user', 'ecdsa', 521),
|
||||
('vs______swvs', 'vscl____wvl3', 'widget ssh ed25519', 'None', '/ssh/sign/user', 'user', 'ed25519', 0);
|
||||
|
||||
insert into target_credential_library
|
||||
(project_id, target_id, credential_library_id, credential_purpose)
|
||||
values
|
||||
('p____bwidget', 't_________wb', 'vl______wvl1', 'brokered'),
|
||||
('p____bwidget', 't_________wb', 'vl______wvl2', 'brokered'),
|
||||
('p____bwidget', 't_________wb', 'vl______wvl3', 'brokered'),
|
||||
('p____bwidget', 't_________wb', 'vl______wvl3', 'injected_application');
|
||||
('p____bwidget', 't_________wb', 'vl______wvl3', 'injected_application'),
|
||||
('p____bwidget', 't_________ws', 'vscl____wvl1', 'injected_application'),
|
||||
('p____bwidget', 't________ws2', 'vscl____wvl2', 'injected_application'),
|
||||
('p____bwidget', 't________ws3', 'vscl____wvl3', 'injected_application');
|
||||
|
||||
insert into credential_static_store
|
||||
(project_id, public_id, name, description)
|
||||
@@ -432,9 +447,9 @@ create function _wtt_load_widgets_sessions() returns void
|
||||
as $$
|
||||
begin
|
||||
insert into session
|
||||
( project_id , target_id , host_set_id , host_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
(project_id, target_id, host_set_id, host_id, user_id, auth_token_id, certificate, endpoint, public_id)
|
||||
values
|
||||
('p____bwidget' , 't_________wb' , 's___1wb-sths' , 'h_____wb__01' , 'u_____warren' , 'tok___warren' , 'abc'::bytea , 'ep1' , 's1____warren');
|
||||
('p____swidget', 't_________wb', 's___1wb-sths', 'h_____wb__01', 'u_____warren', 'tok___warren', 'abc'::bytea, 'ep1', 's1____warren');
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
|
||||
@@ -3,20 +3,22 @@ begin;
|
||||
|
||||
insert into wh_credential_dimension (
|
||||
credential_purpose,
|
||||
credential_library_id, credential_library_type, credential_library_name, credential_library_description, credential_library_vault_path, credential_library_vault_http_method, credential_library_vault_http_request_body,
|
||||
credential_store_id, credential_store_type, credential_store_name, credential_store_description, credential_store_vault_namespace, credential_store_vault_address,
|
||||
target_id, target_type, target_name, target_description, target_default_port_number, target_session_max_seconds, target_session_connection_limit,
|
||||
project_id, project_name, project_description,
|
||||
organization_id, organization_name, organization_description,
|
||||
current_row_indicator, row_effective_time, row_expiration_time
|
||||
credential_library_id, credential_library_type, credential_library_name, credential_library_description, credential_library_vault_path, credential_library_vault_http_method, credential_library_vault_http_request_body,
|
||||
credential_library_username, credential_library_key_type_and_bits,
|
||||
credential_store_id, credential_store_type, credential_store_name, credential_store_description, credential_store_vault_namespace, credential_store_vault_address,
|
||||
target_id, target_type, target_name, target_description, target_default_port_number, target_session_max_seconds, target_session_connection_limit,
|
||||
project_id, project_name, project_description,
|
||||
organization_id, organization_name, organization_description,
|
||||
current_row_indicator, row_effective_time, row_expiration_time
|
||||
) values (
|
||||
'brokered',
|
||||
'vl______wvl1', 'vault credential library', 'gidget vault library', 'None', '/secrets', 'GET', '\x4e6f6e65',
|
||||
'vs_______wvs', 'vault credential store', 'widget vault store', 'None', 'default', 'https://vault.widget',
|
||||
't_________wb', 'tcp target', 'Big Widget Target', 'None', 0, 28800, 1,
|
||||
'p____bwidget', 'Big Widget Factory', 'None',
|
||||
'o_____widget', 'Widget Inc', 'None',
|
||||
'Current', current_timestamp, 'infinity'::timestamptz
|
||||
'vl______wvl1', 'vault generic credential library', 'gidget vault library', 'None', '/secrets', 'GET', '\x4e6f6e65',
|
||||
'Not Applicable', 'Not Applicable',
|
||||
'vs_______wvs', 'vault credential store', 'widget vault store', 'None', 'default', 'https://vault.widget',
|
||||
't_________wb', 'tcp target', 'Big Widget Target', 'None', 0, 28800, 1,
|
||||
'p____bwidget', 'Big Widget Factory', 'None',
|
||||
'o_____widget', 'Widget Inc', 'None',
|
||||
'Current', current_timestamp, 'infinity'::timestamptz
|
||||
);
|
||||
|
||||
update wh_credential_dimension
|
||||
@@ -30,20 +32,22 @@ begin;
|
||||
|
||||
insert into wh_credential_dimension (
|
||||
credential_purpose,
|
||||
credential_library_id, credential_library_type, credential_library_name, credential_library_description, credential_library_vault_path, credential_library_vault_http_method, credential_library_vault_http_request_body,
|
||||
credential_store_id, credential_store_type, credential_store_name, credential_store_description, credential_store_vault_namespace, credential_store_vault_address,
|
||||
target_id, target_type, target_name, target_description, target_default_port_number, target_session_max_seconds, target_session_connection_limit,
|
||||
project_id, project_name, project_description,
|
||||
organization_id, organization_name, organization_description,
|
||||
current_row_indicator, row_effective_time, row_expiration_time
|
||||
credential_library_id, credential_library_type, credential_library_name, credential_library_description, credential_library_vault_path, credential_library_vault_http_method, credential_library_vault_http_request_body,
|
||||
credential_library_username, credential_library_key_type_and_bits,
|
||||
credential_store_id, credential_store_type, credential_store_name, credential_store_description, credential_store_vault_namespace, credential_store_vault_address,
|
||||
target_id, target_type, target_name, target_description, target_default_port_number, target_session_max_seconds, target_session_connection_limit,
|
||||
project_id, project_name, project_description,
|
||||
organization_id, organization_name, organization_description,
|
||||
current_row_indicator, row_effective_time, row_expiration_time
|
||||
) values (
|
||||
'brokered',
|
||||
'vl______wvl1', 'vault credential library', 'gidget vault library', 'None', '/secrets', 'GET', '\x4e6f6e65',
|
||||
'vs_______wvs', 'vault credential store', 'widget vault store', 'None', 'default', 'https://vault.widget',
|
||||
't_________wb', 'tcp target', 'Big Widget Target', 'None', 0, 28800, 1,
|
||||
'p____bwidget', 'Big Widget Factory', 'None',
|
||||
'o_____widget', 'Widget Inc', 'None',
|
||||
'Current', current_timestamp, 'infinity'::timestamptz
|
||||
'vl______wvl1', 'vault generic credential library', 'gidget vault library', 'None', '/secrets', 'GET', '\x4e6f6e65',
|
||||
'Not Applicable', 'Not Applicable',
|
||||
'vs_______wvs', 'vault credential store', 'widget vault store', 'None', 'default', 'https://vault.widget',
|
||||
't_________wb', 'tcp target', 'Big Widget Target', 'None', 0, 28800, 1,
|
||||
'p____bwidget', 'Big Widget Factory', 'None',
|
||||
'o_____widget', 'Widget Inc', 'None',
|
||||
'Current', current_timestamp, 'infinity'::timestamptz
|
||||
);
|
||||
|
||||
select is(count(*), 2::bigint) from wh_credential_dimension where organization_id = 'o_____widget';
|
||||
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
-- ssh_certificate_cred_library tests the wh_credential_dimension when
|
||||
-- sessions are created with targets that use a vault ssh cert credential library with ecdsa key type
|
||||
begin;
|
||||
select plan(3);
|
||||
|
||||
select wtt_load('widgets', 'iam', 'kms', 'auth', 'hosts', 'targets', 'credentials');
|
||||
|
||||
-- ensure no existing dimensions
|
||||
select is(count(*), 0::bigint) from wh_credential_dimension where organization_id = 'o_____widget';
|
||||
|
||||
-- insert first session, should result in a new credentials dimension
|
||||
insert into session
|
||||
( project_id, target_id, user_id, auth_token_id, certificate, endpoint, public_id)
|
||||
values
|
||||
('p____swidget', 't________ws2', 'u_____walter', 'tok___walter', 'abc'::bytea, 'ep1', 's2____walter');
|
||||
insert into session_host_set_host
|
||||
(session_id, host_set_id, host_id)
|
||||
values
|
||||
('s2____walter', 's___1ws-sths', 'h_____ws__01');
|
||||
insert into session_credential_dynamic
|
||||
( session_id, library_id, credential_id, credential_purpose)
|
||||
values
|
||||
('s2____walter', 'vscl____wvl2', null, 'injected_application');
|
||||
select is(count(*), 1::bigint) from wh_credential_dimension where organization_id = 'o_____widget';
|
||||
|
||||
prepare select_credential_dimensions as
|
||||
select
|
||||
credential_purpose::text,
|
||||
credential_library_id::text, credential_library_type::text, credential_library_name::text, credential_library_description::text, credential_library_vault_path::text, credential_library_vault_http_method::text, credential_library_vault_http_request_body::text,
|
||||
credential_library_username::text, credential_library_key_type_and_bits::text,
|
||||
credential_store_id::text, credential_store_type::text, credential_store_name::text, credential_store_description::text, credential_store_vault_namespace::text, credential_store_vault_address::text,
|
||||
target_id::text, target_type::text, target_name::text, target_description::text, target_default_port_number, target_session_max_seconds, target_session_connection_limit,
|
||||
project_id::text, project_name::text, project_description::text,
|
||||
organization_id::text, organization_name::text, organization_description::text,
|
||||
current_row_indicator::text
|
||||
from wh_credential_dimension
|
||||
where organization_id = 'o_____widget';
|
||||
|
||||
select results_eq(
|
||||
'select_credential_dimensions',
|
||||
$$VALUES
|
||||
(
|
||||
'injected_application',
|
||||
'vscl____wvl2', 'vault ssh certificate credential library', 'widget ssh ecdsa', 'None', '/ssh/sign/user', 'Not Applicable', 'Not Applicable',
|
||||
'user', 'ecdsa-521',
|
||||
'vs______swvs', 'vault credential store', 'small widget vault store', 'None', 'default', 'https://small.vault.widget',
|
||||
't________ws2', 'tcp target', 'Small Widget Target 2', 'None', 0, 28800, -1,
|
||||
'p____swidget', 'Small Widget Factory', 'None',
|
||||
'o_____widget', 'Widget Inc', 'None',
|
||||
'Current'
|
||||
)$$
|
||||
);
|
||||
|
||||
select * from finish();
|
||||
rollback;
|
||||
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
-- ssh_certificate_cred_library tests the wh_credential_dimension when
|
||||
-- sessions are created with targets that use a vault ssh cert credential library
|
||||
begin;
|
||||
select plan(3);
|
||||
|
||||
select wtt_load('widgets', 'iam', 'kms', 'auth', 'hosts', 'targets', 'credentials');
|
||||
|
||||
-- ensure no existing dimensions
|
||||
select is(count(*), 0::bigint) from wh_credential_dimension where organization_id = 'o_____widget';
|
||||
|
||||
-- insert first session, should result in a new credentials dimension
|
||||
insert into session
|
||||
( project_id, target_id, user_id, auth_token_id, certificate, endpoint, public_id)
|
||||
values
|
||||
('p____swidget', 't________ws3', 'u_____walter', 'tok___walter', 'abc'::bytea, 'ep1', 's3____walter');
|
||||
insert into session_host_set_host
|
||||
(session_id, host_set_id, host_id)
|
||||
values
|
||||
('s3____walter', 's___1ws-sths', 'h_____ws__01');
|
||||
insert into session_credential_dynamic
|
||||
( session_id, library_id, credential_id, credential_purpose)
|
||||
values
|
||||
('s3____walter', 'vscl____wvl3', null, 'injected_application');
|
||||
select is(count(*), 1::bigint) from wh_credential_dimension where organization_id = 'o_____widget';
|
||||
|
||||
prepare select_credential_dimensions as
|
||||
select
|
||||
credential_purpose::text,
|
||||
credential_library_id::text, credential_library_type::text, credential_library_name::text, credential_library_description::text, credential_library_vault_path::text, credential_library_vault_http_method::text, credential_library_vault_http_request_body::text,
|
||||
credential_library_username::text, credential_library_key_type_and_bits::text,
|
||||
credential_store_id::text, credential_store_type::text, credential_store_name::text, credential_store_description::text, credential_store_vault_namespace::text, credential_store_vault_address::text,
|
||||
target_id::text, target_type::text, target_name::text, target_description::text, target_default_port_number, target_session_max_seconds, target_session_connection_limit,
|
||||
project_id::text, project_name::text, project_description::text,
|
||||
organization_id::text, organization_name::text, organization_description::text,
|
||||
current_row_indicator::text
|
||||
from wh_credential_dimension
|
||||
where organization_id = 'o_____widget';
|
||||
|
||||
select results_eq(
|
||||
'select_credential_dimensions',
|
||||
$$VALUES
|
||||
(
|
||||
'injected_application',
|
||||
'vscl____wvl3', 'vault ssh certificate credential library', 'widget ssh ed25519', 'None', '/ssh/sign/user', 'Not Applicable', 'Not Applicable',
|
||||
'user', 'ed25519',
|
||||
'vs______swvs', 'vault credential store', 'small widget vault store', 'None', 'default', 'https://small.vault.widget',
|
||||
't________ws3', 'tcp target', 'Small Widget Target 3', 'None', 0, 28800, -1,
|
||||
'p____swidget', 'Small Widget Factory', 'None',
|
||||
'o_____widget', 'Widget Inc', 'None',
|
||||
'Current'
|
||||
)$$
|
||||
);
|
||||
|
||||
select * from finish();
|
||||
rollback;
|
||||
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
-- ssh_certificate_cred_library tests the wh_credential_dimension when
|
||||
-- sessions are created with targets that use a vault ssh cert credential library with rsa key type
|
||||
begin;
|
||||
select plan(3);
|
||||
|
||||
select wtt_load('widgets', 'iam', 'kms', 'auth', 'hosts', 'targets', 'credentials');
|
||||
|
||||
-- ensure no existing dimensions
|
||||
select is(count(*), 0::bigint) from wh_credential_dimension where organization_id = 'o_____widget';
|
||||
|
||||
-- insert first session, should result in a new credentials dimension
|
||||
insert into session
|
||||
( project_id, target_id, user_id, auth_token_id, certificate, endpoint, public_id)
|
||||
values
|
||||
('p____swidget', 't_________ws', 'u_____walter', 'tok___walter', 'abc'::bytea, 'ep1', 's1____walter');
|
||||
insert into session_host_set_host
|
||||
(session_id, host_set_id, host_id)
|
||||
values
|
||||
('s1____walter', 's___1ws-sths', 'h_____ws__01');
|
||||
insert into session_credential_dynamic
|
||||
( session_id, library_id, credential_id, credential_purpose)
|
||||
values
|
||||
('s1____walter', 'vscl____wvl1', null, 'injected_application');
|
||||
select is(count(*), 1::bigint) from wh_credential_dimension where organization_id = 'o_____widget';
|
||||
|
||||
prepare select_credential_dimensions as
|
||||
select
|
||||
credential_purpose::text,
|
||||
credential_library_id::text, credential_library_type::text, credential_library_name::text, credential_library_description::text, credential_library_vault_path::text, credential_library_vault_http_method::text, credential_library_vault_http_request_body::text,
|
||||
credential_library_username::text, credential_library_key_type_and_bits::text,
|
||||
credential_store_id::text, credential_store_type::text, credential_store_name::text, credential_store_description::text, credential_store_vault_namespace::text, credential_store_vault_address::text,
|
||||
target_id::text, target_type::text, target_name::text, target_description::text, target_default_port_number, target_session_max_seconds, target_session_connection_limit,
|
||||
project_id::text, project_name::text, project_description::text,
|
||||
organization_id::text, organization_name::text, organization_description::text,
|
||||
current_row_indicator::text
|
||||
from wh_credential_dimension
|
||||
where organization_id = 'o_____widget';
|
||||
|
||||
select results_eq(
|
||||
'select_credential_dimensions',
|
||||
$$VALUES
|
||||
(
|
||||
'injected_application',
|
||||
'vscl____wvl1', 'vault ssh certificate credential library', 'widget ssh admin cert', 'None', '/ssh/issue/admin', 'Not Applicable', 'Not Applicable',
|
||||
'admin', 'rsa-4096',
|
||||
'vs______swvs', 'vault credential store', 'small widget vault store', 'None', 'default', 'https://small.vault.widget',
|
||||
't_________ws', 'tcp target', 'Small Widget Target', 'None', 0, 28800, -1,
|
||||
'p____swidget', 'Small Widget Factory', 'None',
|
||||
'o_____widget', 'Widget Inc', 'None',
|
||||
'Current'
|
||||
)$$
|
||||
);
|
||||
|
||||
select * from finish();
|
||||
rollback;
|
||||
|
||||
@@ -18,36 +18,39 @@ begin;
|
||||
|
||||
select is(s.*, row(
|
||||
's1____walter',
|
||||
'brokered', -- credential_purpose,
|
||||
'vl______wvl1', -- credential_library_id,
|
||||
'vault credential library', -- credential_library_type,
|
||||
'widget vault library', -- credential_library_name,
|
||||
'None', -- credential_library_description,
|
||||
'/secrets', -- credential_library_vault_path,
|
||||
'GET', -- credential_library_vault_http_method,
|
||||
'None', -- credential_library_vault_http_request_body,
|
||||
'brokered', -- credential_purpose,
|
||||
'vl______wvl1', -- credential_library_id,
|
||||
'vault generic credential library', -- credential_library_type,
|
||||
'widget vault library', -- credential_library_name,
|
||||
'None', -- credential_library_description,
|
||||
'/secrets', -- credential_library_vault_path,
|
||||
'GET', -- credential_library_vault_http_method,
|
||||
'Not Applicable', -- credential_library_vault_http_request_body,
|
||||
|
||||
'vs_______wvs', -- credential_store_id,
|
||||
'vault credential store', -- credential_store_type,
|
||||
'widget vault store', -- credential_store_name,
|
||||
'None', -- credential_store_description,
|
||||
'default', -- credential_store_vault_namespace,
|
||||
'https://vault.widget', -- credential_store_vault_address,
|
||||
'Not Applicable', -- credential_library_username,
|
||||
'Not Applicable', -- credential_library_key_type_and_bits,
|
||||
|
||||
't_________wb', -- target_id,
|
||||
'tcp target', -- target_type,
|
||||
'Big Widget Target', -- target_name,
|
||||
'None', -- target_description,
|
||||
0, -- target_default_port_number,
|
||||
28800, -- target_session_max_seconds,
|
||||
-1, -- target_session_connection_limit,
|
||||
'vs_______wvs', -- credential_store_id,
|
||||
'vault credential store', -- credential_store_type,
|
||||
'widget vault store', -- credential_store_name,
|
||||
'None', -- credential_store_description,
|
||||
'default', -- credential_store_vault_namespace,
|
||||
'https://vault.widget', -- credential_store_vault_address,
|
||||
|
||||
'p____bwidget', -- project_id,
|
||||
'Big Widget Factory', -- project_name,
|
||||
'None', -- project_description,
|
||||
'o_____widget', -- organization_id,
|
||||
'Widget Inc', -- organization_name,
|
||||
'None' -- organization_description
|
||||
't_________wb', -- target_id,
|
||||
'tcp target', -- target_type,
|
||||
'Big Widget Target', -- target_name,
|
||||
'None', -- target_description,
|
||||
0, -- target_default_port_number,
|
||||
28800, -- target_session_max_seconds,
|
||||
-1, -- target_session_connection_limit,
|
||||
|
||||
'p____bwidget', -- project_id,
|
||||
'Big Widget Factory', -- project_name,
|
||||
'None', -- project_description,
|
||||
'o_____widget', -- organization_id,
|
||||
'Widget Inc', -- organization_name,
|
||||
'None' -- organization_description
|
||||
)::whx_credential_dimension_source)
|
||||
from whx_credential_dimension_source as s
|
||||
where s.target_id = 't_________wb';
|
||||
|
||||
@@ -8,33 +8,36 @@ begin;
|
||||
(
|
||||
key,
|
||||
credential_purpose,
|
||||
credential_library_id, credential_library_type, credential_library_name, credential_library_description, credential_library_vault_path, credential_library_vault_http_method, credential_library_vault_http_request_body,
|
||||
credential_store_id, credential_store_type, credential_store_name, credential_store_description, credential_store_vault_namespace, credential_store_vault_address,
|
||||
target_id, target_type, target_name, target_description, target_default_port_number, target_session_max_seconds, target_session_connection_limit,
|
||||
project_id, project_name, project_description,
|
||||
organization_id, organization_name, organization_description,
|
||||
current_row_indicator, row_effective_time, row_expiration_time
|
||||
credential_library_id, credential_library_type, credential_library_name, credential_library_description, credential_library_vault_path, credential_library_vault_http_method, credential_library_vault_http_request_body,
|
||||
credential_library_username, credential_library_key_type_and_bits,
|
||||
credential_store_id, credential_store_type, credential_store_name, credential_store_description, credential_store_vault_namespace, credential_store_vault_address,
|
||||
target_id, target_type, target_name, target_description, target_default_port_number, target_session_max_seconds, target_session_connection_limit,
|
||||
project_id, project_name, project_description,
|
||||
organization_id, organization_name, organization_description,
|
||||
current_row_indicator, row_effective_time, row_expiration_time
|
||||
)
|
||||
values
|
||||
(
|
||||
'wcd________1',
|
||||
'brokered',
|
||||
'vl_______wvl', 'vault credential library', 'widget vault library', 'None', '/secrets', 'GET', 'None',
|
||||
'vs_______wvs', 'vault credential store', 'widget vault store', 'None', 'blue', 'https://vault.widget',
|
||||
't_________wb', 'tcp target', 'Big Widget Target', 'None', 0, 28800, 1,
|
||||
'p____bwidget', 'Big Widget Factory', 'None',
|
||||
'o_____widget', 'Widget Inc', 'None',
|
||||
'Current', '2021-07-21T12:01'::timestamptz, 'infinity'::timestamptz
|
||||
'vl_______wvl', 'vault generic credential library', 'widget vault library', 'None', '/secrets', 'GET', 'None',
|
||||
'Not Applicable', 'Not Applicable',
|
||||
'vs_______wvs', 'vault credential store', 'widget vault store', 'None', 'blue', 'https://vault.widget',
|
||||
't_________wb', 'tcp target', 'Big Widget Target', 'None', 0, 28800, 1,
|
||||
'p____bwidget', 'Big Widget Factory', 'None',
|
||||
'o_____widget', 'Widget Inc', 'None',
|
||||
'Current', '2021-07-21T12:01'::timestamptz, 'infinity'::timestamptz
|
||||
);
|
||||
|
||||
select is(t.*, row(
|
||||
'wcd________1',
|
||||
'brokered',
|
||||
'vl_______wvl', 'vault credential library', 'widget vault library', 'None', '/secrets', 'GET', 'None',
|
||||
'vs_______wvs', 'vault credential store', 'widget vault store', 'None', 'blue', 'https://vault.widget',
|
||||
't_________wb', 'tcp target', 'Big Widget Target', 'None', 0, 28800, 1,
|
||||
'p____bwidget', 'Big Widget Factory', 'None',
|
||||
'o_____widget', 'Widget Inc', 'None'
|
||||
'vl_______wvl', 'vault generic credential library', 'widget vault library', 'None', '/secrets', 'GET', 'None',
|
||||
'Not Applicable', 'Not Applicable',
|
||||
'vs_______wvs', 'vault credential store', 'widget vault store', 'None', 'blue', 'https://vault.widget',
|
||||
't_________wb', 'tcp target', 'Big Widget Target', 'None', 0, 28800, 1,
|
||||
'p____bwidget', 'Big Widget Factory', 'None',
|
||||
'o_____widget', 'Widget Inc', 'None'
|
||||
)::whx_credential_dimension_target)
|
||||
from whx_credential_dimension_target as t
|
||||
where t.target_id = 't_________wb';
|
||||
|
||||
Reference in new issue
Block a user