A Python library for API key validation
Project description
API Key Gateway
A Python library that provides an @apikey_login decorator to validate API keys.
Features
- Automatically adds
--apikey/-aCLI parameter to decorated functions - Validates API keys using argon2id hashing algorithm
- Fetches valid public keys from a remote JSON endpoint
- Easy to use decorator interface
Installation
uv install apikey-gateway
Usage
from apikey_gateway import apikey_login
@apikey_login
def my_app():
print("API key validated successfully!")
# Your application logic here
if __name__ == "__main__":
my_app()
Run with:
python app.py --apikey your-secret-key
How It Works
- The user provides a secret API key via CLI parameter
- The library computes an argon2id hash of this secret key (using a fixed salt for reproducibility)
- It fetches the list of valid public keys from
https://apikeys.cyanru.com/keys/public-keys.json - If the computed hash matches any public key in the list, access is granted
JSON Format
The remote JSON should be a list of objects:
[
{"key_id": "test_key_123", "public_key": "argon2id_hash_here"},
{"key_id": "another_key", "public_key": "another_hash_here"}
]
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
apikey_gateway-0.1.1.tar.gz
(3.8 kB
view details)
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 apikey_gateway-0.1.1.tar.gz.
File metadata
- Download URL: apikey_gateway-0.1.1.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa991d54998d7b2e235e9c50d24f972bedf9504ddd8f7c7d0dd85c10524cdc37
|
|
| MD5 |
bea4b0fd13d8a3ba6f041d06beb33306
|
|
| BLAKE2b-256 |
36e8702ed4670646a0be622f7e5d949ed9406f539fa987ba3302027c10226faa
|
File details
Details for the file apikey_gateway-0.1.1-py3-none-any.whl.
File metadata
- Download URL: apikey_gateway-0.1.1-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
184c4fccff3721d074689d03c38cd11009a045cd271a1eeed6908d3086358e3d
|
|
| MD5 |
a000cc3f0ac5302f6137bfcfd8df93a8
|
|
| BLAKE2b-256 |
b2dfea661fd7af85ff078ef593a73cc2918b8bc6cc16928b126572065a18fc3e
|