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.

feat(security): include passkeys in credential review screen (#59650)

Matt Brooker9b8fa178a21c
diff --git a/frontend/src/generated/core/api.schemas.ts b/frontend/src/generated/core/api.schemas.ts
index 8336d343c3da..8339801edf12 100644
--- a/frontend/src/generated/core/api.schemas.ts
+++ b/frontend/src/generated/core/api.schemas.ts
@@ -3424,7 +3424,7 @@ export interface UserApi {
/** Real-time notification types that currently have a live dispatch site. Drives the in-app notifications settings UI. Read-only. */
readonly active_realtime_notification_types: readonly string[]
readonly pending_invites: readonly PendingInviteApi[]
- /** True if the user has at least one Personal API Key and has not yet acknowledged their existing credentials. Used to gate a one-shot review screen on first post-provisioning login. Becomes False once the user POSTs to `/api/users/@me/credentials_review_complete/`. Read-only. */
+ /** True if the user has at least one Personal API Key or passkey and has not yet acknowledged their existing credentials. Used to gate a one-shot review screen on first post-provisioning login. Becomes False once the user POSTs to `/api/users/@me/credentials_review_complete/`. Read-only. */
readonly requires_credential_review: boolean
}
@@ -3526,7 +3526,7 @@ export interface PatchedUserApi {
/** Real-time notification types that currently have a live dispatch site. Drives the in-app notifications settings UI. Read-only. */
readonly active_realtime_notification_types?: readonly string[]
readonly pending_invites?: readonly PendingInviteApi[]
- /** True if the user has at least one Personal API Key and has not yet acknowledged their existing credentials. Used to gate a one-shot review screen on first post-provisioning login. Becomes False once the user POSTs to `/api/users/@me/credentials_review_complete/`. Read-only. */
+ /** True if the user has at least one Personal API Key or passkey and has not yet acknowledged their existing credentials. Used to gate a one-shot review screen on first post-provisioning login. Becomes False once the user POSTs to `/api/users/@me/credentials_review_complete/`. Read-only. */
readonly requires_credential_review?: boolean
}
diff --git a/frontend/src/generated/core/api.ts b/frontend/src/generated/core/api.ts
index ab93134fc15d..9fb79b49e3a2 100644
--- a/frontend/src/generated/core/api.ts
+++ b/frontend/src/generated/core/api.ts
@@ -3042,7 +3042,7 @@ export const getUsersCredentialsReviewCompleteCreateUrl = (uuid: string) => {
}
/**
- * Mark the user as having reviewed their existing credentials. Idempotent. Flips `requires_credential_review` to False so the post-login interstitial isn't shown again. Does not modify any credentials; the user revokes individual Personal API Keys via the existing PAT endpoints from the same screen.
+ * Mark the user as having reviewed their existing credentials. Idempotent. Flips `requires_credential_review` to False so the post-login interstitial isn't shown again. Does not modify any credentials; the user revokes individual Personal API Keys and passkeys via their existing endpoints from the same screen.
*/
export const usersCredentialsReviewCompleteCreate = async (uuid: string, options?: RequestInit): Promise<void> => {
return apiMutator<void>(getUsersCredentialsReviewCompleteCreateUrl(uuid), {
diff --git a/frontend/src/scenes/authentication/account/credential-review/CredentialReview.tsx b/frontend/src/scenes/authentication/account/credential-review/CredentialReview.tsx
index cbd0148f71a5..ac96fb99ea93 100644
--- a/frontend/src/scenes/authentication/account/credential-review/CredentialReview.tsx
+++ b/frontend/src/scenes/authentication/account/credential-review/CredentialReview.tsx
@@ -5,6 +5,7 @@ import { LemonButton } from '@posthog/lemon-ui'
import { BridgePage } from 'lib/components/BridgePage/BridgePage'
import { HeartHog } from 'lib/components/hedgehogs'
import { SceneExport } from 'scenes/sceneTypes'
+import { passkeySettingsLogic } from 'scenes/settings/user/passkeySettingsLogic'
import { personalAPIKeysLogic } from 'scenes/settings/user/personalAPIKeysLogic'
import { credentialReviewLogic } from './credentialReviewLogic'
@@ -18,6 +19,7 @@ export const scene: SceneExport = {
export function CredentialReview(): JSX.Element {
const { markComplete } = useActions(credentialReviewLogic)
const { keysLoading } = useValues(personalAPIKeysLogic)
+ const { passkeysLoading } = useValues(passkeySettingsLogic)
return (
<BridgePage view="credential-review" fixedWidth={false}>
@@ -28,8 +30,8 @@ export function CredentialReview(): JSX.Element {
<HeartHog className="w-full h-full" />
</div>
<p className="mb-6 max-w-xl">
- Your account was set up with the API keys listed below. Review what each one can access, and revoke
- any you don't recognize before continuing.
+ Your account was set up with the credentials listed below. Review each one and revoke anything you
+ don't recognize before continuing.
</p>
<div className="w-full mb-6 text-left">
<CredentialsReviewList />
@@ -38,7 +40,7 @@ export function CredentialReview(): JSX.Element {
type="primary"
size="large"
onClick={() => markComplete()}
- disabledReason={keysLoading ? 'Loading your API keys…' : null}
+ disabledReason={keysLoading || passkeysLoading ? 'Loading your credentials…' : null}
>
Continue to PostHog
</LemonButton>
diff --git a/frontend/src/scenes/authentication/account/credential-review/CredentialsReviewList.tsx b/frontend/src/scenes/authentication/account/credential-review/CredentialsReviewList.tsx
index 1b64768eb3ca..82ca5eeddf0f 100644
--- a/frontend/src/scenes/authentication/account/credential-review/CredentialsReviewList.tsx
+++ b/frontend/src/scenes/authentication/account/credential-review/CredentialsReviewList.tsx
@@ -3,6 +3,7 @@ import { useActions, useValues } from 'kea'
import { LemonButton, LemonDialog, LemonTable, Tooltip } from '@posthog/lemon-ui'
import { humanFriendlyDetailedTime } from 'lib/utils'
+import { type PasskeyCredential, passkeySettingsLogic } from 'scenes/settings/user/passkeySettingsLogic'
import { personalAPIKeysLogic } from 'scenes/settings/user/personalAPIKeysLogic'
import { PersonalAPIKeyType } from '~/types'
@@ -36,63 +37,138 @@ function teamScopeSummary(key: PersonalAPIKeyType): string {
return parts.join(', ')
}
+function passkeyTypeLabel(passkey: PasskeyCredential): string {
+ switch (passkey.authenticator_type) {
+ case 'platform':
+ return 'This device'
+ case 'hardware':
+ return 'Hardware key'
+ case 'hybrid':
+ return 'Cross-device'
+ default:
+ return 'Unknown'
+ }
+}
+
export function CredentialsReviewList(): JSX.Element {
const { keys, keysLoading } = useValues(personalAPIKeysLogic)
const { deleteKey } = useActions(personalAPIKeysLogic)
+ const { passkeys, passkeysLoading } = useValues(passkeySettingsLogic)
+ const { deletePasskey } = useActions(passkeySettingsLogic)
+
+ const showKeys = keysLoading || keys.length > 0
+ const showPasskeys = passkeysLoading || passkeys.length > 0
return (
- <LemonTable
- dataSource={keys}
- loading={keysLoading}
- rowKey={(key) => key.id}
- columns={[
- {
- title: 'Label',
- dataIndex: 'label',
- render: (_, key) => <span className="font-semibold">{key.label}</span>,
- },
- {
- title: 'Access',
- render: (_, key) => (
- <Tooltip title={key.scopes?.join(', ') ?? ''}>
- <span>
- {scopeSummary(key)} · {teamScopeSummary(key)}
- </span>
- </Tooltip>
- ),
- },
- {
- title: 'Created',
- dataIndex: 'created_at',
- render: (value) => humanFriendlyDetailedTime(value as string),
- },
- {
- title: '',
- width: 0,
- render: (_, key) => (
- <LemonButton
- type="secondary"
- status="danger"
- size="small"
- onClick={() =>
- LemonDialog.open({
- title: `Revoke "${key.label}"?`,
- description:
- 'Any service still using this key will start receiving 401 errors immediately.',
- primaryButton: {
- status: 'danger',
- children: 'Revoke',
- onClick: () => deleteKey(key.id),
- },
- })
- }
- >
- Revoke
- </LemonButton>
- ),
- },
- ]}
- emptyState="No API keys found."
- />
+ <div className="flex flex-col gap-6">
+ {showKeys && (
+ <section>
+ <h3 className="text-base font-semibold mb-2">Personal API keys</h3>
+ <LemonTable
+ dataSource={keys}
+ loading={keysLoading}
+ rowKey={(key) => key.id}
+ columns={[
+ {
+ title: 'Label',
+ dataIndex: 'label',
+ render: (_, key) => <span className="font-semibold">{key.label}</span>,
+ },
+ {
+ title: 'Access',
+ render: (_, key) => (
+ <Tooltip title={key.scopes?.join(', ') ?? ''}>
+ <span>
+ {scopeSummary(key)} · {teamScopeSummary(key)}
+ </span>
+ </Tooltip>
+ ),
+ },
+ {
+ title: 'Created',
+ dataIndex: 'created_at',
+ render: (value) => humanFriendlyDetailedTime(value as string),
+ },
+ {
+ title: '',
+ width: 0,
+ render: (_, key) => (
+ <LemonButton
+ type="secondary"
+ status="danger"
+ size="small"
+ onClick={() =>
+ LemonDialog.open({
+ title: `Revoke "${key.label}"?`,
+ description:
+ 'Any service still using this key will start receiving 401 errors immediately.',
+ primaryButton: {
+ status: 'danger',
+ children: 'Revoke',
+ onClick: () => deleteKey(key.id),
+ },
+ })
+ }
+ >
+ Revoke
+ </LemonButton>
+ ),
+ },
+ ]}
+ />
+ </section>
+ )}
+ {showPasskeys && (
+ <section>
+ <h3 className="text-base font-semibold mb-2">Passkeys</h3>
+ <LemonTable
+ dataSource={passkeys}
+ loading={passkeysLoading}
+ rowKey={(passkey) => passkey.id}
+ columns={[
+ {
+ title: 'Label',
+ dataIndex: 'label',
+ render: (_, passkey) => <span className="font-semibold">{passkey.label}</span>,
+ },
+ {
+ title: 'Type',
+ render: (_, passkey) => passkeyTypeLabel(passkey),
+ },
+ {
+ title: 'Created',
+ dataIndex: 'created_at',
+ render: (value) => humanFriendlyDetailedTime(value as string),
+ },
+ {
+ title: '',
+ width: 0,
+ render: (_, passkey) => (
+ <LemonButton
+ type="secondary"
+ status="danger"
+ size="small"
+ onClick={() =>
+ LemonDialog.open({
+ title: `Remove "${passkey.label}"?`,
+ description:
+ 'Anyone signed in with this passkey will need a new one to log in again.',
+ primaryButton: {
+ status: 'danger',
+ children: 'Remove',
+ onClick: () => deletePasskey(passkey.id),
+ },
+ })
+ }
+ >
+ Remove
+ </LemonButton>
+ ),
+ },
+ ]}
+ />
+ </section>
+ )}
+ </div>
)
}
diff --git a/frontend/src/scenes/authentication/account/credential-review/credentialReviewLogic.ts b/frontend/src/scenes/authentication/account/credential-review/credentialReviewLogic.ts
index 9c0b8b07eac7..5073ef75bc65 100644
--- a/frontend/src/scenes/authentication/account/credential-review/credentialReviewLogic.ts
+++ b/frontend/src/scenes/authentication/account/credential-review/credentialReviewLogic.ts
@@ -3,6 +3,7 @@ import { router } from 'kea-router'
import api from 'lib/api'
import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
+import { passkeySettingsLogic } from 'scenes/settings/user/passkeySettingsLogic'
import { personalAPIKeysLogic } from 'scenes/settings/user/personalAPIKeysLogic'
import { urls } from 'scenes/urls'
import { userLogic } from 'scenes/userLogic'
@@ -11,12 +12,12 @@ import type { credentialReviewLogicType } from './credentialReviewLogicType'
export const credentialReviewLogic = kea<credentialReviewLogicType>([
path(['scenes', 'authentication', 'account', 'credential-review', 'credentialReviewLogic']),
- // connect (not a bare import call) so personalAPIKeysLogic is mounted as a dependency
+ // connect (not bare import calls) so both list logics are mounted as dependencies
// of this scene logic. afterMount runs before the review component renders, so without
- // this the loadKeys() call below hits an unmounted logic and throws, which sceneLogic
+ // this the load calls below hit an unmounted logic and throw, which sceneLogic
// catches and turns into a 404 for the whole credential review screen.
connect(() => ({
- actions: [personalAPIKeysLogic, ['loadKeys']],
+ actions: [personalAPIKeysLogic, ['loadKeys'], passkeySettingsLogic, ['loadPasskeys']],
})),
actions({
markComplete: true,
@@ -38,9 +39,9 @@ export const credentialReviewLogic = kea<credentialReviewLogicType>([
},
}),
afterMount(({ actions }) => {
- // personalAPIKeysLogic only auto-loads teams (not keys) when it mounts; the
- // settings page calls loadKeys() from its own useEffect. Trigger it here so the
- // review table isn't dismissable while empty.
+ // Neither logic auto-loads its list on mount, so trigger both here. Otherwise
+ // the review screen would render empty until the user hit the settings page.
actions.loadKeys()
+ actions.loadPasskeys()
}),
])
diff --git a/posthog/api/signup.py b/posthog/api/signup.py
index 30392533d3d0..ade2ffad1bf3 100644
--- a/posthog/api/signup.py
+++ b/posthog/api/signup.py
@@ -256,6 +256,11 @@ class SignupSerializer(serializers.Serializer):
verified=True,
label="Passkey",
)
+ # Self-created during signup, so it counts as already-acknowledged for the
+ # credential review interstitial. Otherwise the user would be asked to revoke
+ # the only credential they just minted to log in with.
+ self._user.credentials_reviewed_at = timezone.now()
+ self._user.save(update_fields=["credentials_reviewed_at"])
except IntegrityError as e:
# This can happen if:
@@ -610,6 +615,10 @@ class InviteSignupSerializer(serializers.Serializer):
if invite.organization.enforce_2fa and not user.passkeys_enabled_for_2fa:
user.passkeys_enabled_for_2fa = True
user.save(update_fields=["passkeys_enabled_for_2fa"])
+ # Self-created during invite signup; treat as already-acknowledged so the
+ # credential review interstitial doesn't ask the user to revoke their own passkey.
+ user.credentials_reviewed_at = timezone.now()
+ user.save(update_fields=["credentials_reviewed_at"])
if is_new_user:
verify_email_or_login(self.context["request"], user)
diff --git a/posthog/api/test/test_signup.py b/posthog/api/test/test_signup.py
index d8f63cbe1bb5..a7b06ee3ad2a 100644
--- a/posthog/api/test/test_signup.py
+++ b/posthog/api/test/test_signup.py
@@ -1683,6 +1683,53 @@ class TestPasskeySignupAPI(APIBaseTest):
self.assertIsNone(session.get(WEBAUTHN_SIGNUP_EMAIL_KEY))
self.assertIsNone(session.get(WEBAUTHN_SIGNUP_USER_UUID_KEY))
+ @pytest.mark.skip_on_multitenancy
+ def test_passkey_signup_marks_credentials_reviewed(self):
+ # Self-created passkeys count as already-acknowledged: otherwise the user lands
+ # on the credential review interstitial after signup and could revoke their only
+ # login credential.
+ from django.contrib.sessions.backends.db import SessionStore
+
+ from webauthn.helpers import bytes_to_base64url
+
+ from posthog.api.webauthn import (
+ WEBAUTHN_SIGNUP_CREDENTIAL_KEY,
+ WEBAUTHN_SIGNUP_EMAIL_KEY,
+ WEBAUTHN_SIGNUP_USER_UUID_KEY,
+ )
+
+ session = SessionStore()
+ session[WEBAUTHN_SIGNUP_EMAIL_KEY] = "[email protected]"
+ session[WEBAUTHN_SIGNUP_USER_UUID_KEY] = str(uuid.uuid4())
+ session[WEBAUTHN_SIGNUP_CREDENTIAL_KEY] = {
+ "credential_id": bytes_to_base64url(b"reviewed-credential-id"),
+ "public_key": bytes_to_base64url(b"reviewed-public-key"),
+ "algorithm": -7,
+ "sign_count": 0,
+ "transports": ["internal"],
+ }
+ session.create()
+ self.client.cookies["sessionid"] = session.session_key or ""
+
+ response = self.client.post(
+ "/api/signup/",
+ {
+ "first_name": "Reviewed",
+ "last_name": "Passkey",
+ "email": "[email protected]",
+ "organization_name": "Reviewed Passkey Org",
+ "role_at_organization": "engineering",
+ },
+ )
+ self.assertEqual(response.status_code, status.HTTP_201_CREATED)
+
+ user = User.objects.get(email="[email protected]")
+ self.assertIsNotNone(user.credentials_reviewed_at)
+
+ me_response = self.client.get("/api/users/@me/")
+ self.assertEqual(me_response.status_code, status.HTTP_200_OK)
+ self.assertFalse(me_response.json()["requires_credential_review"])
+
@pytest.mark.skip_on_multitenancy
def test_password_signup_generates_random_uuid(self):
"""
@@ -2927,6 +2974,60 @@ class TestInviteSignupAPI(APIBaseTest):
self.assertEqual(WebauthnCredential.objects.filter(user=user, verified=True).count(), 1)
self.assertEqual(user.passkeys_enabled_for_2fa, expected_passkeys_enabled_for_2fa)
+ def test_passkey_invite_signup_marks_credentials_reviewed(self):
+ # Self-created passkeys via invite signup count as already-acknowledged: otherwise
+ # the user lands on the credential review interstitial after signup and could revoke
+ # their only login credential.
+ from django.contrib.sessions.backends.db import SessionStore
+
+ from webauthn.helpers import bytes_to_base64url
+
+ from posthog.api.webauthn import (
+ WEBAUTHN_SIGNUP_CREDENTIAL_KEY,
+ WEBAUTHN_SIGNUP_EMAIL_KEY,
+ WEBAUTHN_SIGNUP_USER_UUID_KEY,
+ )
+
+ invite: OrganizationInvite = OrganizationInvite.objects.create(
+ target_email="[email protected]", organization=self.organization
+ )
+
+ # APIBaseTest leaves self.client authenticated as self.user, which would push the flow
+ # down the "already authenticated" branch and skip new-user creation entirely.
+ self.client.logout()
+
+ session = SessionStore()
+ session[WEBAUTHN_SIGNUP_EMAIL_KEY] = "[email protected]"
+ session[WEBAUTHN_SIGNUP_USER_UUID_KEY] = str(uuid.uuid4())
+ session[WEBAUTHN_SIGNUP_CREDENTIAL_KEY] = {
+ "credential_id": bytes_to_base64url(b"reviewed-invite-credential-id"),
+ "public_key": bytes_to_base64url(b"reviewed-invite-public-key"),
+ "algorithm": -7,
+ "sign_count": 0,
+ "transports": ["internal"],
+ }
+ session.create()
+ self.client.cookies["sessionid"] = session.session_key or ""
+
+ response = self.client.post(
+ f"/api/signup/{invite.id}/",
+ {
+ "first_name": "Reviewed",
+ "last_name": "InvitePasskey",
+ },
+ )
+ self.assertEqual(response.status_code, status.HTTP_201_CREATED)
+
+ user = User.objects.get(email="[email protected]")
+ self.assertIsNotNone(user.credentials_reviewed_at)
+ # Confirm a passkey credential was actually minted — otherwise this test would pass
+ # vacuously if the passkey branch silently skipped credential creation.
+ self.assertEqual(WebauthnCredential.objects.filter(user=user).count(), 1)
+
+ me_response = self.client.get("/api/users/@me/")
+ self.assertEqual(me_response.status_code, status.HTTP_200_OK)
+ self.assertFalse(me_response.json()["requires_credential_review"])
+
class TestSignupPrecheckPendingInvite(APIBaseTest):
def setUp(self):
diff --git a/posthog/api/test/test_user.py b/posthog/api/test/test_user.py
index d78c4e074ff8..462019081ca5 100644
--- a/posthog/api/test/test_user.py
+++ b/posthog/api/test/test_user.py
@@ -29,6 +29,7 @@ from posthog.models.organization import Organization, OrganizationMembership
from posthog.models.organization_domain import OrganizationDomain
from posthog.models.personal_api_key import PersonalAPIKey
from posthog.models.utils import generate_random_token_personal, hash_key_value
+from posthog.models.webauthn_credential import WebauthnCredential
from products.dashboards.backend.models.dashboard import Dashboard
@@ -221,13 +222,24 @@ class TestUserAPI(APIBaseTest):
@parameterized.expand(
[
- ("unreviewed_no_keys", False, False, False),
- ("unreviewed_with_keys", False, True, True),
- ("reviewed_with_keys", True, True, False),
- ("reviewed_no_keys", True, False, False),
+ ("unreviewed_nothing", False, False, False, False),
+ ("unreviewed_pat_only", False, True, False, True),
+ ("unreviewed_passkey_only", False, False, True, True),
+ ("unreviewed_pat_and_passkey", False, True, True, True),
+ ("reviewed_pat_only", True, True, False, False),
+ ("reviewed_passkey_only", True, False, True, False),
+ ("reviewed_pat_and_passkey", True, True, True, False),
+ ("reviewed_nothing", True, False, False, False),
]
)
- def test_requires_credential_review(self, _name: str, reviewed: bool, with_key: bool, expected: bool):
+ def test_requires_credential_review(
+ self,
+ _name: str,
+ reviewed: bool,
+ with_key: bool,
+ with_passkey: bool,
+ expected: bool,
+ ):
self.user.credentials_reviewed_at = timezone.now() if reviewed else None
self.user.save(update_fields=["credentials_reviewed_at"])
if with_key:
@@ -237,10 +249,38 @@ class TestUserAPI(APIBaseTest):
secure_value=hash_key_value("phx_test_value_1234567890"),
scopes=["*"],
)
+ if with_passkey:
+ WebauthnCredential.objects.create(
+ user=self.user,
+ label="Test passkey",
+ credential_id=b"test-credential-id",
+ public_key=b"test-public-key",
+ algorithm=-7,
+ transports=["internal"],
+ verified=True,
+ )
response = self.client.get("/api/users/@me/")
assert response.status_code == 200
assert response.json()["requires_credential_review"] is expected
+ def test_requires_credential_review_unverified_passkey(self):
+ # Unverified passkeys are the realistic pre-claim attack artifact - a partner
+ # session can register a credential without ever completing verification.
+ self.user.credentials_reviewed_at = None
+ self.user.save(update_fields=["credentials_reviewed_at"])
+ WebauthnCredential.objects.create(
+ user=self.user,
+ label="Unverified passkey",
+ credential_id=b"unverified-credential-id",
+ public_key=b"test-public-key",
+ algorithm=-7,
+ transports=["internal"],
+ verified=False,
+ )
+ response = self.client.get("/api/users/@me/")
+ assert response.status_code == 200
+ assert response.json()["requires_credential_review"] is True
+
def test_credentials_review_complete_endpoint(self):
User.objects.filter(pk=self.user.pk).update(credentials_reviewed_at=None)
PersonalAPIKey.objects.create(
diff --git a/posthog/api/user.py b/posthog/api/user.py
index 98a83d4483b4..dbddc1b34988 100644
--- a/posthog/api/user.py
+++ b/posthog/api/user.py
@@ -91,6 +91,7 @@ from posthog.models.user import (
OnboardingSkippedReason,
ShortcutPosition,
)
+from posthog.models.webauthn_credential import WebauthnCredential
from posthog.permissions import APIScopePermission, TimeSensitiveActionPermission, UserNoOrgMembershipDeletePermission
from posthog.rate_limit import (
OnboardingSkipThrottle,
@@ -238,9 +239,9 @@ class UserSerializer(serializers.ModelSerializer):
)
requires_credential_review = serializers.SerializerMethodField(
help_text=(
- "True if the user has at least one Personal API Key and has not yet acknowledged "
- "their existing credentials. Used to gate a one-shot review screen on first "
- "post-provisioning login. Becomes False once the user POSTs to "
+ "True if the user has at least one Personal API Key or passkey and has not yet "
+ "acknowledged their existing credentials. Used to gate a one-shot review screen on "
+ "first post-provisioning login. Becomes False once the user POSTs to "
"`/api/users/@me/credentials_review_complete/`. Read-only."
),
)
@@ -386,7 +387,9 @@ class UserSerializer(serializers.ModelSerializer):
def get_requires_credential_review(self, instance: User) -> bool:
if instance.credentials_reviewed_at is not None:
return False
- return PersonalAPIKey.objects.filter(user=instance).exists()
+ if PersonalAPIKey.objects.filter(user=instance).exists():
+ return True
+ return WebauthnCredential.objects.filter(user=instance).exists()
@tracer.start_as_current_span("user_serializer.is_2fa_enabled")
def get_is_2fa_enabled(self, instance: User) -> bool:
@@ -1271,7 +1274,8 @@ class UserViewSet(
"Mark the user as having reviewed their existing credentials. Idempotent. "
"Flips `requires_credential_review` to False so the post-login interstitial "
"isn't shown again. Does not modify any credentials; the user revokes "
- "individual Personal API Keys via the existing PAT endpoints from the same screen."
+ "individual Personal API Keys and passkeys via their existing endpoints from "
+ "the same screen."
),
)
@action(
@@ -1281,9 +1285,9 @@ class UserViewSet(
authentication_classes=[SessionAuthentication],
)
def credentials_review_complete(self, request, **kwargs):
- # Session-only auth: this endpoint dismisses the partner-issued-PAK review
- # screen, so accepting PersonalAPIKeyAuthentication here would let the
- # attacker who minted the PAK silently dismiss their own surfacing.
+ # Session-only auth: this endpoint dismisses the partner-issued-credential
+ # review screen, so accepting PersonalAPIKeyAuthentication here would let
+ # the attacker who minted the PAK silently dismiss their own surfacing.
user = self.get_object()
if user.credentials_reviewed_at is None:
user.credentials_reviewed_at = django_timezone.now()
diff --git a/posthog/test/test_middleware.py b/posthog/test/test_middleware.py
index 199271795631..ce50de2fdf64 100644
--- a/posthog/test/test_middleware.py
+++ b/posthog/test/test_middleware.py
@@ -354,8 +354,8 @@ class TestAutoProjectMiddleware(APIBaseTest):
feature_flag = FeatureFlag.objects.create(team=self.second_team, created_by=self.user)
with self.assertNumQueries(
- FuzzyInt(self.base_app_num_queries, self.base_app_num_queries + 9)
- ): # +1 from activity logging _get_before_update()
+ FuzzyInt(self.base_app_num_queries, self.base_app_num_queries + 10)
+ ): # +1 from activity logging _get_before_update(), +1 from passkey credential review check
response_app = self.client.get(f"/feature_flags/{feature_flag.id}")
response_users_api = self.client.get(f"/api/users/@me/")
response_users_api_data = response_users_api.json()
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index eb981fe043d1..fea760bfa43f 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -28466,7 +28466,7 @@ export namespace Schemas {
/** Real-time notification types that currently have a live dispatch site. Drives the in-app notifications settings UI. Read-only. */
readonly active_realtime_notification_types: readonly string[];
readonly pending_invites: readonly PendingInvite[];
- /** True if the user has at least one Personal API Key and has not yet acknowledged their existing credentials. Used to gate a one-shot review screen on first post-provisioning login. Becomes False once the user POSTs to `/api/users/@me/credentials_review_complete/`. Read-only. */
+ /** True if the user has at least one Personal API Key or passkey and has not yet acknowledged their existing credentials. Used to gate a one-shot review screen on first post-provisioning login. Becomes False once the user POSTs to `/api/users/@me/credentials_review_complete/`. Read-only. */
readonly requires_credential_review: boolean;
}
@@ -34586,7 +34586,7 @@ export namespace Schemas {
/** Real-time notification types that currently have a live dispatch site. Drives the in-app notifications settings UI. Read-only. */
readonly active_realtime_notification_types?: readonly string[];
readonly pending_invites?: readonly PendingInvite[];
- /** True if the user has at least one Personal API Key and has not yet acknowledged their existing credentials. Used to gate a one-shot review screen on first post-provisioning login. Becomes False once the user POSTs to `/api/users/@me/credentials_review_complete/`. Read-only. */
+ /** True if the user has at least one Personal API Key or passkey and has not yet acknowledged their existing credentials. Used to gate a one-shot review screen on first post-provisioning login. Becomes False once the user POSTs to `/api/users/@me/credentials_review_complete/`. Read-only. */
readonly requires_credential_review?: boolean;
}