Skip to main content

A reusable FastAPI vault utility service for other projects to use hashicorp vault

Project description

Here's a sample README.md for your Vault Service package, including descriptions for each method in your utilities file. You can customize it further based on your needs:

# Vault Service

The **Vault Service** package provides a convenient interface for interacting with HashiCorp Vault. It offers various methods to manage secrets for different tenants and connectors. This package is designed for seamless integration into your applications.

## Table of Contents

- [Installation](#installation)
- [Usage](#usage)
- [Methods](#methods)
  - [store_secret](#store_secret)
  - [get_secret](#get_secret)
  - [update_secret](#update_secret)
  - [delete_secret](#delete_secret)
  - [get_all_secrets_for_tenant](#get_all_secrets_for_tenant)
  - [delete_all_secrets_for_tenant](#delete_all_secrets_for_tenant)
- [License](#license)

## Installation

You can install the Vault Service package using pip:

```bash
pip install vault-service

Usage

To use the Vault Service, you need to initialize the VaultController and then call the utility functions. Make sure to set the required environment variables for Vault connection:

export VAULT_ADDR='https://your-vault-address'
export VAULT_TOKEN='your-vault-token'
export BASE_PATH='your-base-path'

Methods

store_secret(tenant_id: str, connector_id: str, secret_data: SecretData)

Stores a new secret in HashiCorp Vault under the specified tenant and connector ID.

Parameters:

  • tenant_id: The ID of the tenant.
  • connector_id: The ID of the connector.
  • secret_data: An instance of SecretData, containing the secret information to be stored.

Returns: A message indicating the success or failure of the operation.


get_secret(tenant_id: str, connector_id: str)

Retrieves a secret from HashiCorp Vault for the specified tenant and connector ID.

Parameters:

  • tenant_id: The ID of the tenant.
  • connector_id: The ID of the connector.

Returns: The retrieved secret data as a dictionary, or an error message if not found.


update_secret(tenant_id: str, connector_id: str, secret_data: SecretData)

Updates an existing secret in HashiCorp Vault for the specified tenant and connector ID.

Parameters:

  • tenant_id: The ID of the tenant.
  • connector_id: The ID of the connector.
  • secret_data: An instance of SecretData, containing the updated secret information.

Returns: A message indicating the success or failure of the operation.


delete_secret(tenant_id: str, connector_id: str)

Deletes a secret from HashiCorp Vault for the specified tenant and connector ID.

Parameters:

  • tenant_id: The ID of the tenant.
  • connector_id: The ID of the connector.

Returns: A message indicating the success or failure of the deletion.


get_all_secrets_for_tenant(tenant_id: str)

Retrieves all secrets for a specific tenant from HashiCorp Vault.

Parameters:

  • tenant_id: The ID of the tenant.

Returns: A list of all secrets associated with the tenant.


delete_all_secrets_for_tenant(tenant_id: str)

Deletes all secrets associated with a specific tenant from HashiCorp Vault.

Parameters:

  • tenant_id: The ID of the tenant.

Returns: A message indicating the success or failure of the deletion.

License

This project is licensed under the MIT License. See the LICENSE file for details.


### Additional Notes:
1. **Installation Instructions**: Modify the installation instructions if your package has specific dependencies or requires setup beyond `pip install`.
2. **Usage Section**: Include sample code snippets that demonstrate how to use your package effectively.
3. **Add Environment Variables**: Ensure users know they must set the environment variables needed for Vault connection.

Feel free to adjust the formatting and content as needed!

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

vault_service-0.2.5.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

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

vault_service-0.2.5-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file vault_service-0.2.5.tar.gz.

File metadata

  • Download URL: vault_service-0.2.5.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for vault_service-0.2.5.tar.gz
Algorithm Hash digest
SHA256 7f199dd3323728f5bae90f78f778f9f9e9ce1e28b685ebdc2d9af91494141fe0
MD5 ce6474db3cdb1d81945b300f48ab85ce
BLAKE2b-256 0fbbe558d320794560016d3fe19b599ff1cb711310bfee0850166ea049b4006b

See more details on using hashes here.

File details

Details for the file vault_service-0.2.5-py3-none-any.whl.

File metadata

  • Download URL: vault_service-0.2.5-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for vault_service-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 c5de915bec527b6c3daec2dccd86d71bc01bfb6aa76f17a9ef4a626f7bf0175d
MD5 a0b79dff2b296001eb4512edaaf2549e
BLAKE2b-256 7c5c384e2b858a436e6b41c7e3a2be8c731daea41d37c016f7c938d2696c6b8d

See more details on using hashes here.

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