Skip to content

Commit 0cce47e

Browse files
committed
fix: allow other authorized party for client_credentials
1 parent 8e4df16 commit 0cce47e

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

.github/workflows/publish.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
python-version: [3.8, 3.9]
13-
fail-fast: false
12+
python-version: [3.9]
1413

1514
steps:
1615
- uses: actions/checkout@v2

fastapi_third_party_auth/auth.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -239,15 +239,15 @@ def authenticate_user(
239239
},
240240
)
241241

242-
if self.client_id is not None:
243-
token_audience = id_token["aud"]
244-
if "azp" in id_token:
245-
if id_token["azp"] != self.client_id:
246-
raise JWTError(
247-
f"""Invalid authorized party "azp": {id_token["azp"]}"""
248-
)
249-
elif type(token_audience) == list and len(token_audience) >= 1:
250-
raise JWTError('Missing authorized party "azp" in IDToken')
242+
if (
243+
type(id_token["aud"]) == list
244+
and len(id_token["aud"]) >= 1
245+
and "azp" not in id_token
246+
):
247+
raise JWTError(
248+
'Missing authorized party "azp" in IDToken when there '
249+
"are multiple audiences"
250+
)
251251

252252
except (ExpiredSignatureError, JWTError, JWTClaimsError) as error:
253253
raise HTTPException(status_code=401, detail=f"Unauthorized: {error}")

0 commit comments

Comments
 (0)