Skip to main content

A simple secrets manager

Project description

A Simple Secrets Manager for python

How to use:

Storing

from SimpleSecretsManager import manager

secrets_manager = manager.SecretsManager("password", "file.bin")

secrets["MY_SECRET"] = "the_secret"
...

secrets_manager.update_secrets(secrets)
secrets_manager.update_secret("ANOTHER_SECRET", "the_other_secret")
secrets_manager.save()

There are 2 additional options when creating your SecretsManager, you can pass a non-default algorithm (defautls to Pbkdf2Algorithm):

from SimpleSecretsManager import manager, utility

algorithm = utility.Argon2Algorithm()

secrets_manager = manager.SecretsManager("password", "file.bin", algorithm=algorithm)

You can also choose to not have the password saved in memory:

from SimpleSecretsManager import manager

secrets_manager = manager.SecretsManager("password", "file.bin", save_password=False)

secrets_manager.update_secret("MY_SECRET", "the_secret")
# Must give password when saving if save_password = False, throws SecretsError otherwise
secrets_manager.save("password")

Note: when giving a password to save(), this will be used to encrypt the file, in place of whatever was orinally stored

Retrieving

from SimpleSecretsManager import manager

secrets_manager = manager.SecretsManager("password", "file.bin")

try:
    my_secret = secrets_manager.get_secret("MY_SECRET")
except SecretsError as e:
    print("Issue retrieving 'MY_SECRET': {e}")

By default, it will throw an error SecretsError if the secret does not exist. If you instead pass a default value, you'll be able to get that returned no matter what.

You can also use the secret manager with the 'with' clause so that it auto saves after:

with secrets_manager:
    secrets_manager.update_secret("MY_SECRET", "newvalue")

and then upon exiting, newvalue will be saved into "MY_SECRET"

Note: This won't work and will throw an error if used when save_password is false, since we won't be able to save the value when we get there

Provided under MIT License

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

simplesecretsmanager-0.5.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

simplesecretsmanager-0.5-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file simplesecretsmanager-0.5.tar.gz.

File metadata

  • Download URL: simplesecretsmanager-0.5.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.12 Linux/6.2.0-26-generic

File hashes

Hashes for simplesecretsmanager-0.5.tar.gz
Algorithm Hash digest
SHA256 02a03ee86db5fb84df441771c3897f9630d477ee3c10d6ab5a408ba39f11cd88
MD5 0a690c2aa3deedb44d9b572cb9254302
BLAKE2b-256 b030702e750dad2df80f4dce5da5b65416c69434ad9e543d900d9e258332e209

See more details on using hashes here.

Provenance

File details

Details for the file simplesecretsmanager-0.5-py3-none-any.whl.

File metadata

  • Download URL: simplesecretsmanager-0.5-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.12 Linux/6.2.0-26-generic

File hashes

Hashes for simplesecretsmanager-0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 7153d2e73389332e4636facebd8e2be484f04c3bdfcf30cb2c0a7e315a3c39b5
MD5 1c66ee536193ff8b5392ad6a36748644
BLAKE2b-256 c90431f23eaa93b1ec1bb7c26f1fd6543f1e474f0ad014932c22566cb44ea33a

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page