{"id":9990,"library":"nsj-flask-auth","title":"Nasajon Flask Authentication","description":"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.","status":"active","version":"0.11.1","language":"python","source_language":"en","source_url":"https://github.com/Nasajon/nsj-flask-auth","tags":["flask","authentication","auth","jwt","nasajon","security"],"install":[{"cmd":"pip install nsj-flask-auth","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core web framework integration.","package":"Flask","optional":false},{"reason":"Handles JSON Web Token (JWT) encoding and decoding.","package":"PyJWT","optional":false},{"reason":"Used for strict separation of settings from code, typically for environment variables.","package":"python-decouple","optional":false},{"reason":"Potentially used for internal API calls (e.g., to an identity provider).","package":"requests","optional":false},{"reason":"Internal Nasajon authentication library dependency.","package":"nsj-auth","optional":false}],"imports":[{"wrong":"from nsj_flask_auth.auth_manager import AuthManager","symbol":"Auth","correct":"from nsj_flask_auth import Auth"}],"quickstart":{"code":"import os\nfrom flask import Flask, jsonify\nfrom nsj_flask_auth.auth_manager import AuthManager\nfrom nsj_flask_auth.decorator import auth_required\n\napp = Flask(__name__)\n\n# Configure authentication settings\napp.config['NSJ_AUTH_TOKEN_HEADER'] = os.environ.get('NSJ_AUTH_TOKEN_HEADER', 'Authorization')\napp.config['NSJ_AUTH_JWT_SECRET'] = os.environ.get('NSJ_AUTH_JWT_SECRET', 'your-super-secret-key-here')\napp.config['NSJ_AUTH_ALGORITHMS'] = os.environ.get('NSJ_AUTH_ALGORITHMS', 'HS256') # Comma-separated for multiple\n\n# Initialize AuthManager with the Flask app\nauth_manager = AuthManager(app)\n\n@app.route('/')\ndef home():\n    return \"Welcome! This route is public.\"\n\n@app.route('/protected')\n@auth_required\ndef protected_route():\n    # Access current user info after authentication\n    user_info = auth_manager.current_user()\n    return jsonify({\"message\": \"This is a protected route!\", \"user\": user_info.to_dict()})\n\nif __name__ == '__main__':\n    # Example usage: Set environment variables or ensure app.config is properly set\n    # For testing, you might use a tool like Postman to send a JWT token\n    # in the 'Authorization' header: 'Bearer <your_jwt_token>'\n    app.run(debug=True, port=5000)","lang":"python","description":"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."},"warnings":[{"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.","message":"Incorrect or missing `NSJ_AUTH_JWT_SECRET` leads to `SignatureVerificationError` or `InvalidSignatureError`. The secret must match the one used to sign the JWT token.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"Mismatch in `NSJ_AUTH_TOKEN_HEADER` or `NSJ_AUTH_ALGORITHMS` prevents token detection or validation. Default is 'Authorization'.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Thoroughly review the GitHub repository's commit history or any available release notes before upgrading minor versions. Test applications extensively after any upgrade.","message":"As 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.","severity":"breaking","affected_versions":"<1.0.0"}],"env_vars":null,"search_vec":"'0.11.1':38 'applic':16 'auth':7,62 'authent':3,14,28,61 'base':27 'basic':10 'cadenc':41 'current':35 'decor':34 'design':12 'ecosystem':20 'featur':55 'fix':57 'flask':2,6,15,31,60 'integr':29 'intern':45 'jwt':26,63 'jwt-base':25 'modul':11 'nasajon':1,19,46,64 'need':48 'new':54 'nsj':5 'nsj-flask-auth':4 'project':47 'provid':22 'releas':40,52 'requir':59 'rout':32 'secur':65 'tie':43 'tool':23 'typic':49 'updat':51 'version':37 'via':33 'within':17","created_at":"2026-04-17T01:21:48.046935+00:00","updated_at":"2026-04-17T01:21:48.046935+00:00","problems":null,"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.11.1","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":"https://pypi.org/project/nsj-flask-auth/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["auth-security","web-framework"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-30","last_verified":"2026-06-30","next_check":"2026-07-30","install_tag":null}}