Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(oauth): skip empty client application lookups (#92160)

Oliver Brownec18803a9ee2a
diff --git a/posthog/api/oauth/test_client_auth.py b/posthog/api/oauth/test_client_auth.py
index 1307f7b14830..ede58c1f069e 100644
--- a/posthog/api/oauth/test_client_auth.py
+++ b/posthog/api/oauth/test_client_auth.py
@@ -1,3 +1,5 @@
+from types import SimpleNamespace
+
from django.contrib.auth.hashers import make_password
from django.test import SimpleTestCase
@@ -33,6 +35,10 @@ class TestVerifyClientSecret(SimpleTestCase):
assert OAuthValidator()._check_secret("", make_password("")) is False
assert OAuthValidator()._check_secret("s3cret", make_password("s3cret")) is True
+ @parameterized.expand([("missing", None), ("blank", "")])
+ def test_validator_skips_application_lookup_without_client_id(self, _name, client_id):
+ assert OAuthValidator()._load_application(client_id, SimpleNamespace(client=None)) is None
+
class TestCredentialRepr(SimpleTestCase):
@parameterized.expand(
diff --git a/posthog/api/oauth/views.py b/posthog/api/oauth/views.py
index b8d1efa367c1..110dc327a203 100644
--- a/posthog/api/oauth/views.py
+++ b/posthog/api/oauth/views.py
@@ -388,6 +388,9 @@ class OAuthValidator(OAuth2Validator):
if request.client:
return request.client
+ if not client_id:
+ return None
+
app = OAuthApplication.objects.filter(client_id=client_id).first()
if app is None or not app.is_usable(request):