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.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a55863fe241d6d6f5792c16611c49bdd3197493b9e73efac34097b6b4c9f55c7 |
|
MD5 | 478315e369b8eecc66d73532f44c91d0 |
|
BLAKE2b-256 | 81571a8d0809b8744673ed63d9dda48031b346bbf83341134cef599b1ede833f |
Hashes for jsa_auth_middleware-0.0.3.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fafb840bf5c815e6a8d4ba8a24c514e8440dfc52748dbc6d1cd4584c20fd59f9 |
|
MD5 | b0595028fdceaa513a50f2968413fd19 |
|
BLAKE2b-256 | 1cd3fcc7b272d0c367a55d461fcb86e7a32be7c1e58ed86645bb2da2c737acc2 |