Credential Manager
Project description
[![Build Status](https://travis-ci.org/OniOni/credentials.svg?branch=master)](https://travis-ci.org/OniOni/credentials)
# Installing
```shell
$ pip install credentials
```
# Usage
## Default
Using default setup, this will try and load credentials first from the processes environement variables and then from `~/.credentials.json`
```python
from credentials import credentials
# load credentials up front
creds = credentials.require(['cred1', 'cred2'])
function_that_needs_creds(creds.cred1)
...
# load credentials as needed
my_cred = credentials.load('cred_3')
function_that_needs_creds(my_cred)
...
```
## Setting up your own loader
```python
# Only load credentias from environement
from credentials import Credentials, EnvBackend
creds = Credentials([EnvBackend()])
...
```
# Implementing your own backend
A backend is just an object with a `load` method. Method should take a `key` as an argument and return the associated credentials or `None` if it could not be loaded.
Example:
```python
class UniversalCredLoader(object):
def load(self, key):
return 42
...
from credentials import Credentials
creds = Credentials([UniversalCredLoader()])
cred.load('cred1')
>>> 42
```
# Installing
```shell
$ pip install credentials
```
# Usage
## Default
Using default setup, this will try and load credentials first from the processes environement variables and then from `~/.credentials.json`
```python
from credentials import credentials
# load credentials up front
creds = credentials.require(['cred1', 'cred2'])
function_that_needs_creds(creds.cred1)
...
# load credentials as needed
my_cred = credentials.load('cred_3')
function_that_needs_creds(my_cred)
...
```
## Setting up your own loader
```python
# Only load credentias from environement
from credentials import Credentials, EnvBackend
creds = Credentials([EnvBackend()])
...
```
# Implementing your own backend
A backend is just an object with a `load` method. Method should take a `key` as an argument and return the associated credentials or `None` if it could not be loaded.
Example:
```python
class UniversalCredLoader(object):
def load(self, key):
return 42
...
from credentials import Credentials
creds = Credentials([UniversalCredLoader()])
cred.load('cred1')
>>> 42
```
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
File details
Details for the file credentials-1.1-py2.py3-none-any.whl
.
File metadata
- Download URL: credentials-1.1-py2.py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c2d4ffaac5ca264b5c7a4daf64306a571e5f01193ddbc9d5d2b79bd6650133e |
|
MD5 | 31aee02dc339dfb0982abab436d2f9e7 |
|
BLAKE2b-256 | 45d6e0555289e0139895366dd67f6b000c6834fcba84f7728a93f95de18440f9 |