Skip to content

Commit 685b9f6

Browse files
authored
fix: azure (keephq#3661)
1 parent 7264754 commit 685b9f6

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

ee/identitymanager/identity_managers/azuread/azuread_authverifier.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def _verify_bearer_token(
181181
# we will validate manually since we need to support both
182182
# v1 (sts.windows.net) and v2 (https://login.microsoftonline.com)
183183
"verify_iss": False,
184-
# "require" the standard claims but NOT "appid"
184+
# "require" the standard claims but NOT "appid" (search for 'azp' in this code to see the comment)
185185
"require": ["exp", "iat", "nbf", "iss", "sub"],
186186
}
187187

@@ -219,8 +219,19 @@ def _verify_bearer_token(
219219
)
220220

221221
# Validate the audience
222-
expected_aud = f"api://{self.client_id}"
223-
if payload.get("aud") != expected_aud:
222+
allowed_aud = [
223+
f"api://{self.client_id}", # v1 tokens
224+
f"{self.client_id}", # v2 tokens
225+
]
226+
if payload.get("aud") not in allowed_aud:
227+
self.logger.error(
228+
f"Invalid token audience: {payload.get('aud')}",
229+
extra={
230+
"tenant_id": self.tenant_id,
231+
"audience": payload.get("aud"),
232+
"allowed_aud": allowed_aud,
233+
},
234+
)
224235
raise HTTPException(
225236
status_code=401, detail="Invalid token audience"
226237
)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "keep"
3-
version = "0.37.8"
3+
version = "0.37.9"
44
description = "Alerting. for developers, by developers."
55
authors = ["Keep Alerting LTD"]
66
packages = [{include = "keep"}]

0 commit comments

Comments
 (0)