Flask middleware for Decode Auth
Project description
Decode Server Flask
A middleware for Flask for authenticating requests from Decode Auth Server.
Installing
Install using pip:
pip install decode_server_flask
A simple example
To integrate your Flask app with Decode Auth you only need to import the middleware and register it with the app. A simple example on how to do it:
from flask import Flask
from decode_server_flask import decode_server_flask
from os import environ
app = Flask(__name__)
# To setup the middleware, you need to get the Decode's RSA Public Key.
# You can read the key from a file or from an ENV variable.
app.config["DECODE_PUBLIC_KEY"] = os.environ["DECODE_PUBLIC_KEY"]
# Then just pass the key to the middleware
app.wsgi_app = decode_server_flask(app.wsgi_app, app.config["DECODE_PUBLIC_KEY"])
# Now all the routes are protected!
# To call them you need a valid JWT which only the Decode Auth server can generate.
@app.route("/me", methods=["GET"])
def me_api():
return {
"user": "Paul Muad'Dib",
"affiliation": "Fremen",
"house": "Atreides",
}
Developing
To install Decode Server Flask, alogn with the tools you need to develop and run tests, run the following in your virtualenv:
pip install -e .[dev]
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
Close
Hashes for decode_server_flask-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b386779f5a082324e9782a693d780821c1690d1ee0b2447028f64173422d70f0 |
|
MD5 | 98e3172cd96f5da3f1dd30eb549b6035 |
|
BLAKE2b-256 | 693c0e89295e5942bc4b3b3619ce79235a04c2985244f4d52127c99cb476ffa8 |
Close
Hashes for decode_server_flask-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d486e847ba7afff54b81164370584cbaae44bee39828abbd378dd13492e7076 |
|
MD5 | 6e88a3e7ad6d7f493c15b955eb732ce9 |
|
BLAKE2b-256 | 8721eb2c4eaf86ba6f31dc929483307e085fd67c8f9e7ff69dda7320ce9b2d50 |