Wrapper for the StoredSafe REST-like API.
Project description
StoredSafe Python
Transparent Python wrapper for the StoredSafe REST-like API.
Full documentation of the API response signatures and more advanced paramters can be found at the StoredSafe API Documentation.
Install
Install storedsafe from pypi.
pip install storedsafe
Examples
Login
# Initial configuration
api = StoredSafe(host='my.site.com', apikey='my-apikey')
# Login using TOTP
api.login_totp(username='my-username', passphrase='my-passphrase', otp='my-timed-otp')
# Login using YubiKey
api.login_yubikey(username='my-username', passphrase='my-passphrase', otp='my-yubico-otp')
In the event you already have a token, you can skip the previous step and input the token directly.
api = StoredSafe(host='my.site.com', token='my-storedsafe-token')
If you're using the StoredSafe tokenhandler, you can also retrieve the host, apikey and token from an rc-file:
# Default rc location
api = StoredSafe.from_rc()
# Custom rc location
api = StoredSafe.from_rc(path='/path/to/rc-file')
Programming styles
For create and edit methods, parameters can be easily passed as keyword arguments, for example:
api.create_vault(vaultname="My Vault", policy=7, description="Sercret")
Or if you're receiving data in dict-format, it can be unpacked into the method:
data = function_that_returns_data()
api.create_vault(**data)
Return types
The return value of all methods is a requests
response object. To obtain the data returned by a successful response object, you can use the json()
function:
r = api.list_vaults()
if <= 403:
data = res.json()
if res.ok:
print(data['VAULTS'])
else:
print(data['ERRORS'])
Usage
from storedsafe import StoredSafe
# Manual configuration
api = StoredSafe(host='my.site.com', apikey='my-apikey', token='my-storedsafe-token')
# Automatic configuration
api = StoredSafe.from_rc() # Use default path ~/.storedsafe-client.rc
api = StoredSafe.from_rc(path='/path/to/rc-file')
# Auth
api.login_totp(username='my-username', passphrase='my-passphrase', otp='my-otp')
api.login_yubikey(username='my-username', passphrase='my-passphrase', otp='my-otp')
api.logout()
api.check()
# Vaults
api.list_vaults()
api.vault_objects(vault_id) # String or integer
api.vault_members(vault_id)
api.create_vault(**params) # See parameters in API documentation
api.edit_vault(vault_id, **params)
api.delete_vault(vault_id)
# Objects
api.get_object(object_id) # String or integer
api.get_object(object_id, children=True) # children False by default
api.decrypt_object(object_id)
api.create_object(**params)
api.edit_object(object_id, **params)
api.delete_object(object_id)
# Users
api.list_users() # List all users
api.list_users(search_string) # Search for any user matching search_string
api.get_user(user_id)
api.create_user(**params)
api.edit_user(user_id, **params)
api.delete_user(user_id)
# Utils
api.status_values()
api.password_policies()
api.version()
api.generate_password() # Use default settings
api.generate_password(**params)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file storedsafe-1.1.0.tar.gz
.
File metadata
- Download URL: storedsafe-1.1.0.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76b45e8e5b12e22be452f5844503dddfea31d5891891127a7f7b3f10140eca4a |
|
MD5 | 59d05b9668d24385a7149ab5188d186b |
|
BLAKE2b-256 | 404ab231dec3c44400db692b496d7e7c31bc530f48377d2999d641e86be6c617 |
File details
Details for the file storedsafe-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: storedsafe-1.1.0-py3-none-any.whl
- Upload date:
- Size: 16.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c4ec61af49bbd49d8708e5a01eaf24938fdd467a0df2ea1ab9b503890aa8f2b |
|
MD5 | 3c7dbdd7397bdbde90e9b487e9d836ea |
|
BLAKE2b-256 | 35f20ba04cc79f6762bd1f3926c7c421dba6b874f6cffd987eb8144612d13d95 |