-
Notifications
You must be signed in to change notification settings - Fork 43
feat(aggregator): Sign ancillary with GCP Kms #2431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: djo/2362/fix-ancillary-signing-on-evolving-files
Are you sure you want to change the base?
feat(aggregator): Sign ancillary with GCP Kms #2431
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for signing ancillary files using a key stored in Google Cloud Platform KMS. Key changes include:
- The implementation of a new signing service (AncillarySignerWithGcpKms) using the gcloud-kms crate.
- The addition of the GcpCryptoKeyVersionResourceName module to validate and parse GCP resource names.
- Updates to configuration, dependency injection, tests, and documentation to integrate GCP KMS as a new ancillary files signer.
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
mithril-aggregator/src/tools/mod.rs | Added constant DEFAULT_GCP_CREDENTIALS_JSON_ENV_VAR |
mithril-aggregator/src/services/snapshotter/ancillary_signer/with_gcp_kms.rs | New signer service implementation using GCP KMS client |
mithril-aggregator/src/services/snapshotter/ancillary_signer/mod.rs | Updated module imports and re-exports |
mithril-aggregator/src/services/snapshotter/ancillary_signer/gcp_kms_resource_name.rs | Added resource name validation and parsing logic |
mithril-aggregator/src/file_uploaders/gcp_uploader.rs | Updated use of environment variable constant in uploader logic |
mithril-aggregator/src/dependency_injection/builder/protocol/artifacts.rs | Integrated GcpKms variant for ancillary files signer configuration |
mithril-aggregator/src/configuration.rs | Updated configuration and added tests for GCP KMS-related settings |
mithril-aggregator/Cargo.toml | Added gcloud-kms dependency |
internal/mithril-doc/src/markdown_formatter.rs | Updated newline formatting in markdown output |
docs/website/root/manual/develop/nodes/mithril-aggregator.md | Updated ancillary files signer configuration documentation |
mithril-aggregator/src/services/snapshotter/ancillary_signer/gcp_kms_resource_name.rs
Outdated
Show resolved
Hide resolved
mithril-aggregator/src/services/snapshotter/ancillary_signer/gcp_kms_resource_name.rs
Fixed
Show fixed
Hide fixed
c504bad
to
3c73805
Compare
80725e7
to
4413093
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
3c73805
to
13b87bd
Compare
4413093
to
05cf135
Compare
13b87bd
to
f872829
Compare
- use `gcloud_kms` crate as backend - define a `GcpCryptoKeyVersionResourceName` struct that's not stricly necessary, as we could pass a string directly, but allow format check at configuration time instead of at the last moment when the request is sent.
05cf135
to
3b8e596
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
|
||
fn from_str(s: &str) -> StdResult<Self> { | ||
let error = format!( | ||
"Invalid resource name: '{s}' does not match pattern 'projects/../locations/../keyRings/../cryptoKeys/../cryptoKeyVersions/..'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to use the constants declared just above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
} | ||
|
||
fn default_gcp_kms_credentials_json_env_var() -> String { | ||
DEFAULT_GCP_CREDENTIALS_JSON_ENV_VAR.to_string() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DEFAULT_GCP_CREDENTIALS_JSON_ENV_VAR.to_string() | |
DEFAULT_GCP_CREDENTIALS_KMS_JSON_ENV_VAR.to_string() |
return Err(anyhow!( | ||
"Missing GOOGLE_APPLICATION_CREDENTIALS_JSON environment variable".to_string() | ||
)); | ||
if env::var(DEFAULT_GCP_CREDENTIALS_JSON_ENV_VAR).is_err() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need 2 different variables if we want to use 2 different service accounts:
if env::var(DEFAULT_GCP_CREDENTIALS_JSON_ENV_VAR).is_err() { | |
if env::var(DEFAULT_GCP_CREDENTIALS_CLOUD_STORAGE_JSON_ENV_VAR).is_err() { |
Content
This PR add a new provider for signing ancillary files: GCP Kms.
Aggregator changes
AncillarySignerWithGcpKms
servicegcloud_kms
, so testing would mean providing a server that would mock Gcp Kms responsesANCILLARY_FILES_SIGNER_CONFIG
configuration key like this:GcpCryptoKeyVersionResourceName
to verify gcp kms resource name provided from the configuration when reading the configuration (elseAncillarySignerWithGcpKms
would fail when computing the signature, far after the aggregator start).tools::DEFAULT_GCP_CREDENTIALS_JSON_ENV_VAR
constant to avoid repetitions of theGOOGLE_APPLICATION_CREDENTIALS_JSON
env var namePre-submit checklist
Issue(s)
Relates to #2362