Credential Manager
Project description
[![Build Status](https://travis-ci.org/OniOni/credentials.svg?branch=master)](https://travis-ci.org/OniOni/credentials)
[![Requirements Status](https://requires.io/github/OniOni/credentials/requirements.svg?branch=master)](https://requires.io/github/OniOni/credentials/requirements/?branch=master)
[![PyPI](https://img.shields.io/pypi/v/credentials.svg)](https://pypi-hypernode.com/pypi/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
```
[![Requirements Status](https://requires.io/github/OniOni/credentials/requirements.svg?branch=master)](https://requires.io/github/OniOni/credentials/requirements/?branch=master)
[![PyPI](https://img.shields.io/pypi/v/credentials.svg)](https://pypi-hypernode.com/pypi/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
```
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
credentials-sauce-1.1.tar.gz
(2.1 kB
view details)
File details
Details for the file credentials-sauce-1.1.tar.gz
.
File metadata
- Download URL: credentials-sauce-1.1.tar.gz
- Upload date:
- Size: 2.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6570f2317a1ec0e956813ca65060c424ad519d93c087bca1c2c2b1005542bc2c |
|
MD5 | 73388ae0421ff41f1be64d5e5c19c504 |
|
BLAKE2b-256 | 5905600845bc939b9f3827b7c3947de60b5b1d0124fd436a24f6bcbc57fb0c0d |