Files
threshold/internal/proto/controller/api/services/v1/scope_service.proto
T
edd323b73a Key Rotation/Destruction (#2477) (#2607)
* 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>
2022-11-16 18:17:28 -05:00

218 lines
7.6 KiB
Protocol Buffer

syntax = "proto3";
package controller.api.services.v1;
import "controller/api/resources/scopes/v1/scope.proto";
import "google/api/annotations.proto";
import "google/protobuf/field_mask.proto";
import "protoc-gen-openapiv2/options/annotations.proto";
option go_package = "github.com/hashicorp/boundary/internal/gen/controller/api/services;services";
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
info: {
title: "Boundary Controller HTTP API"
}
schemes: HTTPS
schemes: HTTP
};
service ScopeService {
// GetScope returns a stored Scope if present. The provided request
// must include the scope ID for the scope being retrieved. If
// that ID is missing, malformed or references a non existing
// resource an error is returned.
rpc GetScope(GetScopeRequest) returns (GetScopeResponse) {
option (google.api.http) = {
get: "/v1/scopes/{id}"
response_body: "item"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "Gets a single Scope."
};
}
// ListScopes returns a list of stored Scopes which exist inside the provided
// parent Scope id.
rpc ListScopes(ListScopesRequest) returns (ListScopesResponse) {
option (google.api.http) = {
get: "/v1/scopes"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "Lists all Scopes within the Scope provided in the request."
};
}
// CreateScope creates and stores a Scope in boundary. The provided request
// must include the Scope ID in which the new scope will be created. If the Scope
// ID is missing, malformed or references a non existing scope, an error is
// returned. If a name is provided that is in use in another Scope in the same
// parent scope, an error is returned.
rpc CreateScope(CreateScopeRequest) returns (CreateScopeResponse) {
option (google.api.http) = {
post: "/v1/scopes"
body: "item"
response_body: "item"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "Creates a single Scope."
};
}
// UpdateScope updates an existing Scope in boundary. The provided
// Scope must not have any read only fields set. The update mask must be
// included in the request and contain at least 1 mutable field. To unset
// a field's value, include the field in the update mask and don't set it
// in the provided scope. An error is returned if the Scope Id is
// missing or reference a non-existing resource. An error
// is also returned if the request attempts to update the name to one that is
// already in use by another scope in the parent scope.
rpc UpdateScope(UpdateScopeRequest) returns (UpdateScopeResponse) {
option (google.api.http) = {
patch: "/v1/scopes/{id}"
body: "item"
response_body: "item"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "Updates a Scope."
};
}
// DeleteScope remotes a Scope and all child resources from Boundary. If the
// provided Scope IDs are malformed or not provided an error is returned.
rpc DeleteScope(DeleteScopeRequest) returns (DeleteScopeResponse) {
option (google.api.http) = {
delete: "/v1/scopes/{id}"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "Deletes a Scope."
};
}
// ListKeys lists all the keys found in the scope specified. If the scope
// is not found an error is returned.
rpc ListKeys(ListKeysRequest) returns (ListKeysResponse) {
option (google.api.http) = {
get: "/v1/scopes/{id}:list-keys"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "List all keys in a Scope."
};
}
// RotateKeys rotates and optionally rewraps all the keys found in the
// scope specified. If the scope is not found an error is returned. If
// the scope is empty, the global scope is used.
rpc RotateKeys(RotateKeysRequest) returns (RotateKeysResponse) {
option (google.api.http) = {
post: "/v1/scopes:rotate-keys"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "Rotate all keys in a Scope."
};
}
// ListKeyVersionDestructionJobs lists any pending key version destruction jobs in the scope.
rpc ListKeyVersionDestructionJobs(ListKeyVersionDestructionJobsRequest) returns (ListKeyVersionDestructionJobsResponse) {
option (google.api.http) = {
get: "/v1/scopes/{scope_id}:list-key-version-destruction-jobs"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "Lists all pending key version destruction jobs in a Scope."
};
}
// DestroyKeyVersion destroys the specified key version. If this requires re-encrypting
// existing data, it will start an asynchronous process to complete this operation
// before destroying the key. Use ListKeyVersionDestructionJobs to monitor pending destruction jobs.
rpc DestroyKeyVersion(DestroyKeyVersionRequest) returns (DestroyKeyVersionResponse) {
option (google.api.http) = {
post: "/v1/scopes:destroy-key-version"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "Destroy the specified key version in a Scope. This may start an asynchronous job that re-encrypts all data encrypted by the specified key version. Use GET /v1/scopes/{scope_id}:list-key-version-destruction-jobs to monitor pending destruction jobs."
};
}
}
message GetScopeRequest {
string id = 1; // @gotags: `class:"public"`
}
message GetScopeResponse {
resources.scopes.v1.Scope item = 1;
}
message ListScopesRequest {
string scope_id = 1; // @gotags: `class:"public"`
bool recursive = 20 [json_name = "recursive"]; // @gotags: `class:"public"`
string filter = 30 [json_name = "filter"]; // @gotags: `class:"public"`
}
message ListScopesResponse {
repeated resources.scopes.v1.Scope items = 1;
}
message CreateScopeRequest {
bool skip_admin_role_creation = 1; // @gotags: `class:"public"`
bool skip_default_role_creation = 2; // @gotags: `class:"public"`
resources.scopes.v1.Scope item = 3;
}
message CreateScopeResponse {
string uri = 1; // @gotags: `class:"public"`
resources.scopes.v1.Scope item = 2;
}
message UpdateScopeRequest {
string id = 1; // @gotags: `class:"public"`
resources.scopes.v1.Scope item = 2;
google.protobuf.FieldMask update_mask = 3 [json_name = "update_mask"];
}
message UpdateScopeResponse {
resources.scopes.v1.Scope item = 1;
}
message DeleteScopeRequest {
string id = 1; // @gotags: `class:"public"`
}
message DeleteScopeResponse {}
message ListKeysRequest {
string id = 1; // @gotags: `class:"public"`
}
message ListKeysResponse {
repeated resources.scopes.v1.Key items = 1;
}
message RotateKeysRequest {
string scope_id = 1; // @gotags: `class:"public"`
bool rewrap = 2; // @gotags: `class:"public"`
}
message RotateKeysResponse {}
message ListKeyVersionDestructionJobsRequest {
string scope_id = 1; // @gotags: `class:"public"`
}
message ListKeyVersionDestructionJobsResponse {
repeated resources.scopes.v1.KeyVersionDestructionJob items = 1;
}
message DestroyKeyVersionRequest {
string scope_id = 1; // @gotags: `class:"public"`
string key_version_id = 2; // @gotags: `class:"public"`
}
message DestroyKeyVersionResponse {
// Destruction state. One of "pending" or "completed".
// Use GET /v1/scopes/{scope_id}:list-key-version-destruction-jobs
// to monitor pending destruction jobs.
string state = 1; // @gotags: `class:"public"`
}