pydantic2-settings-vault


Namepydantic2-settings-vault JSON
Version 1.0.1 PyPI version JSON
download
home_pageNone
SummaryA Pydantic v2 settings extension for secure configuration management using HashiCorp Vault OpenSource (OSS) and Enterprise
upload_time2024-10-21 13:54:50
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseMIT
keywords configuration enterprise hashicorp opensource pydantic python secrets management security settings vault
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Pydantic2-Settings-Vault

Pydantic2-Settings-Vault is a simple extension of Pydantic Settings to collect secrets from HashiCorp Vault OpenSource (OSS) and Enterprise

### Demonstration:

```python
from functools import lru_cache
from threading import Lock
from typing import Tuple, Type
from pydantic import Field, SecretStr
from pydantic_settings import (
    BaseSettings,
    PydanticBaseSettingsSource,
)
from pydantic2_settings_vault import VaultConfigSettingsSource

class AppSettings(BaseSettings):

    MY_SECRET: SecretStr = Field(
        ...,
        json_schema_extra={
            "vault_secret_path": "secret/data/test",
            "vault_secret_key": "FOO",  # pragma: allowlist secret
        },
    )
    
    @classmethod
    def settings_customise_sources(
        cls,
        settings_cls: Type[BaseSettings],
        init_settings: PydanticBaseSettingsSource,
        env_settings: PydanticBaseSettingsSource,
        dotenv_settings: PydanticBaseSettingsSource,
        file_secret_settings: PydanticBaseSettingsSource,
    ) -> Tuple[PydanticBaseSettingsSource, ...]:
        return (
            init_settings,
            env_settings,
            dotenv_settings,
            VaultConfigSettingsSource(settings_cls=settings_cls),
        )

# The connection to Vault is done via HTTP with AppRole authentication
import os
os.environ['VAULT_URL'] = "<configure it>"
os.environ['VAULT_ROLE_ID'] = "<configure it>"
os.environ['VAULT_SECRET_ID'] = "<configure it>"

# Only with Enterprise edition
os.environ['VAULT_NAMESPACE'] = "<configure it>"

# Usage
app_settings_lock = Lock()

@lru_cache
def get_app_settings() -> AppSettings:
    with app_settings_lock:
        return AppSettings()  # type: ignore
```

## Table of Contents

- [Pydantic2-Settings-Vault](#Pydantic2-Settings-Vault)
  - [Table of Contents](#table-of-contents)
  - [Description](#description)
  - [Installation](#installation)
  - [License](#license)
  - [Contact](#contact)

## Description

Pydantic2-Settings-Vault is a extension for Pydantic Settings that enables secure configuration management by integrating with HashiCorp Vault. This library supports both the open-source (OSS) and Enterprise versions of Vault, providing a seamless way to retrieve and manage secrets within your Pydantic-based applications. By leveraging Vault's robust security features, Pydantic2-Settings-Vault allows developers to easily incorporate secure secret management practices into their Python projects, enhancing overall application security and simplifying the handling of sensitive configuration data.

## Installation

```bash
# Install the dependency
pip install pydantic2-settings-vault
uv add pydantic2-settings-vault
poetry add pydantic2-settings-vault
```

## License

Pydantic2-Settings-Vault is released under the MIT License. See the [LICENSE](LICENSE) file for more details.

## Contact

For questions, suggestions, or issues related to Pydantic2-Settings-Vault, please open an issue on the GitHub repository.


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pydantic2-settings-vault",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "configuration, enterprise, hashicorp, opensource, pydantic, python, secrets management, security, settings, vault",
    "author": null,
    "author_email": "Sylvain Mouquet <sylvain.mouquet@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/0a/4c/c5acf375436886eab944aa1450cac25cc927a9089682a43da0142b72efee/pydantic2_settings_vault-1.0.1.tar.gz",
    "platform": null,
    "description": "# Pydantic2-Settings-Vault\n\nPydantic2-Settings-Vault is a simple extension of Pydantic Settings to collect secrets from HashiCorp Vault OpenSource (OSS) and Enterprise\n\n### Demonstration:\n\n```python\nfrom functools import lru_cache\nfrom threading import Lock\nfrom typing import Tuple, Type\nfrom pydantic import Field, SecretStr\nfrom pydantic_settings import (\n    BaseSettings,\n    PydanticBaseSettingsSource,\n)\nfrom pydantic2_settings_vault import VaultConfigSettingsSource\n\nclass AppSettings(BaseSettings):\n\n    MY_SECRET: SecretStr = Field(\n        ...,\n        json_schema_extra={\n            \"vault_secret_path\": \"secret/data/test\",\n            \"vault_secret_key\": \"FOO\",  # pragma: allowlist secret\n        },\n    )\n    \n    @classmethod\n    def settings_customise_sources(\n        cls,\n        settings_cls: Type[BaseSettings],\n        init_settings: PydanticBaseSettingsSource,\n        env_settings: PydanticBaseSettingsSource,\n        dotenv_settings: PydanticBaseSettingsSource,\n        file_secret_settings: PydanticBaseSettingsSource,\n    ) -> Tuple[PydanticBaseSettingsSource, ...]:\n        return (\n            init_settings,\n            env_settings,\n            dotenv_settings,\n            VaultConfigSettingsSource(settings_cls=settings_cls),\n        )\n\n# The connection to Vault is done via HTTP with AppRole authentication\nimport os\nos.environ['VAULT_URL'] = \"<configure it>\"\nos.environ['VAULT_ROLE_ID'] = \"<configure it>\"\nos.environ['VAULT_SECRET_ID'] = \"<configure it>\"\n\n# Only with Enterprise edition\nos.environ['VAULT_NAMESPACE'] = \"<configure it>\"\n\n# Usage\napp_settings_lock = Lock()\n\n@lru_cache\ndef get_app_settings() -> AppSettings:\n    with app_settings_lock:\n        return AppSettings()  # type: ignore\n```\n\n## Table of Contents\n\n- [Pydantic2-Settings-Vault](#Pydantic2-Settings-Vault)\n  - [Table of Contents](#table-of-contents)\n  - [Description](#description)\n  - [Installation](#installation)\n  - [License](#license)\n  - [Contact](#contact)\n\n## Description\n\nPydantic2-Settings-Vault is a extension for Pydantic Settings that enables secure configuration management by integrating with HashiCorp Vault. This library supports both the open-source (OSS) and Enterprise versions of Vault, providing a seamless way to retrieve and manage secrets within your Pydantic-based applications. By leveraging Vault's robust security features, Pydantic2-Settings-Vault allows developers to easily incorporate secure secret management practices into their Python projects, enhancing overall application security and simplifying the handling of sensitive configuration data.\n\n## Installation\n\n```bash\n# Install the dependency\npip install pydantic2-settings-vault\nuv add pydantic2-settings-vault\npoetry add pydantic2-settings-vault\n```\n\n## License\n\nPydantic2-Settings-Vault is released under the MIT License. See the [LICENSE](LICENSE) file for more details.\n\n## Contact\n\nFor questions, suggestions, or issues related to Pydantic2-Settings-Vault, please open an issue on the GitHub repository.\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Pydantic v2 settings extension for secure configuration management using HashiCorp Vault OpenSource (OSS) and Enterprise",
    "version": "1.0.1",
    "project_urls": {
        "changelog": "https://github.com/sylvainmouquet/pydantic2-settings-vault/releases",
        "documentation": "https://github.com/sylvainmouquet/pydantic2-settings-vault",
        "homepage": "https://github.com/sylvainmouquet/pydantic2-settings-vault",
        "repository": "https://github.com/sylvainmouquet/pydantic2-settings-vault"
    },
    "split_keywords": [
        "configuration",
        " enterprise",
        " hashicorp",
        " opensource",
        " pydantic",
        " python",
        " secrets management",
        " security",
        " settings",
        " vault"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7789e5f4c6fbe0b629029e0f670c6476c75ba10bd517bef0e9efad87f14c7d75",
                "md5": "974bac9a9ee46be0778c21458ce8d1d3",
                "sha256": "4519f8407320aee8306e5346b9da5a4423411484510d027f18713aaea578a493"
            },
            "downloads": -1,
            "filename": "pydantic2_settings_vault-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "974bac9a9ee46be0778c21458ce8d1d3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 5728,
            "upload_time": "2024-10-21T13:54:48",
            "upload_time_iso_8601": "2024-10-21T13:54:48.050132Z",
            "url": "https://files.pythonhosted.org/packages/77/89/e5f4c6fbe0b629029e0f670c6476c75ba10bd517bef0e9efad87f14c7d75/pydantic2_settings_vault-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0a4cc5acf375436886eab944aa1450cac25cc927a9089682a43da0142b72efee",
                "md5": "b3759568ed637bf7c299802f1402fe4c",
                "sha256": "5353d4033b7b055aa35fb2d4fea92e9e0530673fcc8425342be354b60051acea"
            },
            "downloads": -1,
            "filename": "pydantic2_settings_vault-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "b3759568ed637bf7c299802f1402fe4c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 64349,
            "upload_time": "2024-10-21T13:54:50",
            "upload_time_iso_8601": "2024-10-21T13:54:50.240408Z",
            "url": "https://files.pythonhosted.org/packages/0a/4c/c5acf375436886eab944aa1450cac25cc927a9089682a43da0142b72efee/pydantic2_settings_vault-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-21 13:54:50",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sylvainmouquet",
    "github_project": "pydantic2-settings-vault",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pydantic2-settings-vault"
}
        
Elapsed time: 0.38308s