Skip to main content

PyPI - Version PyPI - Python Version PyPI - Types

SecureStore Python library

This repository/package houses a Python implementation of the cross-platform, language-agnostic SecureStore secrets specification. In particular, this library may be used for interacting with SecureStore secrets containers, providing an easy-to-use and idiomatic interface for loading SecureStore containers and decrypting/retrieving secrets from your frontend or backend application, interactively or with key-based decryption.

Usage

This python library is largely intended to be used alongside one of the SecureStore cli companion apps, used to create SecureStore values and manage (add/remove/update) the secrets stored therein. In this example, we'll be using the ssclient cli utility to create a new store.

Creating a secrets vault

Typical SecureStore usage begins by creating a new SecureStore "vault" (an encrypted secrets container) that will store the credentials (usually both usernames/access keys and passwords/api keys) that your app will need for one or more services. Begin by compiling or downloading and installing a copy of ssclient, the SecureStore companion cli.

While you can compile it yourself or manually download pre-built binaries for your platform, you might find it easiest to just install it with npm:

~> npm install --global @neosmart/ssclient

after which you can proceed with the following steps:

~> mkdir secure/
~> cd secure/
~> ssclient create --export-key secrets.key
Password: ************
Confirm Password: ************

# Now you can use `ssclient -p` with your password or
# `ssclient -k secrets.key` to get or set additional
# secrets using the same encryption/decryption key.

Adding secrets

Secrets may be added with your password or the equivalent encryption key file, and may be specified in-line as arguments to ssclient or more securely at a prompt by omitting the value when calling ssclient create:

# ssclient defaults to password-based decryption:
~> ssclient set aws:s3:accessId AKIAV4EXAMPLE7QWERT
Password: *********

similarly:

# Use `-k secrets.key` to load the encryption key and
# skip the prompt for the vault password:
~> ssclient -k secrets.key set aws:s3:accessKey
Value: v1Lp9X7mN2B5vR8zQ4tW1eY6uI0oP3aS5dF7gH9j

Retrieving secrets

Secrets can be retrieved at the commandline with ssclient or programmatically with a SecureStore library for your development language or framework of choice.

This library contains the python implementation of the SecureStore protocol. The SecureStore protocol was intentionally designed to maximize security and compatibility, and, as such, has minimal dependencies (only a dependency on cryptography and compatible with very old versions of python3).

This project has been uploaded to PyPi and can be installed with pip or your favorite modern alternative:

pip install securestore

after which you can use the library as follows:

from securestore import SecretsManager, KeySource

key = KeySource.from_file("secure/secrets.key")
sman = SecretsManager.from_file("secure/secrets.json", key)

# Retrieve and decrypt a specific secret
s3AccessId  = sman.get("aws:s3:accessId")
s3AccessKey = sman.get("aws:s3:accessKey")

# List all available keys in the vault
for key in sman.keys():
    print(f"* {key}")

Interactively decoding secrets

Normally you would use ssclient locally with password-based decryption to manage secrets in the secrets.json vault, then use key-based decryption to allow for securely decrypting the secrets at runtime without hardcoding any secrets, as shown above. But you can also use this library interactively (or otherwise) to decrypt a SecureStore vault using a password instead:

from securestore import SecretsManager

key = KeySource.from_password("MyPASsWOrd42")
sman = SecretsManager.from_file("secrets.json", key)

sman.get("aws:s3:accessId")
...

API overview

The SecureStore library provides a high-level interface for decrypting and accessing secrets stored in SecureStore v3 vaults.

The following types/classes/interfaces are exposed by this library:

SecretsManager

The primary class used to open vaults and retrieve secrets.

Method Description
from_file(path, key_source) Static. Opens a vault from a file on disk using a KeySource.
from_json(json_str, key_source) Static. Opens a vault from the contents of the SecureStore vault as (string or bytes).
from_dict(data, key_source) Static. Opens a vault from a pre-parsed dictionary.
get(name) Retrieves and decrypts the secret associated with name. Returns None if the key does not exist.
keys() Returns a list of all secret names (keys) available in the vault.

KeySource

An abstraction layer for authentication credentials. Use this to define how the vault should be unlocked.

Method Description
from_password(password) Static. For decrypting the vault with a password string.
from_file(path) Static. Loads a decryption key from a file (supports raw binary or ASCII-armored keys).
from_key(key) Static. Creates a key source from the contents of a key (supports bytes, str, or list of integers).

Metadata

Release files for securestore 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for securestore 0.1.2
File Size Uploaded Provenance Actions
securestore-0.1.2.tar.gz 56.7 kB Without provenance Details for securestore-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for securestore 0.1.2
File Interpreter ABI Platform Actions
securestore-0.1.2-py3-none-any.whl Python 3 none any Details for securestore-0.1.2-py3-none-any.whl

Total release size: 63.7 kB

Release files / securestore-0.1.2.tar.gz

Download URL securestore-0.1.2.tar.gz
Size 56.7 kB
Tags Source
SHA-256 checksum
How to use checksums
ca1c50043f294c23e5745e916a0521e823e023692a0cec8d81c9e93e77d1dccd
BLAKE2b-256 checksum
How to use checksums
aee00579a6ef13574940123d1566aa4b1c239033adc8fecbdd4e108746cf9aba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / securestore-0.1.2-py3-none-any.whl

Download URL securestore-0.1.2-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2616c62137c1d5d919fc6fd2acc9657fb3e6f13d1840de766d8162d1bd889a48
BLAKE2b-256 checksum
How to use checksums
ad8f7cd4ed05dcb5cd83ad72f861fd4ababf78c59a01d980303415e75c3b8047
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Security for securestore 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page