summaryrefslogtreecommitdiff
path: root/jwt
Commit message (Collapse)AuthorAgeFilesLines
...
* Bump up version to v2.2.0 (#697)2.2.0José Padilla2021-10-061-1/+1
| | | Co-authored-by: José Padilla <jpadilla@users.noreply.github.com>
* Use timezone package as Python 3.5+ is required (#694)Kevin Kirsche2021-10-061-2/+2
| | | | | | | | | | | | | | | | | | | * Use timezone package as Python 3.5+ is required This method is deprecated: https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow Replaced with: https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow using: https://docs.python.org/3/library/datetime.html#datetime.timezone.utc which seems to indicate this was added in Python 3.2 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Chore: inline Variables that immediately Returned (#690)Yasser Tahiri2021-10-035-43/+35
| | | | | * Fix Inline variables & Refactor Code Expression * Fix Linting Issue
* Add support for Ed448/EdDSA. (#675)Ajitomi, Daisuke2021-10-031-18/+32
| | | | | * Add support for Ed448/EdDSA. * Add test for verification using EdDSA private key.
* Assume JWK is valid for signing if "use" is omitted (#668)Klavionik2021-08-121-1/+1
| | | | | * PyJWKClient: Assume JWK is intended for signing if 'use' claim is either 'sig' or not present * Update CHANGELOG
* Remove arbitrary kwargs. (#657)Ajitomi, Daisuke2021-08-082-12/+13
| | | | | * Remove arbitrary kwargs. * Update CHANGELOG.
* Make typ optional (#644)Ajitomi, Daisuke2021-08-081-0/+2
| | | | | | | | | | | | | | | | | | | | | * Make typ optional. * Update doc. * Update CHANGELOG. * Refine parameter order of for backward compatibility. * Remove comment. * Add Optional to typ. * Keep order of JWT header parameter (typ, alg). * Make typ optional with headers argument. * Make typ optional with headers argument. * Remove unused log.
* Prefer headers['alg'] to algorithm parameter in encode(). (#673)Ajitomi, Daisuke2021-08-052-2/+6
| | | | | | | | | | | * Prefer headers['alg'] to algorithm parameter in encode(). * Fix lack of @crypto_required. * Prefer headers['alg'] to algorithm parameter in encode(). * Prefer headers['alg'] to algorithm parameter in encode(). * Make algorithm parameter of encode() Optioanl explicitly.
* Fix aud validation to support {'aud': null} case. (#670)Ajitomi, Daisuke2021-07-301-8/+7
| | | | | * Fix aud validation to support {'aud': null} case. * Fix aud validation to support {'aud': null} case.
* Bump up version to v2.1.0 (#653)2.1.0José Padilla2021-04-281-1/+1
|
* Export PyJWK and PyJWKSet (#652)José Padilla2021-04-281-0/+3
| | | | | * Export PyJWK and PyJWKSet. Closes #646 * Update CHANGELOG
* Add to_jwk to Ed25519Algorithm. (#642) (#643)JohannesWill2021-04-281-0/+43
| | | | | | | | | | | | | | | * Add to_jwk to Ed25519Algorithm. (#642) * add test for invalid key * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * update CHANGELOG for #643 * remove alg from jwk Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Allow to verify with private key on ECAlgorithm, as well as on ↵Ajitomi, Daisuke2021-04-161-0/+2
| | | | | | | Ed25519Algorithm. (#645) * Add private key support for ECAlgorithm verify. * Update CHANGELOG.
* Support JWK without alg. (#624)Ajitomi, Daisuke2021-03-221-2/+31
| | | | | | | | | | | * Support JWK without alg. * Make kty mandatory on PyJWK. * Add tests for kty=OKP. * Add tests for OKP-type JWK. * Add support for ES256K.
* Add from_jwk to Ed25519Algorithm (Support kty: OKP). (#623)Ajitomi, Daisuke2021-03-181-0/+31
| | | | | * Support from_jwk on Ed25519Algorithm. * Update CHANGELOG.
* Add missing exceptions.InvalidKeyError to jwt module __init__ imports. (#620)Aaron Campbell2021-03-181-0/+2
| | | | | | | | | * Add missing exceptions.InvalidKeyError to jwt module __init__ imports. * flake8 * Update CHANGELOG.rst Co-authored-by: José Padilla <jpadilla@webapplicate.com>
* Support ES256K. (#629)Ajitomi, Daisuke2021-03-181-0/+9
| | | | | | | | | * Support ES256K. * Add tests for ES256K. * Add api_jws tests. * Update CHANGELOG.
* Cache signing keys (#611)Steven Pitts2021-02-271-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | * Cache the result of get_signing_key * Include URI in key for getting known signing keys * Add test_get_signing_key_caches_result test * Add test to make sure multiple uris are being distinguished in key caching * Ignore URI in caching * Use functools.lru_cache to cache signing keys * Allow opting out of key caching * Allow adjusting max cached keys * Add #611 change to CHANGELOG.rst * Update CHANGELOG.rst Co-authored-by: José Padilla <jpadilla@webapplicate.com> Co-authored-by: José Padilla <jpadilla@webapplicate.com>
* Validate claims if configured and verify_signature is not. (#608)Rémy HUBSCHER2021-02-151-3/+9
| | | | | | | * Validate claims if configured. * Remove secret and algorithm since we don't validate the signature. * Add changelog.
* Bump up version to 2.0.1 (#604)2.0.1José Padilla2021-01-171-1/+1
|
* Fix `from_jwk()` for all algorithms (#598)José Padilla2021-01-111-3/+15
| | | | | * Fix `from_jwk()` for all algorithms * Update CHANGELOG.rst
* Release 2.0.0 (#576)José Padilla2020-12-221-1/+1
| | | | | | | * Bump up version to 2.0.0 * Update usage docs * Update CHANGELOG
* Complete type hinting of jwks_client.py (#578)Jon Dufresne2020-12-211-7/+8
|
* Use generator expressions (#569)Jon Dufresne2020-12-211-1/+1
| | | | Avoids building a list in memory unnecessarily. Generator expressions are evaluated lazily.
* Simplify black configuration to be closer to upstream defaults (#568)Jon Dufresne2020-12-215-42/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* Prefer ModuleNotFoundError over ImportError (#565)Jon Dufresne2020-12-213-3/+3
| | | | | | | | | | | 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
|
* 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-195-43/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | 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-191-0/+1
|
* 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-171-4/+3
| | | | | | Follows upstream cryptography commit: https://github.com/pyca/cryptography/commit/5528a3182fdd6ed1c44c126d451a87bcf39e79de Since Python 3.2, this bytes to an int is a native feature.
* Tighten bytes/str boundaries and remove unnecessary coercing (#547)Jon Dufresne2020-12-173-29/+15
| | | | | | | | | | | | | | | | | | | 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.
* Enforce .encode() return type using mypy (#551)Jon Dufresne2020-12-172-2/+2
| | | Closes #505
* Refactor jwt/jwks_client.py without requests dependency (#546)Jon Dufresne2020-12-161-14/+5
| | | | | | | | | 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 unnecessary Unicode decoding before json.loads() (#542)Jon Dufresne2020-12-162-3/+3
| | | | | | | | 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-161-3/+3
| | | | | | | | | 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.
* Run pyupgrade to simplify code and use Python 3.6 syntax (#536)Jon Dufresne2020-12-163-5/+3
| | | | | | | | | | | | | | 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-162-3/+3
| | | | | | 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-164-37/+26
| | | | | | | | | | | | | | | | | | 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.
* 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-161-17/+16
| | | | | | | | | | | 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.
* Update version to 2.0.0a1 (#528)José Padilla2020-11-021-1/+1
| | | | | * Update version to 2.0.0a1 * Adjust project codecov target