Skip to main content

Keeper Secrets Manager SDK storage integration with Google Cloud KMS for encrypted key-value storage.

Project description

GCP KSM

Keeper Secrets Manager integrates with GCP KMS in order to provide protection for Keeper Secrets Manager configuration files. With this integration, you can protect connection details on your machine while taking advantage of Keeper's zero-knowledge encryption of all your secret credentials.

Features

  • Encrypt and Decrypt your Keeper Secrets Manager configuration files with GCP KMS
  • Protect against unauthorized access to your Secrets Manager connections
  • Requires only minor changes to code for immediate protection. Works with all Keeper Secrets Manager Python SDK functionality

Prerequisites

  • Supports the Python Secrets Manager SDK
  • Requires google-cloud-kms package
  • These are permissions required for service account:
    • Cloud KMS CryptoKey Decrypter
    • Cloud KMS CryptoKey Encrypter
    • Cloud KMS CryptoKey Public Key Viewer
    • Cloud KMS Viewer (provides cloudkms.cryptoKeys.get, required for key introspection on init)

Setup

  1. Install KSM Storage Module

The Secrets Manager GCP KSM module can be installed using pip

pip3 install keeper-secrets-manager-storage-gcp-kms

Note: v1.1.0+ requires Python 3.9.2+ (effective floor; cryptography>=46.0.5 excludes 3.9.0 and 3.9.1). Users on Python 3.6–3.8 should pin to keeper-secrets-manager-storage-gcp-kms<1.1.0.

  1. Configure GCP Connection

By default the google-cloud-kms library will utilize the default connection session setup with the GCP CLI with the gcloud auth command. If you would like to specify the connection details, the two configuration files located at ~/.config/gcloud/configurations/config_default and ~/.config/gcloud/legacy_credentials//adc.json can be manually edited.

See the GCP documentation for more information on setting up an GCP session: https://cloud.google.com/sdk/gcloud/reference/auth

Alternatively, configuration variables can be provided explicitly as a service account file using the GcpSessionConfig data class and providing a path to the service account json file.

You will need a GCP service account to use the GCP KMS integration.

For more information on GCP service accounts see the GCP documentation: https://cloud.google.com/iam/docs/service-accounts

  1. Add GCP KMS Storage to Your Code

Now that the GCP connection has been configured, you need to tell the Secrets Manager SDK to utilize the KMS as storage.

To do this, use GcpKmsKeyvalueStorage as your Secrets Manager storage in the SecretsManager constructor.

The storage will require a GCP Key ID, as well as the name of the Secrets Manager configuration file which will be encrypted by GCP KMS.

    from keeper_secrets_manager_storage_gcp_kms import GCPKeyConfig, GCPKeyValueStorage, GCPKMSClientConfig

    from keeper_secrets_manager_core import SecretsManager

    # example key : projects/<project>/locations/<location>/keyRings/<key>/cryptoKeys/<key_name>/cryptoKeyVersions/<key_version>
    gcp_key_config_1 = GCPKeyConfig("<key_resource_uri_1>")
    gcp_key_config_2 = GCPKeyConfig("<key_resource_uri_1>")

    gcp_session_config = GCPKMSClientConfig().create_client_from_credentials_file('<gcp_credentials_config_file_location.json>')
    config_path = "<ksm_config.json>"
    one_time_token = "<token>"

    storage = GCPKeyValueStorage(config_path, gcp_key_config_1, gcp_session_config)
    storage.change_key(gcp_key_config_2) # if we want to change the key
    secrets_manager = SecretsManager(token=one_time_token,config=storage)
    all_records = secrets_manager.get_secrets()
    print(storage.decrypt_config(False))

    first_record = all_records[0]
    print(first_record)

You're ready to use the KSM integration 👍 Using the GCP KMS Integration

Once setup, the Secrets Manager GCP KMS integration supports all Secrets Manager Python SDK functionality. Your code will need to be able to access the GCP KMS APIs in order to manage the decryption of the configuration file when run.

Change Log

1.1.0

Requirements:

  • Minimum Python version raised to 3.9.2 (effective floor; cryptography>=46.0.5 excludes 3.9.0 and 3.9.1 — users on exactly those patch versions will hit a pip resolver error); users on Python 3.6–3.8 should pin to <1.1.0
  • Minimum keeper-secrets-manager-core dependency raised to 17.2.1

Security:

  • Fixed CVE-2026-0994: upgraded protobuf to ≥6.33.5 (JSON recursion DoS)
  • Fixed CVE-2026-26007: upgraded cryptography to ≥46.0.5 (subgroup attack)
  • Fixed AES-GCM nonce from 128-bit (PyCryptodome default) to 96-bit per NIST SP 800-38D; existing encrypted blobs remain readable
  • Replaced MD5 with SHA-256 for config change detection

Bug fixes:

  • GCPKeyValueStorage now raises on init when cloudkms.cryptoKeys.get is denied, instead of proceeding with the config file left unencrypted on disk
  • KMS errors (permission denials, network failures, decryption failures) now propagate as exceptions instead of being silently swallowed or reported as misleading JSON parse errors
  • decrypt_config() no longer writes plaintext credentials to disk when called without arguments (autosave default changed from True to False)
  • read_storage() now returns a copy; mutations to the returned dict no longer silently corrupt internal state
  • delete() of the last config key now persists correctly to disk
  • delete_all() now removes the config file from disk; previously it attempted to re-encrypt an empty config, leaving credentials readable if KMS was unavailable
  • set() now propagates PermissionError when the config file is read-only, preventing silent in-memory/on-disk state divergence
  • change_key() rolls back cleanly on failure; a failed rotation no longer leaves the storage in an inconsistent state
  • GCPKeyValueStorage is now thread-safe for concurrent set(), delete(), change_key(), and decrypt_config() calls (KSM-946)
  • key_version on GCPKeyConfig applies only to encrypt and asymmetric operations; symmetric client.decrypt uses the unversioned CryptoKey name as required by the GCP API (the server selects the version from the ciphertext envelope)
  • load_config() now always leaves self.config as a dict (never None) after parsing a plaintext {} bootstrap config; previously every subsequent read/set/delete crashed with TypeError: 'NoneType' object is not iterable (KSM-948)

1.0.1

  • Fixed installation and import instructions in README

1.0.0

  • Initial release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

keeper_secrets_manager_storage_gcp_kms-1.1.0.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file keeper_secrets_manager_storage_gcp_kms-1.1.0.tar.gz.

File metadata

File hashes

Hashes for keeper_secrets_manager_storage_gcp_kms-1.1.0.tar.gz
Algorithm Hash digest
SHA256 c82fb7dddfcfe541f36778276012af7fc7a9abf1ebbe92addfcbfddf9d9cb487
MD5 37bea4c1bba38a0543943bb8bd0fa670
BLAKE2b-256 dd39bc96f9e98aa155a198e084227fdbca9c88ae2dba9ddd910da1cffa52c922

See more details on using hashes here.

Provenance

The following attestation bundles were made for keeper_secrets_manager_storage_gcp_kms-1.1.0.tar.gz:

Publisher: publish.pypi.sdk.storage.gcp.kms.yml on Keeper-Security/secrets-manager

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file keeper_secrets_manager_storage_gcp_kms-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for keeper_secrets_manager_storage_gcp_kms-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dc7bd6dc6618e42a43276373c21c90468ceae60b88e05b78cc57f45032ae8b4a
MD5 14e94dab762b4162b6dc13e3867dd511
BLAKE2b-256 bdcfd8510e066a80857f44dab621e74e1d969b9019553fee9fea67ac60242a73

See more details on using hashes here.

Provenance

The following attestation bundles were made for keeper_secrets_manager_storage_gcp_kms-1.1.0-py3-none-any.whl:

Publisher: publish.pypi.sdk.storage.gcp.kms.yml on Keeper-Security/secrets-manager

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page