Simple key management. Generate tokens for any usage.
Project description
FenKeysManagement
Simple key management. Generate tokens for any usage.
FenKeysManagement is a simple tool for manage and generate tokens that can be used in different applications. Like for example a flask API.
Usage
Key management
For managing your keyfile you have a command fenkm where you can add, see and revoke tokens.
usage: fenkm [-h] [genkey ...] [revokekey ...] [listkeys ...]
Simple key management. Generate tokens for any usage.
positional arguments:
genkey Generate a new key. Optional argument comment in the format comment=<comment>
revokekey Revoke a key. The format should be <key>=<value> where <key> cant be the id or the key directly
listkeys List all the key available
options:
-h, --help show this help message and exit
Module usage
As an example, here is a snippet of how I use this in some flask applications. This is not a working flask application, don't copy past without understanding it.
import json
from fenkeysmanagement import KeyManager
# ... more imports and flask related code
key_manager = KeyManager()
# .. more flask related code
def check_perms(request):
data_str = request.data.decode('utf-8')
try:
data_json = json.loads(data_str)
if "auth_key" in data_json.keys():
key_manager.reload_keys()
if not key_manager.key_revoked(data_json['auth_key']):
return True
return False
except json.decoder.JSONDecodeError:
return False
# ... more flask related code
@app.route("/", methods=["POST"])
def home():
if not check_perms(request):
# ... code for handle the failed auth verification
# ... code for handle the real request after correct auth verification
# ... more flask related code
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fenkeysmanagement-1.0.1.tar.gz.
File metadata
- Download URL: fenkeysmanagement-1.0.1.tar.gz
- Upload date:
- Size: 16.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20443ffc96f5631ac0f97fda392f0e03dac79f99ce7c5179f6e506329c1a8a45
|
|
| MD5 |
2c95b05c0c9de65545266db43c08f1fe
|
|
| BLAKE2b-256 |
5bcb7b2bf34d084313afc0ce3ef3f1505f36086d0cfaf3dff251935826548456
|
File details
Details for the file fenkeysmanagement-1.0.1-py3-none-any.whl.
File metadata
- Download URL: fenkeysmanagement-1.0.1-py3-none-any.whl
- Upload date:
- Size: 28.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57459b815c355576864d939a22341a19c5db648bb2e98e2747ea7a14050a0c93
|
|
| MD5 |
42a6cd301bd43b2f1c2f65c7cb945c7b
|
|
| BLAKE2b-256 |
90edef7ab207226358fc22d6ead1a20049507dcec8b84536df63786a64b533b8
|