Flask Auth Middleware
Flask Auth Middlewawre is a middleware for securing flask application. It provides a convenient way to secure your Flask routes and endpoints using jwt tokens.
Features
- Seamless integration with Flask applications.
- Easily protect routes and endpoints with JWT authentication.
- Lightweight and designed for simplicity.
Requirements
Python 3
Installation
$ pip install flask_auth_middleware
Example
Create it
- Create a file
app.pywith:
from flask import Flask
from flask_auth_middleware import JWTAuthMiddleware
app = Flask(__name__)
app.wsgi_app = JWTAuthMiddleware(app, "your_secret_key")
@app.get("/")
def hello():
return "Hello, World!"
@app.get("/namaste")
def hello():
return "Namaste, World!"
Here all the routes of flask application will be protected by JWTAuthMiddleware.
If you want to secure selective routes. Then here you go:
from flask import Flask, jsonify, request
from flask_auth_middleware import login_required
app = Flask(__name__)
secret_key = "your_secret_key"
@app.route("/public")
def public_data():
return jsonify({"message": "This is public data"})
@app.route("/protected")
@login_required(secret_key=secret_key, algorithms=["HS256"])
def protected_route(decoded_payload):
# your logic with decoded payload
return jsonify(
{"message": "This is public data.", "decoded_payload": decoded_payload}
)
if __name__ == "__main__":
app.run(debug=True)
Contributing
Feel free to contribute to this project.
License
This project is licensed under the terms of the MIT license.
Metadata
Release files for flask-auth-middleware 0.3.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 |
|---|---|---|---|---|
| flask_auth_middleware-0.3.0.tar.gz | 5.1 kB | Without provenance | Details for flask_auth_middleware-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flask_auth_middleware-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for flask_auth_middleware-0.3.0-py3-none-any.whl |
Total release size: 10.6 kB
Release files / flask_auth_middleware-0.3.0.tar.gz
| Download URL | flask_auth_middleware-0.3.0.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5a50a5ef73810d2d9888ac05a6889fe8a6066edf4a280b98f7be96ca4595de18
|
|
BLAKE2b-256 checksum How to use checksums |
3f59453b175dfc08a8a4625d016ed556dd525f0e2e2a78f0552641e66d36a7b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / flask_auth_middleware-0.3.0-py3-none-any.whl
| Download URL | flask_auth_middleware-0.3.0-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
47e37cde795b0cf5ff6df39b168cf0b4dc955e472df356ed463ca1fdc45197dc
|
|
BLAKE2b-256 checksum How to use checksums |
18d2c952be5fa731adeddff9d759c6e9305cdfb124b93b329b6a06875a4ea36f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Security for flask-auth-middleware 0.3.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.