JetStream Authentication MiddleWare
Project description
JSA Auth Middleware is a python package built for integrating with JetStream across multiple micro-services, with the aim of handling authentication and Single-Sign-On while ensuring API security.
Quick start
Configure AUTH_BASE_URL in project settings pointing to the Authentication server without trailing slash
Add jsa_auth_middleware.JSAMiddleware to your MIDDLEWARE configuration in settings.py to validate authentication of all incoming requests. Maintain the order and hierarchy of middlewares, with Django middlewares above JSAMiddleware.
MIDDLEWARE = [ ... 'jsa_auth_middleware.JSAMiddleware', ]
Setup JSAMiddleware configuration in settings.py:
JSA_AUTH_MIDDLEWARE_CONFIG = { 'IGNORE_URLS': ( '<<URL_TO_IGNORE>>', ), 'IGNORE_STARTSWITH_URLS': ( '<<URL_TO_IGNORE>>', ), 'AUTH_BASE_URL': '', # optional if variable isn't in `settings.py` }
Import Query Response across application to define and process API response:
from jsa_auth_middleware.query_response import Response resp = Response() resp.failed() # on failure, using default failure status_code resp.message = '<<Some response message>>' resp.add_params('<<data_key>>', <<data_value>>) resp = Response() resp.passed() # on success, using default success status_code resp.message = '<<Some response message>>' resp.add_params('<<data_key>>', <<data_value>>) # Setting response status code resp.status_code = <<CustomStatusCode>>
NOTE
The IGNORE_STARTSWITH_URLS in JSA_AUTH_MIDDLEWARE_CONFIG has the following default pre-defined endpoints patterns to be ignored:
( "/admin/", "/swagger/", "/redoc/", )
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
Built Distribution
Hashes for jsa-auth-middleware-0.0.3.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e605072d26c7dbcbc0d68ca62d02a5d4e43978546b97a6dcb0d6b17262441abe |
|
MD5 | 953f00059b9534428190adf34bb0a405 |
|
BLAKE2b-256 | a22517209d889477757053cc09417e6d393cef25a75bd13e19a45e4e8a5658ae |
Hashes for jsa_auth_middleware-0.0.3.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57870a816d3bff840b254fa77b2344bf1fbdfb9174427749820466c287507633 |
|
MD5 | b7f0f6776b5dab91fc77d47c6395e3e9 |
|
BLAKE2b-256 | 665a97271df7f8d5fc875377d9be228d91da41fdd02ef88c840aacfa23b897fd |