From 245785f409a562d3b876889a608b49263612e950 Mon Sep 17 00:00:00 2001 From: Paul Anton Letnes Date: Thu, 18 Feb 2021 14:15:17 +0100 Subject: [PATCH] Fix bytes -> str in pyjwt versions >= 2.x See github issue https://github.com/jpadilla/pyjwt/issues/391 for more details relevant for this fix. The fix caused a breaking change, triggering a major version update (1.x -> 2.x), and rendering pyjwt incompatible with python 2. The travis worker does not contain a working Rust toolchain and tries to build the `cryptography` module from source for the python3.6 environment. Some fixes to .travis.yml were done to alleviate this. --- .travis.yml | 10 +++++++--- Dockerfile | 6 +++--- README.md | 2 +- setup.py | 7 ++----- tests/jwt_tools.py | 2 +- tox.ini | 5 ++++- version.txt | 2 +- 7 files changed, 19 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index 832f6c8..4d62c63 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,11 +3,15 @@ language: python matrix: fast_finish: true include: - - python: 2.7 - env: TOXENV=py27 - python: 3.6 env: TOXENV=py36 + - python: 3.7 + env: TOXENV=py37 + - python: 3.8 + env: TOXENV=py38 +before_install: + - python -m pip install --upgrade virtualenv install: - - pip install tox + - pip install -U tox script: tox diff --git a/Dockerfile b/Dockerfile index f47449f..2c56b78 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,9 +4,9 @@ FROM python:3.6-slim -RUN apt-get update && apt-get install -y curl git python2.7 +RUN apt-get update && apt-get install -y curl git WORKDIR /root/home -RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && python get-pip.py +RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && python3 get-pip.py RUN git clone https://github.com/SAP/cloud-pysec WORKDIR /root/home/cloud-pysec -RUN pip install -r requirements-tests.txt +RUN pip3 install -r requirements-tests.txt diff --git a/README.md b/README.md index 216f09f..796a4b3 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ change the `USE_SAP_PY_JWT` environment variable to `true`. # Requirements -*sap_xssec* requires either *python 2.7* or *python 3.7*. +*sap_xssec* requires *python 3.6* or newer. # Download and Installation diff --git a/setup.py b/setup.py index 9677e85..fc5954e 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ 'deprecation>=2.1.0', 'requests>=2.21.0', 'six>=1.11.0', - 'pyjwt>=1.7.0', + 'pyjwt>=2.0.1', '{}'.format(sap_py_jwt_dep) ], long_description=LONG_DESCRIPTION, @@ -50,13 +50,10 @@ "Operating System :: POSIX :: Linux", "Operating System :: Microsoft :: Windows", "Programming Language :: Python", - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.4", - "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", ], diff --git a/tests/jwt_tools.py b/tests/jwt_tools.py index 38e2938..c1afc66 100644 --- a/tests/jwt_tools.py +++ b/tests/jwt_tools.py @@ -10,4 +10,4 @@ def sign(payload, headers=None): "kid": "key-id-0" } payload = {k: payload[k] for k in payload if payload[k] is not None} - return jwt.encode(payload, PRIVATE_KEY, algorithm="RS256", headers=headers).decode("utf-8") + return jwt.encode(payload, PRIVATE_KEY, algorithm="RS256", headers=headers) diff --git a/tox.ini b/tox.ini index 14bf2fc..bfacfa7 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,8 @@ [tox] -envlist = py27,py36 +envlist = py36,py37,py38 + [testenv] +allowlist_externals = env + deps = -rrequirements-tests.txt commands = env SAP_EXT_JWT_ALG=* python -m unittest discover diff --git a/version.txt b/version.txt index 7ec1d6d..4a36342 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -2.1.0 +3.0.0