* Key Rotation/Destruction (#2477) * fix: Correct kms.CreateKeys comment This method does not return anything. * feat(kms): Add new ListKeys method The new ListKeys method wraps the underlying KMS wrapper, returning all the keys in the scope specified. * feat(scopes): Add new scope actions for key management Adds list-keys, rotate-keys and revoke-keys actions for scopes. * feat(scopes): Add ListKeys API endpoint This new endpoint lists all keys in a scope * feat(api): Add ListKeys to Scopes client This has to be a custom function because it is a custom action and doesn't map well to any of the existing templates, or generalises well in a way that would make it reasonable to create a new template. * feat(cli): Add new scopes list-keys command * add RotateKeys function to the kms repository * Add Rotate Keys Endpoint to Scopes Api (#2360) * add rotate keys endpoint * add tests for RotateKeys endpoint * remove that one comment I forgot about * addressing more PR comments * Add Rotate Keys CLI Command (#2395) * add cli command and client * add bats tests * fix some info text and pr comments * write a new rotate keys description * Add Missing DEK Foreign Keys (#2408) * add missing fks * mark key as nullable in gorm * update tests to use a new wrapper with a real key_id * fix formatting in test and add keys for auth_token test * replace key values * revert postgres_40_01_test.go * style: reformat sql for readability * refactor: change type of key_id columns to kms_private_id * Store key_id and scope_id with oplog entries, re-type columns referencing data key version (#2431) * fix(db): Correct types of data key version referencers * fix(oplog): Fix missing error handling * feat(oplog): Store key_id and scope_id with oplog entries This migration truncates all existing oplog entries, as migrating existing data would have been complex and likely unnecessary. * Update view references * Always delete oplog entries when dropping keys * Fix rebase issues * Fix sql tests * Add schema for new kms destruction jobs (#2479) * feat: Add schema for new kms destruction jobs The schema lets us manage destruction jobs per-table while providing a guarantee that only one run is running at a time. * Apply suggestions from code review Co-authored-by: Michael Gaffney <mgaffney@users.noreply.github.com> * Fix table reference and tests Co-authored-by: Michael Gaffney <mgaffney@users.noreply.github.com> * update domain, api, and cli to all include key versions in outputs (#2472) * update domain, api, and cli to all include key versions in outputs * fix go sum * add migration to fix immutable error * fix final test issue as well as make gen issue * rebase and fix * address johan pr comments * make gen, didn't realize comments were included * update migrations based on new migration 55 file 03 * Move migrations to 56 * feat: Add key version rewrapping function registry (#2478) The new RegisterTableRewrapFn can be used by a domain to register a callback to use when rewrapping data in a specific table name. * feat(kms): Add scopeId to RewrapFn (#2539) This makes it much easier for rewrap functions to look up the correct wrapper and limit the number of rows searched. * Update Root Cert Proto Definition (#2542) * update root cert proto definition to properly identify public_key as the table primary key * add the test fix as well * Rewrap Functions for Encrypted Tables (#2532) * add oidc rewrap * add argon2 config rewrap * add auth token rewrapping * add worker auth cert rewrapping * check the err * add username password credential rewrapping * add ssh private key credential rewrapping * add vault client certificate rewrap function * add host catalog secret rewrap function * cleanup a little * add host vault token rewrap function * add session credential rewrap function * add session rewrap function * add worker auth rewrap function * update test to include full assert gamut * add session rewrap function TEST * bring all tests up to current standards, make more readable, and include full assert gamut * rework all rewrap functions to utilize scope id * update comments, queries, sql refs, etc, in response to PR comments * forgot a comment * remove hmac updates and fix a couple comments again * Rewrapping Registered Tables Test (#2555) * add the registered table test as well as the two missing rewrap functions * address pr comments, add db r/w conversions, cmp.diff, sql comment, remove (now) faulty immutable test * Add ability to list key version destruction jobs, recurring jobs and destroying key versions (#2498) * feat(kms): Add ability to list data key version destruction jobs * feat(scopes): Add ListKeyVersionDestructionJobs * feat(cli): Add list-key-version-destruction-jobs * feat(kms): Add recurring job that performs table rewrapping The new recurring job runs for each job table with a registered rewrapping callback. It attempts to become the running run and start its rewrapping, gracefully handling sudden interruptions by resuming it's work if it finds evidence of sudden interruption. * feat(kms): Add recurring job for destroying key versions The new job monitors the database for data key version destruction jobs that have finished rewrapping all its data, performing the final data key version revocation. * feat(kms): Add DestroyKeyVersion DestroyKeyVersion immediately destroys a key version if it is a root key version or a data key version which encrypts no data. If the data key version encrypts data which needs to be rewrapped, it queues an asynchronous job to complete the rewrapping operation. * feat(scopes): Add DestroyKeyVersion API endpoint * feat(cli): Add scopes destroy-key-version CLI command * Ensure all secret updates include key ID (#2556) * feat(all): Ensure all secret updates include key ID When updating a secret, it is paramount that the key ID is also updated, as it is the only means we have of ensuring that we only destroy keys once there is no more data associated with the key. * Remove fix to session repository for now This breaks the current private key derivation method * add new encrypt/decrypt funcs and made necessary proto changes (#2557) * add new encrypt/decrypt funcs and made necessary proto changes * address all PR comments * fix test panic * add param checking to rewraps * fix(schema): Correctly organize migrations again * Review comments part 1 * Review comments part 2 * Review comments part 3 * Store cert private key, encrypt tofu token (#2583) * fix(session): store cert private key, encrypt tofu token Previously, we would derive a session certificate private key from the session key used in each project, and not store the key. We would also encrypt the tofu token with the database key but not store a reference to this key in the database. This change fixes this by replacing our key derivation with a key generation step, and instead store the generated key, encrypted, in the database. We also ensure that any new tofu tokens are encrypted with the same key. To handle existing sessions, we lazily rewrite the sessions whenever a user lists them. There is a minor risk that a user could end up destroying the database key that encrypts the tofu token before that session has been rewrapped, but this is going to be rare and temporary. * feat(session): Allow the random source for secrets to be configured * Review comments * Minor fixes * More minor fixes * More small fixes Co-authored-by: Danielle Miu <dani.miu@hashicorp.com> Co-authored-by: Danielle <29378233+DanielleMiu@users.noreply.github.com> Co-authored-by: Michael Gaffney <mike@gaffney.cc> Co-authored-by: Michael Gaffney <mgaffney@users.noreply.github.com> * fix(session): Unset session key ID when scope is deleted Unsetting the key ID allows the session to live beyond the lifetime of the scope, while allowing the scope to cascade delete its keys. * fix(migrations): Rewrite migration 56 tests These tests can no longer use the normal test helpers as they try to use the new oplog table structure, so we have to manually write all the interactions. * fix(migrations): Rename migration 58 file name This was the name used in the release branch, update it to the new migration number. * fix(e2e): Add some comments and debug to kms tests * fix(session): Handle empty project and user IDs in read When a project or user is deleted, the session is automatically canceled and the respective field on the session is unset. LookupSession did not handle this case gracefully, and would error on decryption in this state. Skip decrypting sessions that do not have either a user or project to avoid this error. The decrypted values are not used for a canceled session. * Fix worker test * Increase test timeout Co-authored-by: Danielle Miu <dani.miu@hashicorp.com> Co-authored-by: Danielle <29378233+DanielleMiu@users.noreply.github.com> Co-authored-by: Michael Gaffney <mike@gaffney.cc> Co-authored-by: Michael Gaffney <mgaffney@users.noreply.github.com>
449 lines
19 KiB
PL/PgSQL
449 lines
19 KiB
PL/PgSQL
begin;
|
|
-- _wtt_load_widgets_iam populates all iam_ tables for the widgets persona.
|
|
-- iam does not depend on any other aggregates, but others depend on it,
|
|
-- as such is it should be first in the list.
|
|
create function _wtt_load_widgets_iam()
|
|
returns void
|
|
as $$
|
|
begin
|
|
-- Add organizations
|
|
insert into iam_scope
|
|
(parent_id, type, public_id, name)
|
|
values
|
|
('global', 'org', 'o_____widget', 'Widget Inc');
|
|
|
|
-- Add projects to the organizations
|
|
insert into iam_scope
|
|
(parent_id, type, public_id, name)
|
|
values
|
|
('o_____widget', 'project', 'p____bwidget', 'Big Widget Factory'),
|
|
('o_____widget', 'project', 'p____swidget', 'Small Widget Factory');
|
|
|
|
-- Add global users
|
|
-- insert into iam_user
|
|
-- (scope_id, public_id, name)
|
|
-- values
|
|
-- ('global', 'u_______gary', 'Gary'),
|
|
-- ('global', 'u_______gina', 'Gina'),
|
|
-- ('global', 'u______nancy', 'Nancy');
|
|
|
|
-- Add organization users
|
|
insert into iam_user
|
|
(scope_id, public_id, name)
|
|
values
|
|
('o_____widget', 'u_____walter', 'Walter'),
|
|
('o_____widget', 'u_____warren', 'Warren'),
|
|
('o_____widget', 'u_____waylon', 'Waylon'),
|
|
('o_____widget', 'u_____wilson', 'Wilson');
|
|
|
|
insert into iam_group
|
|
(scope_id, public_id, name)
|
|
values
|
|
-- ('global', 'g___gg-group', 'Global Group'),
|
|
('o_____widget', 'g___ow-group', 'Widget Inc Group'),
|
|
('p____bwidget', 'g___wb-group', 'Big Widget Group'),
|
|
('p____swidget', 'g___ws-group', 'Small Widget Group');
|
|
|
|
insert into iam_group_member_user
|
|
(group_id, member_id)
|
|
values
|
|
-- ('g___gg-group', 'u_______gary'),
|
|
('g___ow-group', 'u_____walter'),
|
|
('g___wb-group', 'u_____warren'),
|
|
('g___ws-group', 'u_____waylon');
|
|
|
|
insert into iam_role
|
|
(scope_id, grant_scope_id, public_id, name)
|
|
values
|
|
-- ('global', 'global', 'r_gg_____buy', 'Purchaser'),
|
|
-- ('global', 'global', 'r_gg____shop', 'Shopper'),
|
|
('p____bwidget', 'p____bwidget', 'r_pp_bw__bld', 'Widget Builder'),
|
|
('p____swidget', 'p____swidget', 'r_pp_sw__bld', 'Widget Builder'),
|
|
('o_____widget', 'p____swidget', 'r_op_sw__eng', 'Small Widget Engineer'),
|
|
('o_____widget', 'o_____widget', 'r_oo_____eng', 'Widget Engineer');
|
|
|
|
insert into iam_role_grant
|
|
(role_id, canonical_grant, raw_grant)
|
|
values
|
|
-- ('r_gg_____buy', 'type=*;action=purchase', 'purchase anything'),
|
|
-- ('r_gg____shop', 'type=*;action=view', 'view anything'),
|
|
('r_oo_____eng', 'type=widget;action=design', 'design widget'),
|
|
('r_op_sw__eng', 'type=widget;action=design', 'design widget'),
|
|
('r_op_sw__eng', 'type=widget;action=tune', 'tune widget'),
|
|
('r_op_sw__eng', 'type=widget;action=clean', 'clean widget'),
|
|
('r_pp_bw__bld', 'type=widget;action=build', 'build widget'),
|
|
('r_pp_sw__bld', 'type=widget;action=build', 'build widget');
|
|
|
|
insert into iam_group_role
|
|
(role_id, principal_id)
|
|
values
|
|
('r_oo_____eng', 'g___ow-group'), -- widget
|
|
('r_pp_bw__bld', 'g___wb-group'), -- widget
|
|
('r_pp_sw__bld', 'g___ws-group'); -- widget
|
|
|
|
-- insert into iam_user_role
|
|
-- (role_id, principal_id)
|
|
-- values
|
|
-- ('r_gg_____buy', 'u_auth'),
|
|
-- ('r_gg____shop', 'u_anon');
|
|
end;
|
|
$$ language plpgsql;
|
|
|
|
-- _wtt_load_kms populates all kms_ tables for the widgets persona.
|
|
-- kms depends on iam.
|
|
create function _wtt_load_widgets_kms()
|
|
returns void
|
|
as $$
|
|
begin
|
|
insert into kms_root_key
|
|
(private_id, scope_id)
|
|
values
|
|
('krk___widget', 'o_____widget');
|
|
|
|
insert into kms_root_key_version
|
|
(private_id, root_key_id, key)
|
|
values
|
|
('krkv___widget', 'krk___widget', 'krk___widget'::bytea);
|
|
|
|
insert into kms_data_key
|
|
(private_id, root_key_id, purpose)
|
|
values
|
|
('kdk____widget', 'krk___widget', 'database');
|
|
|
|
insert into kms_data_key_version
|
|
(private_id, data_key_id, root_key_version_id, key)
|
|
values
|
|
('kdkv___widget', 'kdk____widget', 'krkv___widget', 'kdk____widget'::bytea);
|
|
|
|
insert into kms_data_key_version_destruction_job
|
|
(key_id)
|
|
values
|
|
('kdkv___widget');
|
|
|
|
insert into kms_data_key_version_destruction_job_run
|
|
(key_id, table_name, total_count)
|
|
values
|
|
('kdkv___widget', 'auth_token', 100);
|
|
|
|
end;
|
|
$$ language plpgsql;
|
|
|
|
-- _wtt_load_widgets_auth populates all auth_ tables for the widgets persona.
|
|
-- auth depends on iam, and kms.
|
|
create function _wtt_load_widgets_auth()
|
|
returns void
|
|
as $$
|
|
begin
|
|
insert into auth_password_conf
|
|
(password_method_id, private_id)
|
|
values
|
|
('apm___widget', 'apmc__widget'),
|
|
('apm1__widget', 'apmc1_widget');
|
|
|
|
|
|
-- Add password auth method to organizations
|
|
insert into auth_password_method
|
|
(scope_id, public_id, password_conf_id, name)
|
|
values
|
|
('o_____widget', 'apm___widget', 'apmc__widget', 'Widget Auth Password'),
|
|
('o_____widget', 'apm1__widget', 'apmc1_widget', 'Widget Auth Password 1');
|
|
|
|
insert into auth_password_account
|
|
(auth_method_id, public_id, login_name)
|
|
values
|
|
('apm___widget', 'apa___walter', 'walter'),
|
|
('apm1__widget', 'apa1__walter', 'walter'),
|
|
('apm___widget', 'apa___warren', 'warren'),
|
|
('apm___widget', 'apa___waylon', 'waylon'),
|
|
('apm___widget', 'apa___wilson', 'wilson');
|
|
|
|
update auth_account set iam_user_id = 'u_____walter' where public_id = 'apa___walter';
|
|
update auth_account set iam_user_id = 'u_____walter' where public_id = 'apa1__walter';
|
|
update auth_account set iam_user_id = 'u_____warren' where public_id = 'apa___warren';
|
|
update auth_account set iam_user_id = 'u_____waylon' where public_id = 'apa___waylon';
|
|
update auth_account set iam_user_id = 'u_____wilson' where public_id = 'apa___wilson';
|
|
|
|
insert into auth_token
|
|
(key_id, auth_account_id, public_id, token)
|
|
values
|
|
('kdkv___widget', 'apa___walter', 'tok___walter', 'tok___walter'::bytea),
|
|
('kdkv___widget', 'apa1__walter', 'tok1__walter', 'tok1__walter'::bytea),
|
|
('kdkv___widget', 'apa___warren', 'tok___warren', 'tok___warren'::bytea),
|
|
('kdkv___widget', 'apa___waylon', 'tok___waylon', 'tok___waylon'::bytea),
|
|
('kdkv___widget', 'apa___wilson', 'tok___wilson', 'tok___wilson'::bytea);
|
|
|
|
insert into auth_oidc_method
|
|
(scope_id, public_id, client_id, name, state, key_id, issuer)
|
|
values
|
|
('o_____widget', 'aom___widget', 'aomc__widget', 'Widget OIDC', 'active-private', 'kdkv___widget', 'https://oidc.widget.test');
|
|
|
|
insert into auth_oidc_account
|
|
(auth_method_id, public_id, name, description, full_name, email, issuer, subject)
|
|
values
|
|
('aom___widget', 'aoa___walter', 'walter account', 'Walter OIDC Account', 'Walter', 'walter@widget.test', 'https://widget.test', 'sub___walter'),
|
|
('aom___widget', 'aoa___warren', 'warren account', 'Warren OIDC Account', null, null, 'https://widget.test', 'sub___warren');
|
|
|
|
update auth_account set iam_user_id = 'u_____walter' where public_id = 'aoa___walter';
|
|
update auth_account set iam_user_id = 'u_____warren' where public_id = 'aoa___warren';
|
|
|
|
insert into auth_token
|
|
(key_id, auth_account_id, public_id, token)
|
|
values
|
|
('kdkv___widget', 'aoa___walter', 'oidc__walter', 'oidc__walter'::bytea),
|
|
('kdkv___widget', 'aoa___warren', 'oidc__warren', 'oidc__warren'::bytea);
|
|
|
|
end;
|
|
$$ language plpgsql;
|
|
|
|
-- _wtt_load_widgets_hosts populates all host_ tables for the widgets persona.
|
|
-- hosts depend on iam.
|
|
create function _wtt_load_widgets_hosts()
|
|
returns void
|
|
as $$
|
|
begin
|
|
insert into static_host_catalog
|
|
(project_id, public_id, name)
|
|
values
|
|
('p____bwidget', 'c___wb-sthcl', 'Big Widget Static Catalog'),
|
|
('p____swidget', 'c___ws-sthcl', 'Small Widget Static Catalog');
|
|
|
|
insert into static_host
|
|
(catalog_id, public_id, address)
|
|
values
|
|
('c___wb-sthcl', 'h_____wb__01', '1.big.widget'),
|
|
('c___wb-sthcl', 'h_____wb__02', '2.big.widget'),
|
|
('c___wb-sthcl', 'h_____wb__03', '3.big.widget'),
|
|
('c___wb-sthcl', 'h_____wb__04', '4.big.widget'),
|
|
('c___wb-sthcl', 'h_____wb__05', '5.big.widget'),
|
|
('c___wb-sthcl', 'h_____wb__06', '6.big.widget'),
|
|
('c___wb-sthcl', 'h_____wb__07', '7.big.widget'),
|
|
('c___wb-sthcl', 'h_____wb__08', '8.big.widget'),
|
|
('c___wb-sthcl', 'h_____wb__09', '9.big.widget'),
|
|
|
|
('c___ws-sthcl', 'h_____ws__01', '1.small.widget'),
|
|
('c___ws-sthcl', 'h_____ws__02', '2.small.widget'),
|
|
('c___ws-sthcl', 'h_____ws__03', '3.small.widget'),
|
|
('c___ws-sthcl', 'h_____ws__04', '4.small.widget'),
|
|
('c___ws-sthcl', 'h_____ws__05', '5.small.widget'),
|
|
('c___ws-sthcl', 'h_____ws__06', '6.small.widget'),
|
|
('c___ws-sthcl', 'h_____ws__07', '7.small.widget'),
|
|
('c___ws-sthcl', 'h_____ws__08', '8.small.widget'),
|
|
('c___ws-sthcl', 'h_____ws__09', '9.small.widget');
|
|
|
|
insert into static_host_set
|
|
(catalog_id, public_id, name)
|
|
values
|
|
('c___wb-sthcl', 's___1wb-sths', 'Big Widget Static Set 1'),
|
|
('c___wb-sthcl', 's___2wb-sths', 'Big Widget Static Set 2'),
|
|
('c___ws-sthcl', 's___1ws-sths', 'Small Widget Static Set 1'),
|
|
('c___ws-sthcl', 's___2ws-sths', 'Small Widget Static Set 2');
|
|
|
|
insert
|
|
into static_host_set_member
|
|
( host_id, set_id, catalog_id)
|
|
select h.public_id, s.public_id, s.catalog_id
|
|
from static_host as h,
|
|
static_host_set as s
|
|
where h.catalog_id = s.catalog_id
|
|
and h.address like '%.widget';
|
|
|
|
insert into plugin_host
|
|
(scope_id, public_id, name)
|
|
values
|
|
('global', 'plg___wb-hplg', 'Short Host Plugin');
|
|
|
|
insert into host_plugin_catalog
|
|
(project_id, public_id, plugin_id, name, attributes)
|
|
values
|
|
('p____bwidget', 'c___wb-plghcl', 'plg___wb-hplg', 'Big Widget Plugin Catalog', ''),
|
|
('p____swidget', 'c___ws-plghcl', 'plg___wb-hplg', 'Small Widget Plugin Catalog', '');
|
|
|
|
insert into host_plugin_host
|
|
(catalog_id, public_id, external_id)
|
|
values
|
|
('c___wb-plghcl', 'h_____wb__01-plgh', '1 big widget'),
|
|
('c___wb-plghcl', 'h_____wb__02-plgh', '2 big widget'),
|
|
('c___wb-plghcl', 'h_____wb__03-plgh', '3 big widget'),
|
|
|
|
('c___ws-plghcl', 'h_____ws__01-plgh', '1 small widget'),
|
|
('c___ws-plghcl', 'h_____ws__02-plgh', '2 small widget'),
|
|
('c___ws-plghcl', 'h_____ws__03-plgh', '3 small widget');
|
|
|
|
insert into host_dns_name
|
|
(host_id, name)
|
|
values
|
|
('h_____wb__01-plgh', '1.big.widget'),
|
|
('h_____wb__02-plgh', '2.big.widget'),
|
|
('h_____wb__03-plgh', '3.big.widget'),
|
|
|
|
('h_____ws__01-plgh', '1.small.widget'),
|
|
('h_____ws__02-plgh', '2.small.widget'),
|
|
('h_____ws__03-plgh', '3.small.widget');
|
|
|
|
insert into host_ip_address
|
|
(host_id, address)
|
|
values
|
|
('h_____wb__01-plgh', '1.1.1.1'),
|
|
('h_____wb__02-plgh', 'fe80::2222:2222:2222:2222'),
|
|
-- host 3 only has a dns name so the set of addresses are the same
|
|
-- between the static and plugin based host
|
|
|
|
('h_____ws__01-plgh', '11.11.11.11'),
|
|
('h_____ws__02-plgh', '2001:4860:4860::2222'),
|
|
('h_____ws__03-plgh', '33.33.33.33');
|
|
|
|
insert into host_plugin_set
|
|
(catalog_id, public_id, name, attributes, need_sync)
|
|
values
|
|
('c___wb-plghcl', 's___1wb-plghs', 'Big Widget Plugin Set 1', '', false),
|
|
('c___wb-plghcl', 's___2wb-plghs', 'Big Widget Plugin Set 2', '', false),
|
|
('c___ws-plghcl', 's___1ws-plghs', 'Small Widget Plugin Set 1', '', false),
|
|
('c___ws-plghcl', 's___2ws-plghs', 'Small Widget Plugin Set 2', '', false);
|
|
|
|
insert
|
|
into host_plugin_set_member
|
|
( host_id, set_id, catalog_id)
|
|
select h.public_id, s.public_id, s.catalog_id
|
|
from host_plugin_host as h,
|
|
host_plugin_set as s
|
|
where h.catalog_id = s.catalog_id;
|
|
end;
|
|
$$ language plpgsql;
|
|
|
|
-- _wtt_load_widgets_targets populates all target_ tables for the widgets persona.
|
|
-- targets depend on iam, auth, hosts.
|
|
create function _wtt_load_widgets_targets()
|
|
returns void
|
|
as $$
|
|
begin
|
|
insert into target_tcp
|
|
(project_id, public_id, name)
|
|
values
|
|
('p____bwidget', 't_________wb', 'Big Widget Target'),
|
|
('p____swidget', 't_________ws', 'Small Widget Target');
|
|
|
|
insert into target_host_set
|
|
(project_id, target_id, host_set_id)
|
|
values
|
|
('p____bwidget', 't_________wb', 's___1wb-sths'),
|
|
('p____bwidget', 't_________wb', 's___2wb-sths'),
|
|
('p____swidget', 't_________ws', 's___1ws-sths'),
|
|
('p____swidget', 't_________ws', 's___2ws-sths'),
|
|
('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');
|
|
|
|
end;
|
|
$$ language plpgsql;
|
|
|
|
create function _wtt_load_widgets_credentials()
|
|
returns void
|
|
as $$
|
|
begin
|
|
insert into credential_vault_store
|
|
(project_id, public_id, name, description, vault_address, namespace)
|
|
values
|
|
('p____bwidget', 'vs_______wvs', 'widget vault store', 'None', 'https://vault.widget', 'default');
|
|
|
|
insert into credential_vault_token
|
|
(store_id, key_id, status, token_hmac, token, last_renewal_time, expiration_time)
|
|
values
|
|
('vs_______wvs', 'kdkv___widget', 'current', 'hmac-value', 'token-value', now(), now() + interval '1 hour');
|
|
|
|
insert into credential_vault_library
|
|
(store_id, public_id, name, description, vault_path, http_method, credential_type)
|
|
values
|
|
('vs_______wvs', 'vl______wvl1', 'widget vault library', 'None', '/secrets', 'GET', 'unspecified'),
|
|
('vs_______wvs', 'vl______wvl2', 'widget vault ssh', 'None', '/secrets/ssh/admin', 'GET', 'unspecified'),
|
|
('vs_______wvs', 'vl______wvl3', 'widget vault kv one', 'None', '/secrets/kv/one', 'GET', 'username_password'),
|
|
('vs_______wvs', 'vl______wvl4', 'widget vault kv two', 'None', '/secrets/kv/two', 'GET', 'username_password'),
|
|
('vs_______wvs', 'vl______wvl5', 'widget vault kv three', 'None', '/secrets/kv/three', 'GET', 'username_password'),
|
|
('vs_______wvs', 'vl______wvl6', 'widget vault kv four', 'None', '/secrets/kv/four', 'GET', 'username_password'),
|
|
('vs_______wvs', 'vl______wvl7', 'widget vault kv five', 'None', '/secrets/kv/five', 'GET', 'username_password'),
|
|
('vs_______wvs', 'vl______wvl8', 'widget vault kv six', 'None', '/secrets/kv/six', 'GET', 'ssh_private_key'),
|
|
('vs_______wvs', 'vl______wvl9', 'widget vault kv seven', 'None', '/secrets/kv/seven', 'GET', 'ssh_private_key'),
|
|
('vs_______wvs', 'vl______wvl10', 'widget vault kv eight', 'None', '/secrets/kv/eight', 'GET', 'ssh_private_key'),
|
|
('vs_______wvs', 'vl______wvl11', 'widget vault kv nine', 'None', '/secrets/kv/nine', 'GET', 'ssh_private_key'),
|
|
('vs_______wvs', 'vl______wvl12', 'widget vault kv ten', 'None', '/secrets/kv/n', 'GET', 'ssh_private_key');
|
|
|
|
insert into credential_vault_library_username_password_mapping_override
|
|
(library_id)
|
|
values
|
|
('vl______wvl4');
|
|
|
|
insert into credential_vault_library_username_password_mapping_override
|
|
(library_id, username_attribute)
|
|
values
|
|
('vl______wvl5', 'my_username');
|
|
|
|
insert into credential_vault_library_username_password_mapping_override
|
|
(library_id, password_attribute)
|
|
values
|
|
('vl______wvl6', 'my_password');
|
|
|
|
insert into credential_vault_library_username_password_mapping_override
|
|
(library_id, username_attribute, password_attribute)
|
|
values
|
|
('vl______wvl7', 'my_username', 'my_password');
|
|
|
|
insert into credential_vault_library_ssh_private_key_mapping_override
|
|
(library_id)
|
|
values
|
|
('vl______wvl9');
|
|
|
|
insert into credential_vault_library_ssh_private_key_mapping_override
|
|
(library_id, username_attribute)
|
|
values
|
|
('vl______wvl10', 'my_username');
|
|
|
|
insert into credential_vault_library_ssh_private_key_mapping_override
|
|
(library_id, private_key_attribute)
|
|
values
|
|
('vl______wvl11', 'my_private_key');
|
|
|
|
insert into credential_vault_library_ssh_private_key_mapping_override
|
|
(library_id, username_attribute, private_key_attribute, private_key_passphrase_attribute)
|
|
values
|
|
('vl______wvl12', 'my_username', 'my_private_key', 'my_passphrase');
|
|
|
|
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');
|
|
|
|
insert into credential_static_store
|
|
(project_id, public_id, name, description)
|
|
values
|
|
('p____bwidget', 'cs______wup1', 'widget static store', 'None'),
|
|
('p____swidget', 'cs______wup2', 'widget static store', 'None');
|
|
|
|
insert into credential_static_username_password_credential
|
|
(store_id, public_id, name, description, username, password_encrypted, password_hmac, key_id)
|
|
values
|
|
('cs______wup1', 'cred____wup1', 'widget static username password credential', 'None', 'b_user', 'encrypted_password', 'hmac-value', 'kdkv___widget'),
|
|
('cs______wup2', 'cred____wup2', 'widget static username password credential', 'None', 's_user', 'encrypted_password', 'hmac-value', 'kdkv___widget');
|
|
|
|
insert into credential_static_json_credential
|
|
(store_id, public_id, name, description, object_encrypted, object_hmac, key_id)
|
|
values
|
|
('cs______wup1', 'cred____wjson1', 'widget static json credential', 'None', 'json_value'::bytea, 'hmac-value', 'kdkv___widget');
|
|
end;
|
|
$$ language plpgsql;
|
|
|
|
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)
|
|
values
|
|
('p____bwidget' , 't_________wb' , 's___1wb-sths' , 'h_____wb__01' , 'u_____warren' , 'tok___warren' , 'abc'::bytea , 'ep1' , 's1____warren');
|
|
end;
|
|
$$ language plpgsql;
|
|
|
|
commit;
|