{ "info": { "author": "Nate Peterson", "author_email": "nate_peterson@byu.edu", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: Apache Software License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "# byu-jwt-python\nA python JWT validator that does all the BYU specific stuff as well as handle caching well-known and cert fetching\n\n# Installation\n`pip install byu_jwt`\n\n## API\n\n---\n**Note: It is important to declare the handler at a global level. This allows the caching of the well-known data as well as using the cache-control headers on the certificates only re-fetching those when cache-control has timed out. Reinitializing the class object will negate any benefit of the caching**\n\n---\nInstantiate the class and reuse the object to utilize caching:\n```python\nimport byu_jwt\nbyujwt = byu_jwt.JWT_Handler()\n```\n\n### Check only if JWT is valid\n```python\nassert byujwt.is_valid(jwt_to_validate)\n```\n\n### Decode JWT and Check validity\n```python\ntry:\n jwt = byujwt.decode(jwt_to_validate)\n return f\"Hello, {jwt['preferredFirstName']}\"\nexcept byu_jwt.exceptions.JWTVerifyError as ex_info:\n return \"Invalid JWT\"\nexcept byu_jwt.exceptions.JWTHandlerError as ex_info:\n return \"Error attempting to verify the jwt\"\n```\n\n### JWT Header Names\n\nBYU's API Manager creates an HTTP header that contains a signed [JWT](https://jwt.io/). The names of the designed BYU signed headers can be referenced here for lookup convenience.\n\n### BYU_JWT_HEADER_CURRENT\n\nThe property containing the name of the HTTP header that contains the BYU signed JWT sent directly from BYU's API Manager.\n\nValue is X-JWT-Assertion.\n\nExample\n\n```python\ncurrent_jwt_header = byu_jwt.JWT_HEADER\n```\n\n### BYU_JWT_HEADER_ORIGINAL\n\nThe property containing the name of the HTTP header that contains the BYU signed JWT forwarded on from a service that received the BYU signed JWT sent directly from BYU's API Manager.\n\nValue is X-JWT-Assertion-Original.\n\nExample\n\n```python\noriginal_jwt_header = byu_jwt.JWT_HEADER_ORIGINAL\n```\n\n### Example Python Lambda function that makes use of caching\n```python\nimport byu_jwt\n\nbyujwt = byu_jwt.JWT_Handler()\n\ndef handler(event, context):\n jwt_to_decode = event['headers'][byu_jwt.JWT_HEADER]\n try:\n jwt = byujwt.decode(jwt_to_validate)\n return {'statusCode': 200, 'body': f'Hello, {jwt[\"preferredFirstName\"]}'}\n except byu_jwt.exceptions.JWTVerifyError as ex_info:\n return {'statusCode': 403, 'body': \"Invalid JWT\"}\n except byu_jwt.exceptions.JWTHandlerError as ex_info:\n return {'statusCode': 500, 'body': \"Error attempting to verify the jwt\"}\n```\n\n\n### Example Decoded JWT Structure\n```json\n{\n \"iss\": \"https://api.byu.edu\",\n \"exp\": 1545425710,\n \"byu\": {\n \"client\": {\n \"byuId\": \"\",\n \"claimSource\": \"\",\n \"netId\": \"\",\n \"personId\": \"\",\n \"preferredFirstName\": \"\",\n \"prefix\": \"\",\n \"restOfName\": \"\",\n \"sortName\": \"\",\n \"subscriberNetId\": \"\",\n \"suffix\": \"\",\n \"surname\": \"\",\n \"surnamePosition\": \"\"\n },\n \"resourceOwner\": {\n \"byuId\": \"\",\n \"netId\": \"\",\n \"personId\": \"\",\n \"preferredFirstName\": \"\",\n \"prefix\": \"\",\n \"restOfName\": \"\",\n \"sortName\": \"\",\n \"suffix\": \"\",\n \"surname\": \"\",\n \"surnamePosition\": \"\"\n }\n },\n \"wso2\": {\n \"apiContext\": \"\",\n \"application\": {\n \"id\": \"\",\n \"name\": \"\",\n \"tier\": \"\"\n },\n \"clientId\": \"\",\n \"endUser\": \"\",\n \"endUserTenantId\": \"\",\n \"keyType\": \"\",\n \"subscriber\": \"\",\n \"tier\": \"\",\n \"userType\": \"\",\n \"version\": \"\"\n }\n}\n```", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/byu-oit/byu-jwt-python", "keywords": "", "license": "Apache-2.0", "maintainer": "Nate Peterson", "maintainer_email": "nate_peterson@byu.edu", "name": "byu-jwt", "package_url": "https://pypi.org/project/byu-jwt/", "platform": "", "project_url": "https://pypi.org/project/byu-jwt/", "project_urls": { "Homepage": "https://github.com/byu-oit/byu-jwt-python", "Repository": "https://github.com/byu-oit/byu-jwt-python" }, "release_url": "https://pypi.org/project/byu-jwt/2.0.0/", "requires_dist": [ "requests (>=2.21,<3.0)", "pyjwt (>=1.7,<2.0)", "cryptography (>=2.4,<3.0)" ], "requires_python": ">=3.4,<4.0", "summary": "", "version": "2.0.0" }, "last_serial": 4694804, "releases": { "1.1.0": [ { "comment_text": "", "digests": { "md5": "c7059db3d8a618fde05b42bcd5cc93df", "sha256": "85bcb5196e32eaa04246a9b8acc5222236177e2951cabaea4d4eb09f67cf13d9" }, "downloads": -1, "filename": "byu_jwt-1.1.0.tar.gz", "has_sig": false, "md5_digest": "c7059db3d8a618fde05b42bcd5cc93df", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2035, "upload_time": "2017-04-14T23:29:33", "url": "https://files.pythonhosted.org/packages/d2/d2/200f76f0e51544d410fb870d692461ccb4606db25c342a869ef40c081872/byu_jwt-1.1.0.tar.gz" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "78581999387315422747c5c8457e029a", "sha256": "c315d156a6eacf64e7f2bd8c491f2885873bd60ee1abdd521f7a08ffca3f7e66" }, "downloads": -1, "filename": "byu_jwt-1.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "78581999387315422747c5c8457e029a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8786, "upload_time": "2017-11-03T19:17:22", "url": "https://files.pythonhosted.org/packages/19/f8/196bc93946951c6d0cd0e20711c85d8512e4e8a6f6eb69defbeae032130c/byu_jwt-1.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e657b6322d9e88c0bdb0b0dffc6db39f", "sha256": "56c384e8d3eecbb7a91fff6f17e037d9b78b01708df68aa53b37545b77991397" }, "downloads": -1, "filename": "byu_jwt-1.1.1.tar.gz", "has_sig": false, "md5_digest": "e657b6322d9e88c0bdb0b0dffc6db39f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1984, "upload_time": "2017-11-03T19:17:22", "url": "https://files.pythonhosted.org/packages/a7/ef/c87e5d7dedbbe0974be56cf9cd8bdf4821480cb8323ed9dbd7eac10c2303/byu_jwt-1.1.1.tar.gz" } ], "1.1.2": [ { "comment_text": "", "digests": { "md5": "25a79fd8c56654bb4473a24db83fdf7e", "sha256": "4a6feb642c09eada27a7ed9b7817a8ff44f8c03288e3fa680318daf592bcb6e8" }, "downloads": -1, "filename": "byu_jwt-1.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "25a79fd8c56654bb4473a24db83fdf7e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 12423, "upload_time": "2017-11-03T19:48:24", "url": "https://files.pythonhosted.org/packages/cc/6b/bdb82e91a7d67305adcbf240d53b5459678a4202b0926f4e88fe07c34bd8/byu_jwt-1.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "63e8b484b3aea7978d4d036d960d6c98", "sha256": "f5c83dbe67ee063d0d421e617927e61356a2699767f8d5ef37280bfa3d3213e6" }, "downloads": -1, "filename": "byu_jwt-1.1.2.tar.gz", "has_sig": false, "md5_digest": "63e8b484b3aea7978d4d036d960d6c98", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5334, "upload_time": "2017-11-03T19:48:25", "url": "https://files.pythonhosted.org/packages/f8/ae/7efd24c44f11460fc27007d62033641037f49193aec0253ed722e6404fad/byu_jwt-1.1.2.tar.gz" } ], "1.1.3": [ { "comment_text": "", "digests": { "md5": "9e819fb88321738864eb3e338d7853e8", "sha256": "0d3b4368753291d83144f84c76a2c4f62aefbf127ba51deb77d00f161918089c" }, "downloads": -1, "filename": "byu_jwt-1.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "9e819fb88321738864eb3e338d7853e8", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 12522, "upload_time": "2017-11-03T19:59:22", "url": "https://files.pythonhosted.org/packages/79/20/9cd9dd04a9c3fa564dfb99a5a91c7ade83f81c5235ca6b114e3868d85ea2/byu_jwt-1.1.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "48a82ccc3c12cd0eb5e102abcf23940f", "sha256": "5956565f91c837389010517603d224c842d51c910030d7f6fde843cac2b2d39c" }, "downloads": -1, "filename": "byu_jwt-1.1.3.tar.gz", "has_sig": false, "md5_digest": "48a82ccc3c12cd0eb5e102abcf23940f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5394, "upload_time": "2017-11-03T19:59:23", "url": "https://files.pythonhosted.org/packages/c2/e3/399eb61cfa9f7de6363622a0fb0daa2499b1a4ad5d510af4bb2eb556e2c4/byu_jwt-1.1.3.tar.gz" } ], "2.0.0": [ { "comment_text": "", "digests": { "md5": "c2dc4f25f61dbbabf90e56e95b4d18b0", "sha256": "9d025861c1eb0d9976ecc1ba01b1ed9d67bb261410c52952cd22ee1cb97a67d6" }, "downloads": -1, "filename": "byu_jwt-2.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "c2dc4f25f61dbbabf90e56e95b4d18b0", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.4,<4.0", "size": 21546, "upload_time": "2019-01-14T15:57:04", "url": "https://files.pythonhosted.org/packages/84/78/9d57eed23cf71e45704e2e9ba52db846ef39fd0def641c0a7839b5428592/byu_jwt-2.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "854f3a3d96555bb9c12d2ba676e9cdcc", "sha256": "4799712bad572f9c34b9b57432920aac94def3f316cffedc21bfebb9c122bf10" }, "downloads": -1, "filename": "byu_jwt-2.0.0.tar.gz", "has_sig": false, "md5_digest": "854f3a3d96555bb9c12d2ba676e9cdcc", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.4,<4.0", "size": 8178, "upload_time": "2019-01-14T15:57:06", "url": "https://files.pythonhosted.org/packages/3e/4a/64df03b787c51f908583438a8925861102afeadbaaed4cf179365bbbca9a/byu_jwt-2.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c2dc4f25f61dbbabf90e56e95b4d18b0", "sha256": "9d025861c1eb0d9976ecc1ba01b1ed9d67bb261410c52952cd22ee1cb97a67d6" }, "downloads": -1, "filename": "byu_jwt-2.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "c2dc4f25f61dbbabf90e56e95b4d18b0", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.4,<4.0", "size": 21546, "upload_time": "2019-01-14T15:57:04", "url": "https://files.pythonhosted.org/packages/84/78/9d57eed23cf71e45704e2e9ba52db846ef39fd0def641c0a7839b5428592/byu_jwt-2.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "854f3a3d96555bb9c12d2ba676e9cdcc", "sha256": "4799712bad572f9c34b9b57432920aac94def3f316cffedc21bfebb9c122bf10" }, "downloads": -1, "filename": "byu_jwt-2.0.0.tar.gz", "has_sig": false, "md5_digest": "854f3a3d96555bb9c12d2ba676e9cdcc", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.4,<4.0", "size": 8178, "upload_time": "2019-01-14T15:57:06", "url": "https://files.pythonhosted.org/packages/3e/4a/64df03b787c51f908583438a8925861102afeadbaaed4cf179365bbbca9a/byu_jwt-2.0.0.tar.gz" } ] }