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.1.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.1-py3-none-any.whl (28.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mxm_secrets-0.3.1.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.1.tar.gz
Algorithm Hash digest
SHA256 6becee6fb9a9f3358762505ae5f20b027f3c01157c52736b03804f345ddca5cf
MD5 fd023f9131f2669838810ef9a5d490d7
BLAKE2b-256 621b1c106bdbddfba22256353fd5a5068c46c190514305940198b27deb34ef07

See more details on using hashes here.

Provenance

The following attestation bundles were made for mxm_secrets-0.3.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: mxm_secrets-0.3.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 21e248cf0406b80af8008b217672311cf7a04b45381ecbd1fd115ed69c1d037b
MD5 cb3c150d0f3dee1793491d094215e7d5
BLAKE2b-256 ee7dfabf8483d2f690428694665e2497206223640d89f09c408d3c4efd036c13

See more details on using hashes here.

Provenance

The following attestation bundles were made for mxm_secrets-0.3.1-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