# Locker Secret Python SDK
<p align="center">
<img src="https://cystack.net/images/logo-black.svg" alt="CyStack" width="50%"/>
</p>
---
The Locker Secret Python SDK provides convenient access to the Locker Secret API from applications written in the
Python language. It includes a pre-defined set of classes for API resources that initialize themselves dynamically
from API responses which makes it compatible with a wide range of versions of the Locker Secret API.
## The Developer - CyStack
The Locker Secret Python SDK is developed by CyStack, one of the leading cybersecurity companies in Vietnam.
CyStack is a member of Vietnam Information Security Association (VNISA) and Vietnam Association of CyberSecurity
Product Development. CyStack is a partner providing security solutions and services for many large domestic and
international enterprises.
CyStack’s research has been featured at the world’s top security events such as BlackHat USA (USA),
BlackHat Asia (Singapore), T2Fi (Finland), XCon - XFocus (China)... CyStack experts have been honored by global
corporations such as Microsoft, Dell, Deloitte, D-link...
## Documentation
The documentation will be updated later.
## Requirements
- Python 3.6+
## Installation
Install from PyPip:
```
pip install --upgrade lockerpm
```
Install from source with:
```
python setup.py install
```
## Usages
### Set up access key
The SDK needs to be configured with your access key which is available in your Locker Secret Dashboard.
Initialize the `access_key` to its value.
You also need to set `api_base` value (default is `https://api.locker.io/locker_secrets`).
If you need to set your custom headers, you also need to set `headers` value in the `options` param:
```
from locker import Locker
access_key_id = "your_access_key_id..."
access_key_secret = "your_access_key_secret..."
api_base = "your_base_api.host"
headers = {
"cf-access-client-id": "",
"cf-access-client-secret": ""
}
locker = Locker(
access_key_id=access_key_id,
access_key_secret=access_key_secret,
api_base=api_base,
options={"headers": headers}
)
```
Now, you can use SDK to get or set values:
```
# Get list secrets quickly
secrets = locker.list()
# Get a secret value by secret key.
# If the Key does not exist, SDK will return the default_value
secret_value = locker.get_secret("REDIS_CONNECTION", default_value="TheDefaultValue")
print(secret_value)
# Get a secret value by secret key and specific environment name.
# If the Key does not exist, SDK will return the default_value
secret_value = locker.get_secret("REDIS_CONNECTION", environment_name="staging", default_value="TheDefaultValue")
print(secret_value)
# Create new secret
secret = locker.create(key="YOUR_NEW_SECRET_KEY", value="YOUR_NEW_SECRET_VALUE")
# Update new secret
secret = locker.modify(key="YOUR_NEW_SECRET_KEY", value="UPDATED_SECRET_VALUE")
# Update a secret value by secret key and a specific environment name
secret = locker.modify(key="REDIS_CONNECTION", environment_name="staging", value="staging.redis.connection")
print(secret.key, secret.value, secret.environment_name)
# List environments
environments = locker.list_environments()
# Get an environment object by name
environment = locker.get_environment("prod")
# Create new environment
new_environment = locker.create_environment(name="staging", external_url="staging.host")
# Update an environment by name
environment = locker.modify_environment(name="staging", external_url="new.staging.host")
```
### Logging
The library can be configured to emit logging that will give you better insight into what it's doing.
There are some levels: `debug`, `info`, `warning`, `error`.
The `info` logging level is usually most appropriate for production use,
but `debug` is also available for more verbosity.
There are a few options for enabling it:
1. Set the environment variable `LOCKER_LOG` to the value `debug`, `info`, `warning` or `error`
```sh
$ export LOCKER_LOG=debug
```
2. Set `log` when initializing the Locker object:
```python
from locker import Locker
locker = Locker(log="debug")
```
3. Enable it through Python's logging module:
```python
import logging
logging.basicConfig()
logging.getLogger('locker').setLevel(logging.DEBUG)
```
## Examples
See the [examples' folder](/examples).
## Development
First install for development.
```
pip install -r requirements-dev.txt
```
### Run tests
Test by using tox. We test against the following versions.
- 3.6
- 3.7
- 3.8
- 3.9
- 3.10
To run all tests against all versions, use:
```
tox
```
Run all tests for a specific Python version:
```
tox -e py3.10
```
Run all tests in a single file:
```
tox -e py3.10 -- tests/test_util.py
```
## Reporting security issues
We take the security and our users' trust very seriously. If you found a security issue in Locker SDK Python, please
report the issue by contacting us at <contact@locker.io>. Do not file an issue on the tracker.
## Contributing
Please check [CONTRIBUTING](CONTRIBUTING.md) before making a contribution.
## Help and media
- FAQ: https://support.locker.io
- Community Q&A: https://forum.locker.io
- News: https://locker.io/blog
## License
Raw data
{
"_id": null,
"home_page": "https://locker.io",
"name": "locker-secrets",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "django,vault management,security",
"author": "CyStack",
"author_email": "contact@locker.io",
"download_url": "https://files.pythonhosted.org/packages/52/8a/89055203fdab57efe668004cd4d0793cdd3f6d9c8f23635b0165c3b4a470/locker-secrets-0.1.8b1.tar.gz",
"platform": null,
"description": "# Locker Secret Python SDK\r\n\r\n<p align=\"center\">\r\n <img src=\"https://cystack.net/images/logo-black.svg\" alt=\"CyStack\" width=\"50%\"/>\r\n</p>\r\n\r\n \r\n---\r\n\r\nThe Locker Secret Python SDK provides convenient access to the Locker Secret API from applications written in the \r\nPython language. It includes a pre-defined set of classes for API resources that initialize themselves dynamically \r\nfrom API responses which makes it compatible with a wide range of versions of the Locker Secret API.\r\n\r\n\r\n## The Developer - CyStack\r\n\r\nThe Locker Secret Python SDK is developed by CyStack, one of the leading cybersecurity companies in Vietnam. \r\nCyStack is a member of Vietnam Information Security Association (VNISA) and Vietnam Association of CyberSecurity \r\nProduct Development. CyStack is a partner providing security solutions and services for many large domestic and \r\ninternational enterprises.\r\n\r\nCyStack\u00e2\u20ac\u2122s research has been featured at the world\u00e2\u20ac\u2122s top security events such as BlackHat USA (USA), \r\nBlackHat Asia (Singapore), T2Fi (Finland), XCon - XFocus (China)... CyStack experts have been honored by global \r\ncorporations such as Microsoft, Dell, Deloitte, D-link...\r\n\r\n\r\n## Documentation\r\n\r\nThe documentation will be updated later.\r\n\r\n## Requirements\r\n\r\n- Python 3.6+\r\n\r\n## Installation\r\n\r\nInstall from PyPip:\r\n\r\n```\r\npip install --upgrade lockerpm\r\n```\r\n\r\nInstall from source with:\r\n\r\n```\r\npython setup.py install\r\n```\r\n\r\n## Usages\r\n\r\n### Set up access key\r\n\r\nThe SDK needs to be configured with your access key which is available in your Locker Secret Dashboard. \r\nInitialize the `access_key` to its value. \r\nYou also need to set `api_base` value (default is `https://api.locker.io/locker_secrets`).\r\n\r\nIf you need to set your custom headers, you also need to set `headers` value in the `options` param:\r\n\r\n```\r\nfrom locker import Locker\r\n\r\naccess_key_id = \"your_access_key_id...\"\r\naccess_key_secret = \"your_access_key_secret...\"\r\napi_base = \"your_base_api.host\"\r\nheaders = {\r\n \"cf-access-client-id\": \"\",\r\n \"cf-access-client-secret\": \"\"\r\n}\r\n\r\nlocker = Locker(\r\n access_key_id=access_key_id, \r\n access_key_secret=access_key_secret, \r\n api_base=api_base, \r\n options={\"headers\": headers}\r\n)\r\n```\r\n\r\nNow, you can use SDK to get or set values:\r\n\r\n```\r\n# Get list secrets quickly\r\nsecrets = locker.list()\r\n\r\n# Get a secret value by secret key. \r\n# If the Key does not exist, SDK will return the default_value\r\nsecret_value = locker.get_secret(\"REDIS_CONNECTION\", default_value=\"TheDefaultValue\")\r\nprint(secret_value)\r\n\r\n# Get a secret value by secret key and specific environment name.\r\n# If the Key does not exist, SDK will return the default_value\r\nsecret_value = locker.get_secret(\"REDIS_CONNECTION\", environment_name=\"staging\", default_value=\"TheDefaultValue\")\r\nprint(secret_value)\r\n\r\n# Create new secret\r\nsecret = locker.create(key=\"YOUR_NEW_SECRET_KEY\", value=\"YOUR_NEW_SECRET_VALUE\")\r\n\r\n# Update new secret\r\nsecret = locker.modify(key=\"YOUR_NEW_SECRET_KEY\", value=\"UPDATED_SECRET_VALUE\")\r\n\r\n# Update a secret value by secret key and a specific environment name\r\nsecret = locker.modify(key=\"REDIS_CONNECTION\", environment_name=\"staging\", value=\"staging.redis.connection\")\r\nprint(secret.key, secret.value, secret.environment_name)\r\n\r\n# List environments\r\nenvironments = locker.list_environments()\r\n\r\n# Get an environment object by name\r\nenvironment = locker.get_environment(\"prod\")\r\n\r\n# Create new environment\r\nnew_environment = locker.create_environment(name=\"staging\", external_url=\"staging.host\")\r\n\r\n# Update an environment by name\r\nenvironment = locker.modify_environment(name=\"staging\", external_url=\"new.staging.host\")\r\n```\r\n\r\n### Logging\r\n\r\nThe library can be configured to emit logging that will give you better insight into what it's doing. \r\nThere are some levels: `debug`, `info`, `warning`, `error`.\r\n\r\nThe `info` logging level is usually most appropriate for production use, \r\nbut `debug` is also available for more verbosity.\r\n\r\nThere are a few options for enabling it:\r\n\r\n1. Set the environment variable `LOCKER_LOG` to the value `debug`, `info`, `warning` or `error`\r\n\r\n```sh\r\n$ export LOCKER_LOG=debug\r\n```\r\n\r\n2. Set `log` when initializing the Locker object:\r\n\r\n```python\r\nfrom locker import Locker\r\n\r\nlocker = Locker(log=\"debug\")\r\n```\r\n\r\n3. Enable it through Python's logging module:\r\n\r\n```python\r\nimport logging\r\nlogging.basicConfig()\r\nlogging.getLogger('locker').setLevel(logging.DEBUG)\r\n```\r\n\r\n\r\n## Examples\r\n\r\nSee the [examples' folder](/examples).\r\n\r\n## Development\r\n\r\nFirst install for development.\r\n```\r\npip install -r requirements-dev.txt\r\n```\r\n\r\n### Run tests\r\n\r\nTest by using tox. We test against the following versions.\r\n- 3.6\r\n- 3.7\r\n- 3.8\r\n- 3.9\r\n- 3.10\r\n\r\nTo run all tests against all versions, use:\r\n```\r\ntox\r\n```\r\n\r\nRun all tests for a specific Python version:\r\n```\r\ntox -e py3.10\r\n```\r\n\r\nRun all tests in a single file:\r\n```\r\ntox -e py3.10 -- tests/test_util.py\r\n```\r\n\r\n\r\n## Reporting security issues\r\n\r\nWe take the security and our users' trust very seriously. If you found a security issue in Locker SDK Python, please \r\nreport the issue by contacting us at <contact@locker.io>. Do not file an issue on the tracker. \r\n\r\n\r\n## Contributing\r\n\r\nPlease check [CONTRIBUTING](CONTRIBUTING.md) before making a contribution.\r\n\r\n\r\n## Help and media\r\n\r\n- FAQ: https://support.locker.io\r\n\r\n- Community Q&A: https://forum.locker.io\r\n\r\n- News: https://locker.io/blog\r\n\r\n\r\n## License\r\n",
"bugtrack_url": null,
"license": "",
"summary": "Locker Secret Python SDK",
"version": "0.1.8b1",
"project_urls": {
"Homepage": "https://locker.io"
},
"split_keywords": [
"django",
"vault management",
"security"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "528a89055203fdab57efe668004cd4d0793cdd3f6d9c8f23635b0165c3b4a470",
"md5": "2feef141fe6306b178fff6ec77098e6f",
"sha256": "5e80c94ec599e6d8b68bf1159e84f2a3983135971aa5f6b6febf946e46f3fc6a"
},
"downloads": -1,
"filename": "locker-secrets-0.1.8b1.tar.gz",
"has_sig": false,
"md5_digest": "2feef141fe6306b178fff6ec77098e6f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 9874878,
"upload_time": "2023-11-28T02:51:11",
"upload_time_iso_8601": "2023-11-28T02:51:11.330134Z",
"url": "https://files.pythonhosted.org/packages/52/8a/89055203fdab57efe668004cd4d0793cdd3f6d9c8f23635b0165c3b4a470/locker-secrets-0.1.8b1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-28 02:51:11",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "locker-secrets"
}