Registry / auth-security / nsj-flask-auth

nsj-flask-auth

JSON →
library0.11.1pypypi✓ verified 83d ago

nsj-flask-auth is a basic module designed for authenticating Flask applications within the Nasajon ecosystem. It provides tools for JWT-based authentication, integrating with Flask routes via decorators. Currently at version 0.11.1, its release cadence is tied to internal Nasajon project needs, typically with updates released as new features or fixes are required.

pip install nsj-flask-auth
INSTALL
IMPORT
SIG · NSJ-FLASK-AUTH
N
nsj-flask-auth
auth-securitypythonv0.11.1
Install
2.8s avg
Import
Disk
24MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.11.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 25.9MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 2.8s · import 0.000s · 26MB
24MB installed
● package 24MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Auth
from nsj_flask_auth import Auth
from nsj_flask_auth.auth_manager import AuthManager

This quickstart demonstrates how to initialize `nsj-flask-auth` with a Flask application, configure essential settings like the JWT secret and token header, and protect a route using the `@auth_required` decorator. Configuration is pulled from `app.config`, which can be populated via environment variables for security and flexibility. Run this, then access `/protected` with a valid JWT in the Authorization header to test.

import os from flask import Flask, jsonify from nsj_flask_auth.auth_manager import AuthManager from nsj_flask_auth.decorator import auth_required app = Flask(__name__) # Configure authentication settings app.config['NSJ_AUTH_TOKEN_HEADER'] = os.environ.get('NSJ_AUTH_TOKEN_HEADER', 'Authorization') app.config['NSJ_AUTH_JWT_SECRET'] = os.environ.get('NSJ_AUTH_JWT_SECRET', 'your-super-secret-key-here') app.config['NSJ_AUTH_ALGORITHMS'] = os.environ.get('NSJ_AUTH_ALGORITHMS', 'HS256') # Comma-separated for multiple # Initialize AuthManager with the Flask app auth_manager = AuthManager(app) @app.route('/') def home(): return "Welcome! This route is public." @app.route('/protected') @auth_required def protected_route(): # Access current user info after authentication user_info = auth_manager.current_user() return jsonify({"message": "This is a protected route!", "user": user_info.to_dict()}) if __name__ == '__main__': # Example usage: Set environment variables or ensure app.config is properly set # For testing, you might use a tool like Postman to send a JWT token # in the 'Authorization' header: 'Bearer <your_jwt_token>' app.run(debug=True, port=5000)
Debug
Known issues
gotchaIncorrect or missing `NSJ_AUTH_JWT_SECRET` leads to `SignatureVerificationError` or `InvalidSignatureError`. The secret must match the one used to sign the JWT token.
fix
Ensure `app.config['NSJ_AUTH_JWT_SECRET']` is correctly set with the exact secret key used by your token issuer. Use environment variables for production secrets.
affects: All versions
gotchaMismatch in `NSJ_AUTH_TOKEN_HEADER` or `NSJ_AUTH_ALGORITHMS` prevents token detection or validation. Default is 'Authorization'.
fix
Verify that `app.config['NSJ_AUTH_TOKEN_HEADER']` matches the header where clients send the token (e.g., 'Authorization'). Also, confirm `app.config['NSJ_AUTH_ALGORITHMS']` includes the algorithm used to sign the token.
affects: All versions
breakingAs a pre-1.0 library, API changes can occur in minor versions (e.g., 0.10.x to 0.11.x) without strict adherence to semantic versioning for breaking changes, requiring careful review of release notes upon upgrade.
fix
Thoroughly review the GitHub repository's commit history or any available release notes before upgrading minor versions. Test applications extensively after any upgrade.
affects: <1.0.0
Upgrade
Version history
0.11.1latest on PyPI · released Apr 2, 2026
Audit
Dependencies
FlaskrequiredCore web framework integration.
PyJWTrequiredHandles JSON Web Token (JWT) encoding and decoding.
python-decouplerequiredUsed for strict separation of settings from code, typically for environment variables.
requestsrequiredPotentially used for internal API calls (e.g., to an identity provider).
nsj-authrequiredInternal Nasajon authentication library dependency.
Agent activity
18 hits · last 30 days
node
16
Amazon
1
OpenAI (training)
1
Resources
nsj-flask-auth — pip install nsj-flask-auth · libregistry