summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Update CHANGELOGprep-releaseJosé Padilla2020-12-211-16/+144
|
* Update usage docsJosé Padilla2020-12-211-0/+23
|
* Bump up version to 2.0.0José Padilla2020-12-211-1/+1
|
* Use generator expressions (#569)Jon Dufresne2020-12-211-1/+1
| | | | Avoids building a list in memory unnecessarily. Generator expressions are evaluated lazily.
* Drop lint environment from GitHub actions in favor of pre-commit.ci (#571)Jon Dufresne2020-12-211-1/+1
| | | | | | | The lint stage of CI is already handled by pre-commit.ci. With it, the extra run in GitHub action is redundant and only consumes time and resources unnecessarily. pre-commit.ci is also faster to respond with results.
* Simplify black configuration to be closer to upstream defaults (#568)Jon Dufresne2020-12-2113-163/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Simplify black configuration to be closer to upstream defaults Avoid extra configuration by simply going with Black defaults. This allows removing some configuration options, thus simplifying the overall configuration. It also makes the code style closer to community conventions. As more projects adopt black formatting, more code will look like the black defaults. Further, the default 88 tends to create more readable lines, IMO. The black rationale is located at: https://black.readthedocs.io/en/stable/the_black_code_style.html#line-length * Update tests/test_api_jws.py Co-authored-by: José Padilla <jpadilla@webapplicate.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update tests/test_api_jws.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: José Padilla <jpadilla@webapplicate.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Fix tox "docs" environment to pass (#567)Jon Dufresne2020-12-214-5/+9
| | | | | | | | - Fixed doctest which included incorrect output. - Use intersphinx to allow linking to Python JSONEncoder class. - Fix param types after previous str/bytes cleanups. - Fix param syntax to avoid vertical bar. The command `tox -e docs` now passes.
* Fix tox "manifest" environment to pass (#566)Jon Dufresne2020-12-215-15/+20
| | | | | | | | | | | | | | | | | | | | | * Fix tox "manifest" environment to pass The command `tox -e manifest` now passes. Added missing files to the sdist: - .pre-commit-config.yaml - CODE_OF_CONDUCT.md - jwt/py.typed - docs/ Alphabetized MANIFEST.in Moved .flake8 to setup.cfg to avoid the need to include yet another file to MANIFEST.in. Exclude codecov.yml. This is for CI only. * Move check-manifest to a pre-commit hook
* Prefer ModuleNotFoundError over ImportError (#565)Jon Dufresne2020-12-217-41/+38
| | | | | | | | | | | ModuleNotFoundError was introduced in Python 3. It is raised when the module does not exist. On the other hand, ImportError is raised during any import failure. For example, a syntax error or other runtime error. Using ModuleNotFoundError means that errors unrelated to a missing package will be propagated to the user. PyJWT doesn't know how to handle these. This also allows more functions to always be available for import
* Simplify from_base64url_uint() (#570)Jon Dufresne2020-12-211-4/+1
| | | | int.from_bytes() has been available since Python 3.2. Using it avoids string formatting.
* Type hint jwt.utils module (#564)Jon Dufresne2020-12-201-10/+12
|
* Bump up version to 2.0.0a22.0.0a2José Padilla2020-12-191-1/+1
|
* Autoupdate pre-commit hooks and apply them (#561)Jon Dufresne2020-12-192-4/+9
| | | https://pre-commit.com/#updating-hooks-automatically
* Add utility functions to assist test skipping (#563)Jon Dufresne2020-12-197-163/+76
|
* Remove unused argument "payload" from PyJWS._verify_signature() (#562)Jon Dufresne2020-12-191-2/+1
|
* Split PyJWT/PyJWS classes to tighten type interfaces (#559)Jon Dufresne2020-12-197-46/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | The class PyJWT was previously a subclass of PyJWS. However, this combination does not follow the Liskov substitution principle. That is, using PyJWT in place of a PyJWS would not produce correct results or follow type contracts. While these classes look to share a common interface it doesn't go beyond the method names "encode" and "decode" and so is merely superficial. The classes have been split into two. PyJWT now uses composition instead of inheritance to achieve the desired behavior. Splitting the classes in this way allowed for precising the type interfaces. The complete parameter to .decode() has been removed. This argument was used to alter the return type of .decode(). Now, there are two different methods with more explicit return types and values. The new method name is .decode_complete(). This fills the previous role filled by .decode(..., complete=True). Closes #554, #396, #394 Co-authored-by: Sam Bull <git@sambull.org> Co-authored-by: Sam Bull <git@sambull.org>
* Do not mutate the input payload in PyJWT.encode() (#557)Jon Dufresne2020-12-192-0/+7
|
* Simplify mocked_response test utility function (#560)Jon Dufresne2020-12-191-18/+14
| | | | No need to create a fixture with a nested function. This can be a simple utility function.
* Use direct indexing in PyJWKClient.get_signing_key_from_jwt() (#558)Jon Dufresne2020-12-191-1/+1
| | | | When complete=True is passed to api_jwt.decode() (aliased as decode_token()), the "header" key always exists.
* Tighten type checking of string values (#556)Jon Dufresne2020-12-172-4/+4
| | | In Python 3, these values will always be str.
* Replace merge_dict() with builtin dict unpacking generalizations (#555)Jon Dufresne2020-12-173-21/+7
| | | | | | | | Merging two dict is support since Python 3.5 using the ** syntax. See: - https://docs.python.org/3.9/whatsnew/3.5.html#whatsnew-pep-448 - https://www.python.org/dev/peps/pep-0448/
* Prefer direct indexing over options.get() (#552)Jon Dufresne2020-12-171-6/+6
| | | | | | Default options are set using PyJWT._get_default_options() therefore, there should never be a KeyError when indexing options directly. Enforce this expectation. Also avoids duplicating the default for the "require" option.
* Cleanup "noqa" comments (#553)Jon Dufresne2020-12-173-4/+7
| | | | - Remove "noqa" comments that are unnecessary - Remove unused imports from api_jwt.py
* Replace int_from_bytes() with builtin int.from_bytes() (#549)Jon Dufresne2020-12-173-29/+4
| | | | | | Follows upstream cryptography commit: https://github.com/pyca/cryptography/commit/5528a3182fdd6ed1c44c126d451a87bcf39e79de Since Python 3.2, this bytes to an int is a native feature.
* Replace codecs.open() with builtin open() (#548)Jon Dufresne2020-12-171-2/+1
| | | | Since Python 3, these two functions are functionally equivalent, so use the builtin one.
* Tighten bytes/str boundaries and remove unnecessary coercing (#547)Jon Dufresne2020-12-176-45/+21
| | | | | | | | | | | | | | | | | | | Now that the project is Python 3 only, the boundaries between bytes and Unicode strings is more explicit. This allows removing several unnecessary force_bytes() and force_unicode() calls that handled differences between Python 2 and Python 3. All uses of force_unicode() have been removed. For values that are known to be bytes, use `.decode()` instead. For values are that known to be str, use `.encode()` instead. This strategy makes the type explicit and reduces a function call. Key handling continues to use force_bytes() to allow callers to pass either bytes or str. To help enforce bytes/str handling in the future, the `-b` option is passed to Python when testing. This option will emit a warning if bytes and str are improperly mixed together.
* Update code blocks in docs (#545)Jon Dufresne2020-12-178-95/+82
| | | | | | | | | | | | | | | | | | | | | | | Update Python 2 syntax and drop Python-2-only examples. Fix all Python console prompts to the full ">>> " for correct highlighting. Use "pycon" instead of "python" for interactive Python console session. The "python" lexer is for Python scripts and doesn't interpret the ">>>" prompt. Fix all Python console code blocks to more accurately display what the user will see. For example, when assigning a value to a variable, it isn't also echoed. Fix typo ".. code::" → ".. code-block::". Use "console" instead of "sh" for shell sessions. The "sh" lexer is for shell scripts. For a complete list of lexers, see: https://pygments.org/docs/lexers/ Use blacken-docs to run black on code blocks. This is now included as a pre-commit hook.
* Enforce .encode() return type using mypy (#551)Jon Dufresne2020-12-172-2/+2
| | | Closes #505
* Replace force_bytes()/force_unicode() in tests with literals (#541)Jon Dufresne2020-12-172-117/+105
| | | | Now that Python 2 has been dropped, can safely use bytes literals (b"abc") and string literals.
* Refactor jwt/jwks_client.py without requests dependency (#546)Jon Dufresne2020-12-163-48/+45
| | | | | | | | | Allows dropping a dependency that isn't very necessary. The requests library was used for a single line of code. This same code is just as easily expressible using the stdlib, thus alllows removing a dependency. Tests were adjusted to mock this new approach.
* Remove deprecated arguments from docs (#544)Jon Dufresne2020-12-162-18/+4
| | | | They were removed from the code in f690976596bb74221f5a81fc9afffd5609bc4e70.
* Use existing key_path() utility function throughout tests (#540)Jon Dufresne2020-12-162-29/+31
|
* Remove unnecessary Unicode decoding before json.loads() (#542)Jon Dufresne2020-12-163-6/+6
| | | | | | | | Since Python 3.6, json.loads() accepts both Unicode and byte strings. https://docs.python.org/3/library/json.html#json.loads > Changed in version 3.6: s can now be of type bytes or bytearray. The > input encoding should be UTF-8, UTF-16 or UTF-32.
* Remove unnecessary force_bytes() calls priot to base64url_decode() (#543)Jon Dufresne2020-12-162-6/+6
| | | | | | | | | The first line of base64url_decode() is: if isinstance(input, str): input = input.encode("ascii") It therefore accepts either str or bytes. Don't bother coercing to bytes at the call site.
* Remove "Command line" sections from docs (#539)Jon Dufresne2020-12-162-30/+0
| | | | The CLI entry point was removed in commit 8a14f087c285bbe2f6e85ba4818e6c620b708d5d.
* Run pyupgrade to simplify code and use Python 3.6 syntax (#536)Jon Dufresne2020-12-168-79/+71
| | | | | | | | | | | | | | pyugrade is a command line tool to automatically update Python syntax to modern usage and patterns. For additional details, see: https://github.com/asottile/pyupgrade Changes made by the tool: - Use short Python3 super() syntax. - Use f-strings when they are simple and more readable. - Drop Python 2 u prefix from strings. - Drop "r" argument from open(). It is the default and so specifying it is unnecessary.
* Upgrade black version and usage (#538)Jon Dufresne2020-12-166-15/+15
| | | | | | Upgrade black to version 20.8b1 and specify that Python 3.6+ syntax should be used. Run it on all files to upgrade syntax.
* Update typing syntax and usage for Python 3.6+ (#535)Jon Dufresne2020-12-166-38/+37
| | | | | | | | | | | | | | | | | | Now that Python 2 is not supported, can move away from type comments to type annotation 🎉. The typing module is always available, so remove the guards. Specify the supported Python in the mypy configuration. Move other mypy configurations to one place. This way, whether tox is used or not, the same mypy errors appear. Distribute and install PEP-561 compliant py.typed file. When PyJWT is a imported as a library, this tells mypy to use the provided type annotations rather than going through typeshed. This way, the types are always up to date when running mypy. Remove outdated ignores since dropping Python 2.
* Drop unknown pytest config option: strict (#537)Jon Dufresne2020-12-161-1/+0
| | | | | | | | Fixes the warning when running tests: .tox/.../lib/python3.9/site-packages/_pytest/config/__init__.py:1233 .../pyjwt/.tox/.../lib/python3.9/site-packages/_pytest/config/__init__.py:1233: PytestConfigWarning: Unknown config option: strict self._warn_or_fail_if_strict(f"Unknown config option: {key}\n")
* Remove unused argument "verify" from PyJWS.decode() (#534)Jon Dufresne2020-12-161-1/+0
| | | | The method signature of PyJWT.decode() now matches the parent PyJWS.decode().
* Upgrade to isort 5 and adjust configurations (#533)Jon Dufresne2020-12-165-38/+27
| | | | | | | | | | | With isort 5, asottile/seed-isort-config is deprecated and unnecessary. The official isort main repo now has a pre-commit hook file. isort is now better at recognizing first party and third party packages. isort can now handle imports inside blocks, files have been updated. isort now supports "profiles" for simpler configuration.
* Avoid loading token twice in pyjwt.decode (#506)Federico Caselli2020-12-121-2/+0
| | | Removes a call to _load that was unused.
* Remove support for EOL Python 3.5 (#532)Jon Dufresne2020-12-071-2/+1
| | | | Python 3.5 went end-of-life 2020-09-30. See: https://devguide.python.org/devcycle/#end-of-life-branches
* add EdDSA to docs (#531)Nutchanon Ninyawee2020-11-131-0/+1
| | | https://github.com/jpadilla/pyjwt/pull/455
* Fix usage example (#530)Michal Čihař2020-11-101-1/+1
| | | The algorithms parameter for decode accepts list not a string.
* Update api.rstJosé Padilla2020-11-041-1/+1
|
* Fix Example Usage in docs2.0.0a1José Padilla2020-11-021-1/+0
|
* Add long_description_content_typeJosé Padilla2020-11-021-0/+1
|
* Update authorsJosé Padilla2020-11-023-30/+8
|
* Fix manifest orderJosé Padilla2020-11-021-1/+1
|