Skip to main content

Minimal secrets interface for Money Ex Machina, supporting gopass and env backends

Project description

mxm-secrets

Version License Python Checked with pyright

Typed, authorization-aware secret resolution for the Money Ex Machina ecosystem.

mxm-secrets resolves public secret names into backend secret values using configured secret references, stores, policies, and runtime identity.

The package provides the Resolution layer of the MXM Runtime Context Architecture.

Purpose

mxm-secrets exists to separate:

application code

from:

secret storage
authorization
runtime identity
secret resolution

Applications should never:

  • hardcode secret values,
  • depend on gopass paths,
  • implement authorization logic,
  • or perform secret discovery themselves.

Instead, applications request secrets through a configured API:

secret = api.get_secret(
    secret_name="databento_api_key",
    identity=runtime_identity,
)

The package then:

resolves the secret reference
derives the principal
evaluates authorization
resolves the backend location
retrieves the secret value

Architecture

mxm-secrets implements the Resolution layer:

RuntimeIdentity
    ↓
Principal
    ↓
SecretPolicy
    ↓
Authorization
    ↓
SecretRef
    ↓
SecretStore
    ↓
ResolvedSecretLocation
    ↓
Backend Retrieval

The package accepts plain configuration data and can construct configured registries and API instances from that data.

Configuration discovery and loading remain the responsibility of mxm-runtime and mxm-config.

mxm-runtime

which constructs configured API instances from configuration data.

Core Concepts

RuntimeIdentity

Represents the operational runtime requesting access.

Example:

machine      bridge
environment  dev
role         marketdata

Runtime identity is always supplied explicitly.

Principal

Represents the operational authority requesting a secret.

Examples:

marketdata
execution
research
human_admin

Principals are derived from runtime identity.

SecretRef

Represents a logical secret reference.

Example:

SecretRef(
    name="databento_api_key",
    store="red",
    path="marketdata/databento/api_key",
    policy="marketdata_access",
)

Applications depend on secret names rather than storage locations.

SecretStore

Represents a configured secret authority.

Example:

SecretStore(
    name="red",
    backend="gopass",
    root="mxm/red",
)

SecretPolicy

Represents authorization rules.

Example:

SecretPolicy(
    name="marketdata_access",
    allowed_principals=(
        "marketdata",
        "research",
    ),
)

Resolution Flow

A secret request follows the path:

secret_name
    ↓
SecretRefRegistry
    ↓
RuntimeIdentity
    ↓
Principal
    ↓
SecretPolicyRegistry
    ↓
Policy Evaluation
    ↓
SecretStoreRegistry
    ↓
ResolvedSecretLocation
    ↓
Secret Retrieval
    ↓
secret value

Unauthorized requests fail before backend retrieval occurs.

Installation

Install from PyPI:

poetry add mxm-secrets

Or install from source:

git clone https://github.com/moneyexmachina/mxm-secrets.git
cd mxm-secrets
poetry install

Usage

Constructing a SecretsApi

The package is intentionally explicit.

Callers construct registries and provide them to SecretsApi.

Example:

api = SecretsApi.from_config_data(
    {
        "stores": {...},
        "refs": {...},
        "policies": {...},
    }
)

Advanced callers may construct registries directly, but the preferred construction path is through configuration data.

Configuration Shape

The package accepts plain configuration data with the structure:

stores:
  red:
    backend: gopass
    root: mxm/red

refs:
  databento_api_key:
    store: red
    path: marketdata/databento/api_key
    policy: marketdata_access

policies:
  marketdata_access:
    allowed_principals:
      - marketdata
      - research

This configuration is typically loaded by mxm-runtime from mxm-config and passed to:

SecretsApi.from_config_data(...)

Retrieving a Secret

secret = api.get_secret(
    secret_name="databento_api_key",
    identity=runtime_identity,
)

Authorization is evaluated automatically before secret retrieval.

Backend Support

Current backend support:

Backend Status
gopass Stable

The backend abstraction remains intentionally small.

Future backends may be added if required by MXM deployment architecture.

Security Model

mxm-secrets separates:

storage

from:

authorization

The existence of a secret in a backend does not imply authorization.

Authorization is evaluated through:

Principal
SecretPolicy
SecretPolicyRegistry

before retrieval occurs.

The package:

  • does not cache secrets,
  • does not preload secret collections,
  • does not expose backend paths to applications,
  • does not infer runtime identity,
  • does not perform configuration discovery.

Relationship To mxm-runtime

mxm-secrets provides semantics.

mxm-runtime provides materialisation.

Responsibilities are separated:

mxm-config
    owns configuration data

mxm-secrets
    owns resolution and authorization semantics

mxm-runtime
    owns assembly and RuntimeContext construction

Applications are expected to consume configured APIs through:

RuntimeContext

rather than constructing production APIs directly.

Development

Install development dependencies:

poetry install

Run formatting:

make fmt

Run linting:

make lint

Run static typing:

make type

Run tests:

make test

Run full validation:

make check

Run MXM package compliance validation:

mxm-foundry check .

Testing

The test suite includes coverage for:

  • secret references,
  • secret stores,
  • secret policies,
  • principals,
  • registries,
  • policy evaluation,
  • runtime identity mapping,
  • secret resolution,
  • backend retrieval,
  • API orchestration,
  • CLI diagnostics.

Tests are executed using:

pytest

Status

Current release status:

Resolution Layer Complete
Config-Driven Construction Complete
RuntimeContext Integration Pending

mxm-secrets now supports construction of configured registries and SecretsApi instances from plain configuration data.

RuntimeContext materialisation remains the responsibility of mxm-runtime.

License

MIT License. See LICENSE.

Links

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

mxm_secrets-0.3.2.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

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

mxm_secrets-0.3.2-py3-none-any.whl (28.4 kB view details)

Uploaded Python 3

File details

Details for the file mxm_secrets-0.3.2.tar.gz.

File metadata

  • Download URL: mxm_secrets-0.3.2.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mxm_secrets-0.3.2.tar.gz
Algorithm Hash digest
SHA256 c0e7a600c76cdb4039890dfc99da499d5605ea84a8944e492cc8fb43fff5dc69
MD5 b94be7aae493c2dc43328596aa71d698
BLAKE2b-256 e8f5eb96b7064a83fcbb5744f991ce8582d0d9e3a34e2fa520ffe87f9dd087e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for mxm_secrets-0.3.2.tar.gz:

Publisher: release.yml on moneyexmachina/mxm-secrets

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

File details

Details for the file mxm_secrets-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: mxm_secrets-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 28.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mxm_secrets-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 49d444d74c531bce2f49734cdfaeae45eea3bc4d7960d5a56b37fb3f8458caaa
MD5 615c24f104de4ff59e0fd5aa9e964a22
BLAKE2b-256 495b2114a4e045700dcd10f6334871a8e565aa70a9256b1f16db0903563b35f6

See more details on using hashes here.

Provenance

The following attestation bundles were made for mxm_secrets-0.3.2-py3-none-any.whl:

Publisher: release.yml on moneyexmachina/mxm-secrets

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