Skip to content

Commit 638306e

Browse files
broHerykyinan-symphony
authored andcommitted
use customized PyJwt instance to bypass subject verification (#355)
1 parent b0fa025 commit 638306e

File tree

6 files changed

+62
-50
lines changed

6 files changed

+62
-50
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ jobs:
5858
timeout-minutes: 10
5959

6060
- name: Upload test results
61-
uses: actions/upload-artifact@v3
61+
uses: actions/upload-artifact@v4
6262
with:
63-
name: pytest-results-${{ matrix.os }}
63+
name: pytest-results-${{ matrix.os }}-${{ matrix.python-version }}-${{ github.run_id }}
6464
path: test-results/junit.xml
6565
if: ${{ always() }}
6666

6767
- name: Upload test coverage
68-
uses: actions/upload-artifact@v3
68+
uses: actions/upload-artifact@v4
6969
with:
70-
name: pytest-coverage-${{ matrix.os }}
70+
name: pytest-coverage-${{ matrix.os }}-${{ matrix.python-version }}-${{ github.run_id }}
7171
path: htmlcov
7272
if: ${{ always() }}

.github/workflows/pylint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050

5151
- name: Upload Pylint results
5252
if: ${{ always() }}
53-
uses: actions/upload-artifact@v3
53+
uses: actions/upload-artifact@v4
5454
with:
5555
name: .pylint.d
5656
path: ~/.pylint.d

.github/workflows/semgrep.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on: [pull_request]
55
jobs:
66
semgrep:
77
name: run-semgrep
8-
runs-on: ubuntu-20.04
8+
runs-on: ubuntu-latest
99
container:
1010
image: returntocorp/semgrep
1111
steps:

poetry.lock

Lines changed: 50 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ packages = [
1212
]
1313

1414
[tool.poetry.dependencies]
15-
python = "^3.9"
15+
python = ">3.9.0,<3.9.1 || >3.9.1,<4.0"
1616
nulltype = "^2.3.1"
1717
python-dateutil = "^2.8.2"
1818
urllib3 = "^1.26.19"
1919
aiohttp = "^3.10.2"
2020
pyyaml = "^6.0"
2121
PyJWT = "^2.10.0"
22-
cryptography = "^43.0.1"
22+
cryptography = "^44.0.1"
2323
tenacity = "^8.0.1"
2424
defusedxml = "^0.7.1"
2525
docutils = "0.16"
@@ -30,6 +30,7 @@ pylint = "^2.6.0"
3030
pytest-cov = "^5.0.0"
3131
pytest-asyncio = "^0.24.0"
3232
Sphinx = "^4.4.0"
33+
jinja2 = "^3.1.6"
3334
recommonmark = "^0.7.1"
3435
furo = "^2022.3.4"
3536
hazelcast-python-client = "^5.0.1"

symphony/bdk/core/auth/jwt_helper.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"""
33
import datetime
44

5-
import jwt
5+
from jwt import PyJWT, DecodeError, ExpiredSignatureError
66
from cryptography.hazmat.primitives.serialization import Encoding, PublicFormat
77
from cryptography.x509 import load_pem_x509_certificate
88

@@ -13,6 +13,7 @@
1313

1414
DEFAULT_EXPIRATION_SECONDS = (5 * 50) - 10
1515

16+
jwt = PyJWT({"verify_sub": False})
1617

1718
def create_signed_jwt(private_key_config: BdkRsaKeyConfig, username: str, expiration: int = None) -> str:
1819
"""Creates a JWT with the provided user name and expiration date, signed with the provided private key.
@@ -57,7 +58,7 @@ def validate_jwt(jwt_token: str, certificate: str, allowed_audience: str) -> dic
5758
try:
5859
return jwt.decode(jwt_token, _parse_public_key_from_x509_cert(certificate),
5960
algorithms=[JWT_ENCRYPTION_ALGORITHM], audience=allowed_audience)
60-
except (jwt.DecodeError, jwt.ExpiredSignatureError) as exc:
61+
except (DecodeError, ExpiredSignatureError) as exc:
6162
raise AuthInitializationError("Unable to validate the jwt") from exc
6263

6364

0 commit comments

Comments
 (0)