MicroJWT
MicroJWT is a simple implementation of JSON Web Tokens (JWT) specifically designed for use in MicroPython. This project utilizes HMAC-SHA256 for signing tokens and employs basic user information (such as username and role) within the token itself. It allows you to create secure authentication systems on embedded systems, especially microcontrollers running MicroPython, like ESP8266, ESP32, and other similar devices.
Goal of the Project
The goal of MicroJWT is to provide a lightweight, easy-to-use JWT solution for embedded systems and microcontrollers. With MicroPython being a minimalistic environment, this package aims to deliver a robust authentication mechanism without requiring heavy resources, making it ideal for IoT devices and embedded applications.
JWT is commonly used in web applications for stateless authentication. MicroJWT brings this functionality to the world of embedded systems, allowing your devices to securely authenticate with external systems or APIs.
Features
- HMAC-SHA256 Signing: Provides a secure way of signing and verifying tokens using HMAC and SHA-256.
- Lightweight: Designed with minimal overhead, making it suitable for resource-constrained devices.
- Compatibility: Works seamlessly with MicroPython, making it compatible with popular microcontrollers like ESP8266, ESP32, and others.
- Security: Supports secure token creation and verification, including expiration time (exp) to prevent token replay attacks.
Installation
To install MicroJWT, you can use pip:
for MicroPython, use the appropriate package manager like upip to install directly on your microcontroller.
upip install microjwt
Usage
Here is an example of how to create and verify a JWT token:
from microjwt.core import microjwt
# Define the secret key
secret_key = "my_secret_key"
# Create a JWT token
token = microjwt.create_token("Arman", "admin", secret_key)
# Verify the token
is_valid = microjwt.verify_token(token, secret_key)
if is_valid:
print("The token is valid.")
else:
print("The token is invalid.")
License
This project is licensed under the MIT License.
Test Images
Metadata
Release files for microjwt 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| microjwt-0.1.0.tar.gz | 5.4 kB | Without provenance | Details for microjwt-0.1.0.tar.gz |
Release files / microjwt-0.1.0.tar.gz
| Download URL | microjwt-0.1.0.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d8714dade6138ae65e01d3743239722e8462374c7564754701879cb7f8503abe
|
|
BLAKE2b-256 checksum How to use checksums |
3a5c7e31b73773efca7055da937d6c073c5dead4c7a27c11a058ad445f716ec9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.0
|
Security for microjwt 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.