Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 

156 wiersze
3.8 KiB

  1. Metadata-Version: 2.4
  2. Name: jwt
  3. Version: 1.4.0
  4. Summary: JSON Web Token library for Python 3.
  5. Author-email: Kohei YOSHIDA <kohei.yoshida@gehirn.co.jp>
  6. Project-URL: Repository, https://github.com/GehirnInc/python-jwt.git
  7. Classifier: Development Status :: 5 - Production/Stable
  8. Classifier: Intended Audience :: Developers
  9. Classifier: License :: OSI Approved :: Apache Software License
  10. Classifier: Operating System :: OS Independent
  11. Classifier: Programming Language :: Python
  12. Classifier: Programming Language :: Python :: 3.9
  13. Classifier: Programming Language :: Python :: 3.10
  14. Classifier: Programming Language :: Python :: 3.11
  15. Classifier: Programming Language :: Python :: 3.12
  16. Classifier: Programming Language :: Python :: 3.13
  17. Classifier: Topic :: Internet :: WWW/HTTP
  18. Classifier: Topic :: Security
  19. Classifier: Topic :: Software Development :: Libraries :: Python Modules
  20. Requires-Python: >=3.9
  21. Description-Content-Type: text/x-rst
  22. License-File: LICENSE
  23. Requires-Dist: cryptography!=3.4.0,>=3.1
  24. Provides-Extra: dev
  25. Requires-Dist: black; extra == "dev"
  26. Requires-Dist: isort; extra == "dev"
  27. Requires-Dist: mypy; extra == "dev"
  28. Requires-Dist: types-freezegun; extra == "dev"
  29. Provides-Extra: test
  30. Requires-Dist: pytest~=6.0; extra == "test"
  31. Requires-Dist: pytest-cov; extra == "test"
  32. Requires-Dist: freezegun; extra == "test"
  33. Dynamic: license-file
  34. .. image:: https://travis-ci.org/GehirnInc/python-jwt.svg?branch=master
  35. :target: https://travis-ci.org/GehirnInc/python-jwt
  36. .. image:: https://coveralls.io/repos/GehirnInc/python-jwt/badge.png?branch=master
  37. :target: https://coveralls.io/r/GehirnInc/python-jwt?branch=master
  38. .. image:: https://badge.fury.io/py/jwt.svg?dummy
  39. :target: http://badge.fury.io/py/jwt
  40. python-jwt
  41. ==========
  42. *python-jwt* is a JSON Web Token (JWT) implementation in Python developed by `Gehirn Inc`_.
  43. Examples
  44. --------
  45. .. code-block:: python
  46. import json
  47. from datetime import datetime, timedelta, timezone
  48. from jwt import (
  49. JWT,
  50. jwk_from_dict,
  51. jwk_from_pem,
  52. )
  53. from jwt.utils import get_int_from_datetime
  54. instance = JWT()
  55. message = {
  56. 'iss': 'https://example.com/',
  57. 'sub': 'yosida95',
  58. 'iat': get_int_from_datetime(datetime.now(timezone.utc)),
  59. 'exp': get_int_from_datetime(
  60. datetime.now(timezone.utc) + timedelta(hours=1)),
  61. }
  62. """
  63. Encode the message to JWT(JWS).
  64. """
  65. # Load a RSA key from a JWK dict.
  66. signing_key = jwk_from_dict({
  67. 'kty': 'RSA',
  68. 'e': 'AQAB',
  69. 'n': '...',
  70. 'd': '...'})
  71. # Or load a RSA key from a PEM file.
  72. with open('rsa_private_key.pem', 'rb') as fh:
  73. signing_key = jwk_from_pem(fh.read())
  74. # You can also load an octet key in the same manner as the RSA.
  75. # signing_key = jwk_from_dict({'kty': 'oct', 'k': '...'})
  76. compact_jws = instance.encode(message, signing_key, alg='RS256')
  77. """
  78. Decode the JWT with verifying the signature.
  79. """
  80. # Load a public key from PEM file corresponding to the signing private key.
  81. with open('rsa_public_key.json', 'r') as fh:
  82. verifying_key = jwk_from_dict(json.load(fh))
  83. message_received = instance.decode(
  84. compact_jws, verifying_key, do_time_check=True)
  85. """
  86. Successfuly retrieved the `message` from the `compact_jws`
  87. """
  88. assert message == message_received
  89. Installation
  90. ------------
  91. You can install python-jwt with pip.
  92. .. code-block:: shell
  93. $ pip install jwt
  94. Implementation Details
  95. -------------------------
  96. Supported Algorithms
  97. ~~~~~~~~~~~~~~~~~~~~
  98. - Unsecured
  99. - none (disabled by default for security)
  100. - Symmetric
  101. - HS256
  102. - HS384
  103. - HS512
  104. - Asymmetric
  105. - PS256
  106. - PS384
  107. - PS512
  108. - RS256
  109. - RS384
  110. - RS512
  111. Supported Python Versions
  112. ~~~~~~~~~~~~~~~~~~~~~~~~~
  113. - Python 3.6+
  114. License
  115. -------
  116. python-jwt is licensed under the Apache License version 2. See ./LICENSE.rst.
  117. .. _Gehirn Inc: http://www.gehirn.co.jp/