Skip to main content

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 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:

pip install -e .[dev]

Pushing updates

# First build the redistributable
python setup.py bdist_wheel sdist

# and then push it to pypi.org
twine upload dist/*

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

decode_server_flask-1.0.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

decode_server_flask-1.0.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file decode_server_flask-1.0.0.tar.gz.

File metadata

  • Download URL: decode_server_flask-1.0.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

File hashes

Hashes for decode_server_flask-1.0.0.tar.gz
Algorithm Hash digest
SHA256 75aa78ec9e4d2d6005731474d0172563eb7aef1db5657da02a98a0701ff4d9c1
MD5 3357ec9b8580a242327ef2da5eb7b6a4
BLAKE2b-256 3fdb67f20606bfd95c12a13abdd74d4effe35711f0374596e01f1e4ad8a0883c

See more details on using hashes here.

File details

Details for the file decode_server_flask-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: decode_server_flask-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

File hashes

Hashes for decode_server_flask-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5b5b33681d4c016dfc366bd8e43573e5dc129427cbf3f581fd775a4fcd127a1b
MD5 b571a97cec6157b3f2397a82be337179
BLAKE2b-256 bce9f0f6989178fcebea8fe5d40bc4068ba4965341b64540eea1df7be9aa86d0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page