Skip to main content

Qloud Integration for WSGI applications

Project description

Qloud Integration for WSGI Servers

qloud-wsgi is a WSGI middleware compatible with all frameworks that support WSGI, like Flask. It provides a simple way to integrate with Qloud.

Installation

pip install qloud-wsgi

Note, we currently only support Python 3.7 and above.

Usage

Flask

from flask import Flask, request
import qloud

SECRET = "YOUR_SECRET"

app = Flask(__name__)
app.wsgi_app = qloud.QloudAuthentication(app.wsgi_app, SECRET, credentials_required=False)

@app.route("/")
def hello_user():
    return request.environ.get("auth") or "Hello Anonymous!"

The SECRET is the secret key that you can find in the Qloud Console Dashboard, respectively, for the DevAuth environment it's fixed to 00000000000000000000000000000000.

The middleware injects the decoded JSON Web Token using the key auth into the environment of the request (e.g. environ["auth"] in plain WSGI, or request.environ.get("auth") in a Flask app). Our documentation has all the information of the fields present in the JWT.

Credentials Required

The credentials_required parameter is optional and defaults to False. For requests without a JSON Web Token, environ["auth"] will not be set.

If your application uses mandatory authentication, we recommend to set credentials_required to True, the integration itself will then also reject unauthenticated requests if they bypass the Proxy.

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

qloud-wsgi-0.2.0.tar.gz (3.9 kB view hashes)

Uploaded Source

Built Distribution

qloud_wsgi-0.2.0-py3-none-any.whl (3.6 kB view hashes)

Uploaded Python 3

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