Page MenuHomeDevCentral

credentials.py
No OneTemporary

credentials.py

# -------------------------------------------------------------
# Nasqueron Reports :: Credentials :: Vault
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: Nasqueron
# Description: Read credentials from Vault or OpenBao
# License: BSD-2-Clause
# -------------------------------------------------------------
import os
from nasqueron_reports.credentials import vault
from nasqueron_reports.errors import NasqueronReportConfigError
# -------------------------------------------------------------
# Credentials wiring
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def resolve_credentials(config):
if config["driver"] == "vault":
return vault.fetch_credentials(config["secret"])
if config["driver"] == "env":
variables = config.get("variables", {})
return read_environment(variables)
raise NasqueronReportConfigError("Credentials driver parameter is missing")
# -------------------------------------------------------------
# Environment
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def read_environment(variables):
return {k:os.environ.get(v, "") for k, v in variables.items()}

File Metadata

Mime Type
text/x-python
Expires
Sun, Oct 12, 05:23 (1 d, 8 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3044169
Default Alt Text
credentials.py (1 KB)

Event Timeline