Skip to content

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

Open
wants to merge 4 commits into
base: djo/2362/fix-ancillary-signing-on-evolving-files
Choose a base branch
from

Conversation

Alenar
Copy link
Collaborator

@Alenar Alenar commented Apr 18, 2025

Content

This PR add a new provider for signing ancillary files: GCP Kms.

Aggregator changes

  • Add AncillarySignerWithGcpKms service
    • not automatically tested as this use a third party crate, gcloud_kms, so testing would mean providing a server that would mock Gcp Kms responses
    • it can be configured by setting the ANCILLARY_FILES_SIGNER_CONFIG configuration key like this:
{
  "type": "gcp-kms",
  "resource_name": "projects/project_name/locations/_location_name/keyRings/key_ring_name/cryptoKeys/key_name/cryptoKeyVersions/key_version"
}
  • Add GcpCryptoKeyVersionResourceName to verify gcp kms resource name provided from the configuration when reading the configuration (else AncillarySignerWithGcpKms would fail when computing the signature, far after the aggregator start).
  • Add tools::DEFAULT_GCP_CREDENTIALS_JSON_ENV_VAR constant to avoid repetitions of the GOOGLE_APPLICATION_CREDENTIALS_JSON env var name

Pre-submit checklist

  • Branch
    • Tests are provided (if possible)
    • Crates versions are updated (if relevant)
    • CHANGELOG file is updated (if relevant)
    • Commit sequence broadly makes sense
    • Key commits have useful messages
  • PR
    • All check jobs of the CI have succeeded
    • Self-reviewed the diff
    • Useful pull request description
    • Reviewer requested
  • Documentation
    • Update documentation website (if relevant)
    • No new TODOs introduced

Issue(s)

Relates to #2362

@Alenar Alenar self-assigned this Apr 18, 2025
Copy link

@Copilot Copilot AI left a 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

Copy link

github-actions bot commented Apr 18, 2025

Test Results

    3 files  ±0     57 suites  ±0   11m 40s ⏱️ -14s
1 874 tests +7  1 874 ✅ +7  0 💤 ±0  0 ❌ ±0 
2 336 runs  +7  2 336 ✅ +7  0 💤 ±0  0 ❌ ±0 

Results for commit 3b8e596. ± Comparison against base commit f872829.

♻️ This comment has been updated with latest results.

@Alenar Alenar force-pushed the djo/2362/fix-ancillary-signing-on-evolving-files branch from c504bad to 3c73805 Compare April 18, 2025 13:40
@Alenar Alenar force-pushed the djo/2362/ancillary-kms-signing branch from 80725e7 to 4413093 Compare April 18, 2025 14:03
Copy link
Collaborator

@sfauvel sfauvel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Alenar Alenar force-pushed the djo/2362/fix-ancillary-signing-on-evolving-files branch from 3c73805 to 13b87bd Compare April 18, 2025 14:15
@Alenar Alenar force-pushed the djo/2362/ancillary-kms-signing branch from 4413093 to 05cf135 Compare April 18, 2025 14:24
@Alenar Alenar force-pushed the djo/2362/fix-ancillary-signing-on-evolving-files branch from 13b87bd to f872829 Compare April 18, 2025 15:07
Alenar added 4 commits April 18, 2025 17:08
- 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.
@Alenar Alenar force-pushed the djo/2362/ancillary-kms-signing branch from 05cf135 to 3b8e596 Compare April 18, 2025 15:08
@Alenar Alenar temporarily deployed to testing-preview April 18, 2025 15:18 — with GitHub Actions Inactive
Copy link
Collaborator

@dlachaume dlachaume left a 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/..'"
Copy link
Collaborator

@dlachaume dlachaume Apr 18, 2025

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?

Copy link
Member

@jpraynaud jpraynaud left a 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()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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() {
Copy link
Member

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:

Suggested change
if env::var(DEFAULT_GCP_CREDENTIALS_JSON_ENV_VAR).is_err() {
if env::var(DEFAULT_GCP_CREDENTIALS_CLOUD_STORAGE_JSON_ENV_VAR).is_err() {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants