jwt-authenticator


Namejwt-authenticator JSON
Version 1.11.1 PyPI version JSON
download
home_pageNone
SummarySimple JWT token flask service security library.
upload_time2024-10-28 19:38:20
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseThe MIT License (MIT) Copyright (c) 2019 Tele-Tracking Technologies, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords authentication flask jwt
VCS
bugtrack_url
requirements flask setuptools wheel tqdm twine python-jose pylint coverage bumpversion
Travis-CI
coveralls test coverage No coveralls.
            [![Build Status](https://github.com/TeleTrackingTechnologies/jwt_authenticator/actions/workflows/workflow.yml/badge.svg)
[![PyPI version](https://badge.fury.io/py/jwt-authenticator.svg)](https://badge.fury.io/py/jwt-authenticator)
# jwt_authenticator

jwt_authenticator is a simply python library for adding JWT token authentication/authorization in flask web sites/services. It controls access either by checking for just a validated token, or optionally, a single role claim from the token. Access is controlled by decorating the endpoint functions with an attribute.

## Installation

Use the package manager [pip](https://pip.pypa.io/en/stable/) to install jwt_authenticator.

```bash
pip install jwt-authenticator
```

If using RS256, you must also:
```bash
pip install cryptography
```

## Usage
In the main application initialization area

```python
from flask import Flask
from jwt_authenticator import AuthenticationHandler

APP = Flask(__name__)
AuthenticationHandler.load_configuration(APP)
```
In the endpoints

```python
from jwt_authenticator import AuthenticationHandler, AuthError

@api.route('/<name>', methods=['GET'])
@AuthenticationHandler.requires_auth("admin")
def get_one(name):
    return f"Hello {name}"

@api.route('/<name>', methods=['GET'])
@AuthenticationHandler.requires_auth()
def get_one(name):
    return f"Hello {name}"
```

## Configuration
jwt_authenticator requires two configuration values to work. These can be specified either in the normal Flask application configuration or as environment variables. Environment variable values will override application configuration values, when

```python
AuthenticationHanlder.load_configuration(app)
```
is called.

### APP.config (i.e. flask application configuration)

* SECRET - the key used to sign the JWT token. Option if JWKS_URL specified.
* AUDIENCE - the audience claim used in the JWT token
* JKWS_URL - [OPTIONAL] OIDC key discovery URL
* GROUPS_CLAIM - [OPTIONAL] which claim has the list of groups. Defaults to "groups"

### Environment Variables

* JWT_SECRET - will override SECRET
* JWT_AUDIENCE - will override AUDIENCE
* JWKS_URL - will override JWKS_URL
* GROUPS_CLAIM - will override GROUPS_CLAIM

## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

## Building
* Requires 'make'

```bash
make init
make test
make package
```

## License
[MIT](https://choosealicense.com/licenses/mit/)


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "jwt-authenticator",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "authentication, flask, jwt",
    "author": null,
    "author_email": "Mike Nacey <nobody@teletracking.com>",
    "download_url": "https://files.pythonhosted.org/packages/37/c1/ca2f38563f012ee32c8fccb4313395dbed0cca6b9732428ff95870e3d9e5/jwt_authenticator-1.11.1.tar.gz",
    "platform": null,
    "description": "[![Build Status](https://github.com/TeleTrackingTechnologies/jwt_authenticator/actions/workflows/workflow.yml/badge.svg)\n[![PyPI version](https://badge.fury.io/py/jwt-authenticator.svg)](https://badge.fury.io/py/jwt-authenticator)\n# jwt_authenticator\n\njwt_authenticator is a simply python library for adding JWT token authentication/authorization in flask web sites/services. It controls access either by checking for just a validated token, or optionally, a single role claim from the token. Access is controlled by decorating the endpoint functions with an attribute.\n\n## Installation\n\nUse the package manager [pip](https://pip.pypa.io/en/stable/) to install jwt_authenticator.\n\n```bash\npip install jwt-authenticator\n```\n\nIf using RS256, you must also:\n```bash\npip install cryptography\n```\n\n## Usage\nIn the main application initialization area\n\n```python\nfrom flask import Flask\nfrom jwt_authenticator import AuthenticationHandler\n\nAPP = Flask(__name__)\nAuthenticationHandler.load_configuration(APP)\n```\nIn the endpoints\n\n```python\nfrom jwt_authenticator import AuthenticationHandler, AuthError\n\n@api.route('/<name>', methods=['GET'])\n@AuthenticationHandler.requires_auth(\"admin\")\ndef get_one(name):\n    return f\"Hello {name}\"\n\n@api.route('/<name>', methods=['GET'])\n@AuthenticationHandler.requires_auth()\ndef get_one(name):\n    return f\"Hello {name}\"\n```\n\n## Configuration\njwt_authenticator requires two configuration values to work. These can be specified either in the normal Flask application configuration or as environment variables. Environment variable values will override application configuration values, when\n\n```python\nAuthenticationHanlder.load_configuration(app)\n```\nis called.\n\n### APP.config (i.e. flask application configuration)\n\n* SECRET - the key used to sign the JWT token. Option if JWKS_URL specified.\n* AUDIENCE - the audience claim used in the JWT token\n* JKWS_URL - [OPTIONAL] OIDC key discovery URL\n* GROUPS_CLAIM - [OPTIONAL] which claim has the list of groups. Defaults to \"groups\"\n\n### Environment Variables\n\n* JWT_SECRET - will override SECRET\n* JWT_AUDIENCE - will override AUDIENCE\n* JWKS_URL - will override JWKS_URL\n* GROUPS_CLAIM - will override GROUPS_CLAIM\n\n## Contributing\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\nPlease make sure to update tests as appropriate.\n\n## Building\n* Requires 'make'\n\n```bash\nmake init\nmake test\nmake package\n```\n\n## License\n[MIT](https://choosealicense.com/licenses/mit/)\n\n",
    "bugtrack_url": null,
    "license": "The MIT License (MIT)  Copyright (c) 2019 Tele-Tracking Technologies, Inc.  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "Simple JWT token flask service security library.",
    "version": "1.11.1",
    "project_urls": {
        "Source": "https://github.com/TeleTrackingTechnologies/jwt_authenticator"
    },
    "split_keywords": [
        "authentication",
        " flask",
        " jwt"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "63282569613287b92bcb228ada74a61a209d41566d888c99fbab84d6c1716f20",
                "md5": "aabf7623500fc2d5cd99b4004d8c7077",
                "sha256": "257e2f1aeee04c6923f7465e33735009d31c501f64680212e616181bf64072f4"
            },
            "downloads": -1,
            "filename": "jwt_authenticator-1.11.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "aabf7623500fc2d5cd99b4004d8c7077",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 5985,
            "upload_time": "2024-10-28T19:38:19",
            "upload_time_iso_8601": "2024-10-28T19:38:19.361347Z",
            "url": "https://files.pythonhosted.org/packages/63/28/2569613287b92bcb228ada74a61a209d41566d888c99fbab84d6c1716f20/jwt_authenticator-1.11.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "37c1ca2f38563f012ee32c8fccb4313395dbed0cca6b9732428ff95870e3d9e5",
                "md5": "cf3e178c9de1369cb68ad5051a06a305",
                "sha256": "0503cb7726165868b012cdaadab10e9d5ba59446188d3d3c2034df8418380bb1"
            },
            "downloads": -1,
            "filename": "jwt_authenticator-1.11.1.tar.gz",
            "has_sig": false,
            "md5_digest": "cf3e178c9de1369cb68ad5051a06a305",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 39551,
            "upload_time": "2024-10-28T19:38:20",
            "upload_time_iso_8601": "2024-10-28T19:38:20.966404Z",
            "url": "https://files.pythonhosted.org/packages/37/c1/ca2f38563f012ee32c8fccb4313395dbed0cca6b9732428ff95870e3d9e5/jwt_authenticator-1.11.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-28 19:38:20",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "TeleTrackingTechnologies",
    "github_project": "jwt_authenticator",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "flask",
            "specs": []
        },
        {
            "name": "setuptools",
            "specs": []
        },
        {
            "name": "wheel",
            "specs": []
        },
        {
            "name": "tqdm",
            "specs": []
        },
        {
            "name": "twine",
            "specs": []
        },
        {
            "name": "python-jose",
            "specs": []
        },
        {
            "name": "pylint",
            "specs": []
        },
        {
            "name": "coverage",
            "specs": []
        },
        {
            "name": "bumpversion",
            "specs": []
        }
    ],
    "lcname": "jwt-authenticator"
}
        
Elapsed time: 0.58011s