decode-server-flask-1.0.0
توضیحات
Flask middleware for Decode Auth
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | decode-server-flask-1.0.0 |
| نام | decode-server-flask |
| نسخه کتابخانه | 1.0.0 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Davor Badrov |
| ایمیل نویسنده | flask@decodeauth.com |
| آدرس صفحه اصلی | https://github.com/usedecode/decode_server |
| آدرس اینترنتی | https://pypi.org/project/decode-server-flask/ |
| مجوز | - |
# Decode Server Flask
A middleware for Flask for authenticating requests from [Decode Auth Server](https://decodeauth.com/).
## Installing
Install using pip:
```sh
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:
```python
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 an ENV variable.
decode_public_key = os.environ["DECODE_PUBLIC_KEY"]
# Or you can read the key from file.
public_key_file = open("decode-key.pub", "r")
decode_public_key = public_key_file.read()
# Then just pass the key to the middleware
app.wsgi_app = decode_server_flask(app.wsgi_app, 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:
```sh
pip install -e .[dev]
```
## Pushing updates
```sh
# First build the redistributable
python setup.py bdist_wheel sdist
# and then push it to pypi.org
twine upload dist/*
```
نیازمندی
| مقدار | نام |
|---|---|
| ~=1.1 | flask |
| ~=3.2 | python-jose |
| >=3.7 | pytest |
| >=3.2 | twine |
نحوه نصب
نصب پکیج whl decode-server-flask-1.0.0:
pip install decode-server-flask-1.0.0.whl
نصب پکیج tar.gz decode-server-flask-1.0.0:
pip install decode-server-flask-1.0.0.tar.gz