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: add property-level access control UI (#54799)

Reece Jones9159f3042e22
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index aea272397943..914a7292f626 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -433,6 +433,7 @@ export const FEATURE_FLAGS = {
PRODUCT_TOURS_LOCALIZATION: 'product-tours-localization', // owner: @adboio #team-surveys
PROMOTED_EVENT_PROPERTIES_EDIT: 'promoted-event-properties-edit', // owner: @pauldambra #team-product-analytics, gates the primary-property picker on the event definition edit page (flag slug kept as `promoted-event-properties-edit` to avoid migrating teams that already toggled it on)
PROMPT_MANAGEMENT: 'prompt-management', // owner: #team-llm-analytics
+ PROPERTY_ACCESS_CONTROL: 'property-access-control', // owner: @reecejones #team-platform-features
PROVISION_MANAGED_WAREHOUSE_BETA: 'provision-managed-warehouse-beta', // owner: @EDsCODE #team-managed-warehouse
QUICK_START_PULSE_INDICATOR: 'quick-start-pulse-indicator', // owner: @fercgomes #team-growth multivariate=control,test
RBAC_UI_REDESIGN: 'rbac-ui-redesign', // owner: @reece #team-platform-features
diff --git a/frontend/src/lib/hog-charts/core/Chart.tsx b/frontend/src/lib/hog-charts/core/Chart.tsx
index a74d654c22d4..65b4a88e49d9 100644
--- a/frontend/src/lib/hog-charts/core/Chart.tsx
+++ b/frontend/src/lib/hog-charts/core/Chart.tsx
@@ -173,7 +173,7 @@ export function Chart<Meta = unknown>({
axisOrientation,
labelToCoord,
}),
- [showCrosshair, theme.crosshairColor, axisOrientation, labelToCoord]
+ [showCrosshair, theme.crosshairColor, axisOrientation, labelToCoord, drawHoverRef.current]
)
useChartDraw({
diff --git a/frontend/src/lib/hog-charts/core/hooks/useChartCanvas.ts b/frontend/src/lib/hog-charts/core/hooks/useChartCanvas.ts
index ae12672c78a3..d109b70a285d 100644
--- a/frontend/src/lib/hog-charts/core/hooks/useChartCanvas.ts
+++ b/frontend/src/lib/hog-charts/core/hooks/useChartCanvas.ts
@@ -98,7 +98,7 @@ export function useChartCanvas(options: UseChartCanvasOptions): UseChartCanvasRe
return () => {
observer.disconnect()
}
- }, [])
+ }, [marginsRef.current])
// When margins change without a resize, recompute dimensions from the cached rect.
useEffect(() => {
@@ -107,7 +107,7 @@ export function useChartCanvas(options: UseChartCanvasOptions): UseChartCanvasRe
return
}
setCanvasState((prev) => (prev ? { ...prev, dimensions: buildDimensions(rect, margins) } : prev))
- }, [margins.left, margins.right, margins.top, margins.bottom])
+ }, [margins.left, margins.right, margins.top, margins.bottom, margins])
return {
canvasRef,
diff --git a/frontend/src/scenes/data-management/definition/DefinitionEdit.tsx b/frontend/src/scenes/data-management/definition/DefinitionEdit.tsx
index 185091e8769a..2b1923639cdc 100644
--- a/frontend/src/scenes/data-management/definition/DefinitionEdit.tsx
+++ b/frontend/src/scenes/data-management/definition/DefinitionEdit.tsx
@@ -26,11 +26,15 @@ import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
import { getPrimaryPropertyForEvent, hasTaxonomyPrimaryProperty } from 'lib/utils/primaryEventProperty'
import { definitionEditLogic } from 'scenes/data-management/definition/definitionEditLogic'
import { DefinitionLogicProps, definitionLogic } from 'scenes/data-management/definition/definitionLogic'
+import { PropertyAccessControl } from 'scenes/data-management/definition/PropertyAccessControl'
import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { SceneExport } from 'scenes/sceneTypes'
+import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
import { SceneContent } from '~/layout/scenes/components/SceneContent'
+import { SceneDivider } from '~/layout/scenes/components/SceneDivider'
+import { SceneSection } from '~/layout/scenes/components/SceneSection'
import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'
import { tagsModel } from '~/models/tagsModel'
import { isCoreFilter } from '~/taxonomy/helpers'
@@ -51,6 +55,7 @@ export function DefinitionEdit(props: DefinitionLogicProps): JSX.Element {
const { editDefinition } = useValues(logic)
const { saveDefinition } = useActions(logic)
const { tags, tagsLoading } = useValues(tagsModel)
+ const { currentTeamId } = useValues(teamLogic)
const { objectStorageAvailable } = useValues(preflightLogic)
const { reportMediaPreviewUploaded } = useActions(eventUsageLogic)
@@ -332,6 +337,18 @@ export function DefinitionEdit(props: DefinitionLogicProps): JSX.Element {
)}
</div>
)}
+
+ {isProperty && editDefinition.id !== 'new' && currentTeamId && (
+ <FlaggedFeature flag={FEATURE_FLAGS.PROPERTY_ACCESS_CONTROL}>
+ <SceneDivider />
+ <SceneSection
+ title="Access control"
+ description="Control who can see this property's values, and who can edit them from the PostHog UI."
+ >
+ <PropertyAccessControl propertyDefinitionId={editDefinition.id} teamId={currentTeamId} />
+ </SceneSection>
+ </FlaggedFeature>
+ )}
</SceneContent>
</Form>
)
diff --git a/frontend/src/scenes/data-management/definition/PropertyAccessControl.tsx b/frontend/src/scenes/data-management/definition/PropertyAccessControl.tsx
new file mode 100644
index 000000000000..82de56b3806b
--- /dev/null
+++ b/frontend/src/scenes/data-management/definition/PropertyAccessControl.tsx
@@ -0,0 +1,261 @@
+import { useActions, useValues } from 'kea'
+
+import { IconPlus } from '@posthog/icons'
+import { LemonButton, LemonDropdown, LemonSelect, LemonSelectOptionLeaf } from '@posthog/lemon-ui'
+
+import { RestrictionScope, useRestrictedArea } from 'lib/components/RestrictedArea'
+import { TeamMembershipLevel } from 'lib/constants'
+import { LemonField } from 'lib/lemon-ui/LemonField'
+import { LemonTable, LemonTableColumn } from 'lib/lemon-ui/LemonTable'
+import { LemonTabs } from 'lib/lemon-ui/LemonTabs'
+import { ProfileBubbles, ProfilePicture } from 'lib/lemon-ui/ProfilePicture'
+import { Spinner } from 'lib/lemon-ui/Spinner'
+
+import type { AccessLevelEnumApi } from 'products/access_control/frontend/generated/api.schemas'
+
+import { propertyAccessControlLogic, PropertyAccessControlLogicProps } from './propertyAccessControlLogic'
+
+const ACCESS_LEVEL_OPTIONS: LemonSelectOptionLeaf<AccessLevelEnumApi>[] = [
+ { value: 'read_write', label: 'Read & write' },
+ { value: 'read', label: 'Read only' },
+ { value: 'none', label: 'No access' },
+]
+
+const OVERRIDE_OPTIONS: LemonSelectOptionLeaf<AccessLevelEnumApi | null>[] = [
+ ...ACCESS_LEVEL_OPTIONS,
+ { value: null, label: 'Remove override' },
+]
+
+interface PropertyAccessControlProps {
+ propertyDefinitionId: string
+ teamId: number
+}
+
+export function PropertyAccessControl({ propertyDefinitionId, teamId }: PropertyAccessControlProps): JSX.Element {
+ const logicProps: PropertyAccessControlLogicProps = { propertyDefinitionId, teamId }
+ const { remoteStateLoading, defaultLevel, memberOverrides, roleOverrides, allMembers, allRoles, activeTab } =
+ useValues(propertyAccessControlLogic(logicProps))
+ const { setLocalDefaultLevel, setLocalMemberOverride, setLocalRoleOverride, setActiveTab } = useActions(
+ propertyAccessControlLogic(logicProps)
+ )
+
+ const restrictedReason = useRestrictedArea({
+ scope: RestrictionScope.Project,
+ minimumAccessLevel: TeamMembershipLevel.Admin,
+ })
+
+ if (remoteStateLoading) {
+ return <Spinner />
+ }
+
+ return (
+ <div className="space-y-4">
+ <LemonField.Pure
+ label="Default access level"
+ help="This is the base access level for all users when no member or role override applies."
+ >
+ <LemonSelect
+ value={defaultLevel}
+ onChange={(value) => setLocalDefaultLevel(value)}
+ options={ACCESS_LEVEL_OPTIONS}
+ size="small"
+ className="max-w-48"
+ disabledReason={restrictedReason}
+ />
+ </LemonField.Pure>
+
+ <LemonTabs
+ activeKey={activeTab}
+ onChange={setActiveTab}
+ tabs={[
+ {
+ key: 'members',
+ label: 'Members',
+ content: (
+ <MembersTab
+ members={allMembers}
+ overrides={memberOverrides}
+ onSetOverride={setLocalMemberOverride}
+ restrictedReason={restrictedReason}
+ />
+ ),
+ },
+ {
+ key: 'roles',
+ label: 'Roles',
+ content: (
+ <RolesTab
+ roles={allRoles}
+ overrides={roleOverrides}
+ onSetOverride={setLocalRoleOverride}
+ restrictedReason={restrictedReason}
+ />
+ ),
+ },
+ ]}
+ />
+ </div>
+ )
+}
+
+interface MemberInfo {
+ id: string
+ first_name: string
+ last_name: string
+ email: string
+}
+
+interface RoleInfo {
+ id: string
+ name: string
+ members: MemberInfo[]
+}
+
+function OverrideCell({
+ currentLevel,
+ onChange,
+ restrictedReason,
+}: {
+ currentLevel: AccessLevelEnumApi | null | undefined
+ onChange: (level: AccessLevelEnumApi | null) => void
+ restrictedReason: string | null
+}): JSX.Element {
+ const hasOverride = currentLevel != null
+
+ if (hasOverride) {
+ return (
+ <LemonSelect
+ value={currentLevel}
+ onChange={onChange}
+ options={OVERRIDE_OPTIONS}
+ size="small"
+ className="w-40"
+ disabledReason={restrictedReason}
+ />
+ )
+ }
+
+ return (
+ <LemonDropdown
+ placement="bottom-end"
+ overlay={
+ <div className="flex flex-col">
+ {ACCESS_LEVEL_OPTIONS.map((option) => (
+ <LemonButton
+ key={option.value}
+ size="small"
+ className="w-40"
+ fullWidth
+ onClick={() => onChange(option.value)}
+ >
+ {option.label}
+ </LemonButton>
+ ))}
+ </div>
+ }
+ >
+ <LemonButton
+ size="small"
+ type="tertiary"
+ icon={<IconPlus />}
+ sideIcon={null}
+ className="w-40"
+ disabledReason={restrictedReason}
+ >
+ Add override
+ </LemonButton>
+ </LemonDropdown>
+ )
+}
+
+function MembersTab({
+ members,
+ overrides,
+ onSetOverride,
+ restrictedReason,
+}: {
+ members: MemberInfo[]
+ overrides: Record<string, AccessLevelEnumApi | null>
+ onSetOverride: (memberId: string, level: AccessLevelEnumApi | null) => void
+ restrictedReason: string | null
+}): JSX.Element {
+ const columns: LemonTableColumn<MemberInfo, keyof MemberInfo | undefined>[] = [
+ {
+ title: 'Member',
+ key: 'name',
+ render: (_, member) => (
+ <div className="flex items-center gap-2">
+ <ProfilePicture user={{ first_name: member.first_name, email: member.email }} size="md" />
+ <div>
+ <div className="font-semibold">
+ {member.first_name} {member.last_name}
+ </div>
+ <div className="text-muted text-xs">{member.email}</div>
+ </div>
+ </div>
+ ),
+ },
+ {
+ title: 'Access level',
+ key: 'access',
+ width: 200,
+ render: (_, member) => (
+ <OverrideCell
+ currentLevel={overrides[member.id]}
+ onChange={(level) => onSetOverride(member.id, level)}
+ restrictedReason={restrictedReason}
+ />
+ ),
+ },
+ ]
+
+ return <LemonTable dataSource={members} columns={columns} rowKey="id" size="small" emptyState="No members found" />
+}
+
+function RolesTab({
+ roles,
+ overrides,
+ onSetOverride,
+ restrictedReason,
+}: {
+ roles: RoleInfo[]
+ overrides: Record<string, AccessLevelEnumApi | null>
+ onSetOverride: (roleId: string, level: AccessLevelEnumApi | null) => void
+ restrictedReason: string | null
+}): JSX.Element {
+ const columns: LemonTableColumn<RoleInfo, keyof RoleInfo | undefined>[] = [
+ {
+ title: 'Role',
+ key: 'name',
+ render: (_, role) => <span className="font-semibold">{role.name}</span>,
+ },
+ {
+ title: 'Members',
+ key: 'members',
+ render: (_, role) => (
+ <ProfileBubbles
+ people={role.members.map((m) => ({
+ email: m.email,
+ name: `${m.first_name} ${m.last_name}`,
+ title: `${m.first_name} ${m.last_name} <${m.email}>`,
+ }))}
+ limit={4}
+ />
+ ),
+ },
+ {
+ title: 'Access level',
+ key: 'access',
+ width: 200,
+ render: (_, role) => (
+ <OverrideCell
+ currentLevel={overrides[role.id]}
+ onChange={(level) => onSetOverride(role.id, level)}
+ restrictedReason={restrictedReason}
+ />
+ ),
+ },
+ ]
+
+ return <LemonTable dataSource={roles} columns={columns} rowKey="id" size="small" emptyState="No roles found" />
+}
diff --git a/frontend/src/scenes/data-management/definition/definitionEditLogic.ts b/frontend/src/scenes/data-management/definition/definitionEditLogic.ts
index 2eab7653ac91..cbd5be8d410b 100644
--- a/frontend/src/scenes/data-management/definition/definitionEditLogic.ts
+++ b/frontend/src/scenes/data-management/definition/definitionEditLogic.ts
@@ -8,8 +8,10 @@ import api from 'lib/api'
import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
import { capitalizeFirstLetter } from 'lib/utils'
import { DefinitionLogicProps, definitionLogic } from 'scenes/data-management/definition/definitionLogic'
+import { propertyAccessControlLogic } from 'scenes/data-management/definition/propertyAccessControlLogic'
import { eventDefinitionsTableLogic } from 'scenes/data-management/events/eventDefinitionsTableLogic'
import { propertyDefinitionsTableLogic } from 'scenes/data-management/properties/propertyDefinitionsTableLogic'
+import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
import { primaryEventPropertiesModel } from '~/models/primaryEventPropertiesModel'
@@ -77,6 +79,18 @@ export const definitionEditLogic = kea<definitionEditLogicType>([
updatePropertyDefinitions({
[`event/${definition.name}`]: definition as PropertyDefinition,
})
+
+ // Save field access control changes if any
+ const currentTeamId = teamLogic.values.currentTeamId
+ if (currentTeamId) {
+ const facLogic = propertyAccessControlLogic({
+ propertyDefinitionId: definition.id,
+ teamId: currentTeamId,
+ })
+ if (facLogic.values.hasChanges) {
+ facLogic.actions.saveAccessControls()
+ }
+ }
}
breakpoint()
diff --git a/frontend/src/scenes/data-management/definition/propertyAccessControlLogic.ts b/frontend/src/scenes/data-management/definition/propertyAccessControlLogic.ts
new file mode 100644
index 000000000000..87662cc53a86
--- /dev/null
+++ b/frontend/src/scenes/data-management/definition/propertyAccessControlLogic.ts
@@ -0,0 +1,262 @@
+import { actions, afterMount, kea, key, listeners, path, props, reducers, selectors } from 'kea'
+import { loaders } from 'kea-loaders'
+
+import { membersLogic } from 'scenes/organization/membersLogic'
+import { rolesLogic } from 'scenes/settings/organization/Permissions/Roles/rolesLogic'
+
+import {
+ propertyAccessControlsCreate,
+ propertyAccessControlsDestroy,
+ propertyAccessControlsRetrieve,
+} from 'products/access_control/frontend/generated/api'
+import type {
+ AccessLevelEnumApi,
+ PropertyAccessControlStateApi,
+} from 'products/access_control/frontend/generated/api.schemas'
+
+import type { propertyAccessControlLogicType } from './propertyAccessControlLogicType'
+
+export interface PropertyAccessControlLogicProps {
+ propertyDefinitionId: string
+ teamId: number
+}
+
+// Local state shape: tracks the user's pending edits
+export interface LocalAccessControlState {
+ defaultLevel: AccessLevelEnumApi
+ // Maps member/role ID to their override level, or null meaning "remove override"
+ memberOverrides: Record<string, AccessLevelEnumApi | null>
+ roleOverrides: Record<string, AccessLevelEnumApi | null>
+}
+
+export const propertyAccessControlLogic = kea<propertyAccessControlLogicType>([
+ path(['scenes', 'data-management', 'definition', 'propertyAccessControlLogic']),
+ props({} as PropertyAccessControlLogicProps),
+ key((props) => props.propertyDefinitionId),
+
+ actions({
+ setLocalDefaultLevel: (level: AccessLevelEnumApi) => ({ level }),
+ setLocalMemberOverride: (memberId: string, level: AccessLevelEnumApi | null) => ({ memberId, level }),
+ setLocalRoleOverride: (roleId: string, level: AccessLevelEnumApi | null) => ({ roleId, level }),
+ resetLocalState: true,
+ saveAccessControls: true,
+ setActiveTab: (tab: string) => ({ tab }),
+ }),
+
+ loaders(({ props }) => ({
+ remoteState: [
+ null as PropertyAccessControlStateApi | null,
+ {
+ loadRemoteState: async () => {
+ return await propertyAccessControlsRetrieve(String(props.teamId), {
+ property_definition_id: props.propertyDefinitionId,
+ })
+ },
+ },
+ ],
+ })),
+
+ reducers({
+ localState: [
+ null as LocalAccessControlState | null,
+ {
+ loadRemoteStateSuccess: (_, { remoteState }) => {
+ if (!remoteState) {
+ return null
+ }
+ const memberOverrides: Record<string, AccessLevelEnumApi | null> = {}
+ const roleOverrides: Record<string, AccessLevelEnumApi | null> = {}
+ for (const rule of remoteState.access_controls) {
+ if (rule.organization_member) {
+ memberOverrides[rule.organization_member] = rule.access_level
+ } else if (rule.role) {
+ roleOverrides[rule.role] = rule.access_level
+ }
+ }
+ return {
+ defaultLevel: remoteState.default_access_level as AccessLevelEnumApi,
+ memberOverrides,
+ roleOverrides,
+ }
+ },
+ setLocalDefaultLevel: (state, { level }) => (state ? { ...state, defaultLevel: level } : state),
+ setLocalMemberOverride: (state, { memberId, level }) =>
+ state ? { ...state, memberOverrides: { ...state.memberOverrides, [memberId]: level } } : state,
+ setLocalRoleOverride: (state, { roleId, level }) =>
+ state ? { ...state, roleOverrides: { ...state.roleOverrides, [roleId]: level } } : state,
+ resetLocalState: () => null,
+ },
+ ],
+ activeTab: [
+ 'members' as string,
+ {
+ setActiveTab: (_, { tab }) => tab,
+ },
+ ],
+ }),
+
+ selectors({
+ defaultLevel: [
+ (s) => [s.localState],
+ (localState): AccessLevelEnumApi => localState?.defaultLevel ?? 'read_write',
+ ],
+ memberOverrides: [
+ (s) => [s.localState],
+ (localState): Record<string, AccessLevelEnumApi | null> => localState?.memberOverrides ?? {},
+ ],
+ roleOverrides: [
+ (s) => [s.localState],
+ (localState): Record<string, AccessLevelEnumApi | null> => localState?.roleOverrides ?? {},
+ ],
+ allMembers: [
+ () => [membersLogic.selectors.members],
+ (members): { id: string; first_name: string; last_name: string; email: string }[] =>
+ (members ?? []).map((member: any) => ({
+ id: member.id,
+ first_name: member.user?.first_name ?? '',
+ last_name: member.user?.last_name ?? '',
+ email: member.user?.email ?? '',
+ })),
+ ],
+ allRoles: [
+ () => [rolesLogic.selectors.roles],
+ (roles): { id: string; name: string; members: any[] }[] =>
+ (roles ?? []).map((role: any) => ({
+ id: role.id,
+ name: role.name,
+ members: (role.members ?? []).map((m: any) => ({
+ id: m.id,
+ first_name: m.user?.first_name ?? '',
+ last_name: m.user?.last_name ?? '',
+ email: m.user?.email ?? '',
+ })),
+ })),
+ ],
+ hasChanges: [
+ (s) => [s.localState, s.remoteState],
+ (localState, remoteState): boolean => {
+ if (!localState || !remoteState) {
+ return false
+ }
+ // Check default level
+ if (localState.defaultLevel !== remoteState.default_access_level) {
+ return true
+ }
+ // Build remote overrides for comparison
+ const remoteMemberOverrides: Record<string, string> = {}
+ const remoteRoleOverrides: Record<string, string> = {}
+ for (const rule of remoteState.access_controls) {
+ if (rule.organization_member) {
+ remoteMemberOverrides[rule.organization_member] = rule.access_level
+ } else if (rule.role) {
+ remoteRoleOverrides[rule.role] = rule.access_level
+ }
+ }
+ // Check member overrides
+ const allMemberIds = new Set([
+ ...Object.keys(localState.memberOverrides),
+ ...Object.keys(remoteMemberOverrides),
+ ])
+ for (const id of allMemberIds) {
+ const local = localState.memberOverrides[id] ?? undefined
+ const remote = remoteMemberOverrides[id] ?? undefined
+ if (local !== remote) {
+ return true
+ }
+ }
+ // Check role overrides
+ const allRoleIds = new Set([
+ ...Object.keys(localState.roleOverrides),
+ ...Object.keys(remoteRoleOverrides),
+ ])
+ for (const id of allRoleIds) {
+ const local = localState.roleOverrides[id] ?? undefined
+ const remote = remoteRoleOverrides[id] ?? undefined
+ if (local !== remote) {
+ return true
+ }
+ }
+ return false
+ },
+ ],
+ }),
+
+ listeners(({ values, actions, props }) => ({
+ saveAccessControls: async () => {
+ if (!values.localState || !values.remoteState) {
+ return
+ }
+ const teamId = String(props.teamId)
+
+ // Save default level if changed
+ if (values.localState.defaultLevel !== values.remoteState.default_access_level) {
+ await propertyAccessControlsCreate(teamId, {
+ property_definition_id: props.propertyDefinitionId,
+ access_level: values.localState.defaultLevel,
+ })
+ }
+
+ // Build remote override maps for diffing
+ const remoteMemberOverrides: Record<string, string> = {}
+ const remoteRoleOverrides: Record<string, string> = {}
+ for (const rule of values.remoteState.access_controls) {
+ if (rule.organization_member) {
+ remoteMemberOverrides[rule.organization_member] = rule.access_level
+ } else if (rule.role) {
+ remoteRoleOverrides[rule.role] = rule.access_level
+ }
+ }
+
+ // Save member override changes
+ for (const [memberId, level] of Object.entries(values.localState.memberOverrides)) {
+ const remoteLevel = remoteMemberOverrides[memberId] ?? undefined
+ if (level !== null && level !== remoteLevel) {
+ await propertyAccessControlsCreate(teamId, {
+ property_definition_id: props.propertyDefinitionId,
+ access_level: level,
+ organization_member: memberId,
+ })
+ }
+ }
+ // Handle removed member overrides (was in remote but set to null locally)
+ for (const memberId of Object.keys(remoteMemberOverrides)) {
+ if (values.localState.memberOverrides[memberId] === null) {
+ await propertyAccessControlsDestroy(teamId, {
+ property_definition_id: props.propertyDefinitionId,
+ organization_member: memberId,
+ })
+ }
+ }
+
+ // Save role override changes
+ for (const [roleId, level] of Object.entries(values.localState.roleOverrides)) {
+ const remoteLevel = remoteRoleOverrides[roleId] ?? undefined
+ if (level !== null && level !== remoteLevel) {
+ await propertyAccessControlsCreate(teamId, {
+ property_definition_id: props.propertyDefinitionId,
+ access_level: level,
+ role: roleId,
+ })
+ }
+ }
+ // Handle removed role overrides
+ for (const roleId of Object.keys(remoteRoleOverrides)) {
+ if (values.localState.roleOverrides[roleId] === null) {
+ await propertyAccessControlsDestroy(teamId, {
+ property_definition_id: props.propertyDefinitionId,
+ role: roleId,
+ })
+ }
+ }
+
+ // Reload remote state to sync
+ actions.loadRemoteState()
+ },
+ })),
+
+ afterMount(({ actions }) => {
+ actions.loadRemoteState()
+ membersLogic.actions.ensureAllMembersLoaded()
+ rolesLogic.actions.loadRoles()
+ }),
+])
diff --git a/posthog/urls.py b/posthog/urls.py
index 6e48ca8d221b..76fba3d5b3fc 100644
--- a/posthog/urls.py
+++ b/posthog/urls.py
@@ -272,6 +272,10 @@ urlpatterns = [
"api/environments/<int:parent_lookup_team_id>/mcp_analytics/",
include("products.mcp_analytics.backend.presentation.urls"),
),
+ path(
+ "api/environments/<int:parent_lookup_team_id>/property_access_controls/",
+ include("products.access_control.backend.presentation.urls"),
+ ),
opt_slash_path("api/support/ensure-zendesk-organization", csrf_exempt(ensure_zendesk_organization)),
path("api/", include(router.urls)),
# Override the tf_urls QRGeneratorView to use the cache-aware version (handles session race conditions)
diff --git a/products/access_control/backend/facade/api.py b/products/access_control/backend/facade/api.py
index 24544497fe5e..70942165a955 100644
--- a/products/access_control/backend/facade/api.py
+++ b/products/access_control/backend/facade/api.py
@@ -1,24 +1,216 @@
"""
-Facade for access_control.
+Facade API for access_control.
-This is the ONLY module other products are allowed to import.
+This is the module that other apps / the presentation layer should
+import from. It accepts plain inputs and returns contract DTOs, never
+ORM instances or QuerySets.
Responsibilities:
-- Accept frozen dataclasses as input parameters
-- Call business logic (logic.py)
-- Convert Django models to frozen dataclasses before returning
-- Enforce transactions where needed
+- Accept DTOs / primitive inputs
+- Call domain logic / ORM
+- Convert Django models to DTOs before returning
- Remain thin and stable
Do NOT:
-- Implement business logic here (use logic.py)
-- Import DRF, serializers, or HTTP concerns
+- Import DRF / serializers / HTTP concerns here
- Return ORM instances or QuerySets
"""
+from __future__ import annotations
-# --- Converters (model -> frozen dataclass) ---
-#
-# These look repetitive when fields align 1:1. The value is having ONE place
-# where "internal" becomes "external contract". When models and contracts drift,
-# the mapper absorbs the change instead of it leaking everywhere.
+from uuid import UUID
+
+from django.shortcuts import get_object_or_404
+
+from posthog.models import OrganizationMembership, PropertyDefinition, Team
+
+from ee.models.rbac.role import Role
+
+from ..models.property_access_control import PropertyAccessControl
+from . import contracts
+from .contracts import PropertyAccessLevel
+
+
+class PropertyDefinitionNotFoundError(Exception):
+ """Raised when the target property definition cannot be found for the team."""
+
+
+class PropertyAccessControlRuleNotFoundError(Exception):
+ """Raised when trying to delete a rule that does not exist."""
+
+
+class InvalidPropertyAccessControlTargetError(Exception):
+ """Raised when the rule target (role or organization member) does not
+ belong to the same organization as the team."""
+
+
+# --- Mappers (model -> DTO) ---
+
+
+def _to_rule(rule: PropertyAccessControl) -> contracts.PropertyAccessControlRule:
+ return contracts.PropertyAccessControlRule(
+ id=rule.id,
+ access_level=PropertyAccessLevel(rule.access_level),
+ organization_member_id=rule.organization_member_id,
+ role_id=rule.role_id,
+ created_by_id=rule.created_by_id,
+ created_at=rule.created_at,
+ updated_at=rule.updated_at,
+ )
+
+
+def _get_property_definition(property_definition_id: str, team_id: int) -> PropertyDefinition:
+ try:
+ return get_object_or_404(PropertyDefinition, id=property_definition_id, team_id=team_id)
+ except Exception as exc:
+ # Normalize 404 -> domain error so presentation can translate without leaking ORM concerns.
+ from django.http import Http404
+
+ if isinstance(exc, Http404):
+ raise PropertyDefinitionNotFoundError(property_definition_id) from exc
+ raise
+
+
+# --- Read API ---
+
+
+def get_property_access_state(
+ *,
+ team_id: int,
+ property_definition_id: str,
+) -> contracts.PropertyAccessControlState:
+ """Return the full access-control state for a single property definition."""
+ prop_def = _get_property_definition(property_definition_id, team_id)
+
+ rules_qs = PropertyAccessControl.objects.filter(
+ team_id=team_id,
+ property_definition=prop_def,
+ ).select_related("organization_member", "role", "created_by")
+ rules = list(rules_qs)
+
+ # The rule with null membership AND null role acts as the property-level default.
+ default_rule = next(
+ (r for r in rules if r.organization_member_id is None and r.role_id is None),
+ None,
+ )
+ default_level = PropertyAccessLevel(default_rule.access_level) if default_rule else PropertyAccessLevel.READ_WRITE
+
+ return contracts.PropertyAccessControlState(
+ rules=[_to_rule(r) for r in rules],
+ available_access_levels=list(PropertyAccessLevel),
+ default_access_level=default_level,
+ )
+
+
+# --- Write API ---
+
+
+def _validate_target_org(
+ *,
+ team_id: int,
+ organization_member_id: UUID | None,
+ role_id: UUID | None,
+) -> None:
+ """Ensure the rule target (role / organization member) belongs to the
+ team's organization.
+
+ Without this check, an org admin who is also a member of another
+ organization could inject role or membership UUIDs from that other org
+ into rules here — which would then either be silently inert or, worse,
+ collide with intra-org IDs in audits and downstream logic.
+ """
+ if organization_member_id is None and role_id is None:
+ return
+
+ organization_id = Team.objects.filter(id=team_id).values_list("organization_id", flat=True).first()
+ if organization_id is None:
+ # Team doesn't exist — the upstream get_object lookup would have failed already,
+ # but be defensive.
+ raise InvalidPropertyAccessControlTargetError("Team not found.")
+
+ if organization_member_id is not None:
+ if not OrganizationMembership.objects.filter(
+ id=organization_member_id, organization_id=organization_id
+ ).exists():
+ raise InvalidPropertyAccessControlTargetError(
+ "organization_member does not belong to this team's organization."
+ )
+
+ if role_id is not None:
+ if not Role.objects.filter(id=role_id, organization_id=organization_id).exists():
+ raise InvalidPropertyAccessControlTargetError("role does not belong to this team's organization.")
+
+
+def upsert_property_access_control(
+ *,
+ team_id: int,
+ created_by_id: int | None,
+ input: contracts.UpsertPropertyAccessControlInput,
+) -> contracts.PropertyAccessControlRule:
+ """Create or update a single access control rule."""
+ prop_def = _get_property_definition(input.property_definition_id, team_id)
+ _validate_target_org(
+ team_id=team_id,
+ organization_member_id=input.organization_member_id,
+ role_id=input.role_id,
+ )
+
+ # `created_by_id` must only be set on creation — using `defaults` would
+ # overwrite the original creator on every update. `create_defaults`
+ # (Django 4.2+) is applied only when a new row is inserted.
+ rule, _created = PropertyAccessControl.objects.update_or_create(
+ team_id=team_id,
+ property_definition=prop_def,
+ organization_member_id=input.organization_member_id,
+ role_id=input.role_id,
+ defaults={
+ "access_level": input.access_level.value,
+ },
+ create_defaults={
+ "access_level": input.access_level.value,
+ "created_by_id": created_by_id,
+ },
+ )
+ return _to_rule(rule)
+
+
+def delete_property_access_control(
+ *,
+ team_id: int,
+ input: contracts.DeletePropertyAccessControlInput,
+) -> None:
+ """Delete an override rule. Raises PropertyAccessControlRuleNotFoundError if nothing matched."""
+ prop_def = _get_property_definition(input.property_definition_id, team_id)
+ _validate_target_org(
+ team_id=team_id,
+ organization_member_id=input.organization_member_id,
+ role_id=input.role_id,
+ )
+
+ deleted, _ = PropertyAccessControl.objects.filter(
+ team_id=team_id,
+ property_definition=prop_def,
+ organization_member_id=input.organization_member_id,
+ role_id=input.role_id, # type: ignore
+ ).delete()
+ if not deleted:
+ raise PropertyAccessControlRuleNotFoundError
+
+
+# --- Convenience for external callers (avoids importing UUID type at call sites) ---
+
+
+def available_access_levels() -> list[PropertyAccessLevel]:
+ return list(PropertyAccessLevel)
+
+
+__all__ = [
+ "InvalidPropertyAccessControlTargetError",
+ "PropertyAccessControlRuleNotFoundError",
+ "PropertyAccessLevel",
+ "PropertyDefinitionNotFoundError",
+ "available_access_levels",
+ "delete_property_access_control",
+ "get_property_access_state",
+ "upsert_property_access_control",
+]
diff --git a/products/access_control/backend/facade/contracts.py b/products/access_control/backend/facade/contracts.py
index e08c64f735b6..b7f9a37f60b1 100644
--- a/products/access_control/backend/facade/contracts.py
+++ b/products/access_control/backend/facade/contracts.py
@@ -1,13 +1,70 @@
"""
Contract types for access_control.
-Stable, framework-free frozen dataclasses that define what this
-product exposes to the rest of the codebase.
+Stable, framework-free frozen dataclasses that define what this product
+exposes to the rest of the codebase. No Django/DRF imports here.
+"""
-Characteristics:
-- No Django imports
-- Immutable (frozen=True)
-- Used by facade as inputs/outputs
+from dataclasses import dataclass, field
+from datetime import datetime
+from enum import Enum
+from uuid import UUID
-Do NOT depend on Django models, DRF serializers, or request objects.
-"""
+
+class PropertyAccessLevel(str, Enum):
+ """Effective access level for a property."""
+
+ READ_WRITE = "read_write"
+ READ = "read"
+ NONE = "none"
+
+ def grants_access(self) -> bool:
+ """Returns True if this level allows the property to be read in queries."""
+ return self in (PropertyAccessLevel.READ_WRITE, PropertyAccessLevel.READ)
+
+
+# --- Output DTOs ---
+
+
+@dataclass(frozen=True)
+class PropertyAccessControlRule:
+ """A single access control rule for a property definition."""
+
+ id: UUID
+ access_level: PropertyAccessLevel
+ organization_member_id: UUID | None
+ role_id: UUID | None
+ created_by_id: int | None
+ created_at: datetime
+ updated_at: datetime
+
+
+@dataclass(frozen=True)
+class PropertyAccessControlState:
+ """The full access control state for a property definition."""
+
+ rules: list[PropertyAccessControlRule] = field(default_factory=list)
+ available_access_levels: list[PropertyAccessLevel] = field(default_factory=list)
+ default_access_level: PropertyAccessLevel = PropertyAccessLevel.READ_WRITE
+
+
+# --- Input DTOs ---
+
+
+@dataclass(frozen=True)
+class UpsertPropertyAccessControlInput:
+ """Input for creating or updating an access control rule."""
+
+ property_definition_id: str
+ access_level: PropertyAccessLevel
+ organization_member_id: UUID | None = None
+ role_id: UUID | None = None
+
+
+@dataclass(frozen=True)
+class DeletePropertyAccessControlInput:
+ """Input for deleting an access control rule."""
+
+ property_definition_id: str
+ organization_member_id: UUID | None = None
+ role_id: UUID | None = None
diff --git a/products/access_control/backend/presentation/serializers.py b/products/access_control/backend/presentation/serializers.py
index 39e7b7fc434e..e665c35a37f3 100644
--- a/products/access_control/backend/presentation/serializers.py
+++ b/products/access_control/backend/presentation/serializers.py
@@ -1,8 +1,125 @@
"""
DRF serializers for access_control.
-Converts frozen dataclasses to/from JSON. Can be auto-generated from
-dataclasses using DataclassSerializer.
+These convert DTOs <-> JSON and validate incoming request bodies.
+They must never touch ORM models directly — presentation code only
+talks to the facade.
"""
-# from ..facade.contracts import ...
+from rest_framework import serializers
+
+from ..facade import contracts
+from ..facade.contracts import PropertyAccessLevel
+
+_ACCESS_LEVEL_CHOICES = [(e.value, e.value) for e in PropertyAccessLevel]
+
+
+class PropertyAccessControlRuleSerializer(serializers.Serializer):
+ """Serializes a single access control rule DTO."""
+
+ id = serializers.UUIDField(read_only=True)
+ access_level = serializers.ChoiceField(
+ choices=_ACCESS_LEVEL_CHOICES,
+ help_text="The access level for this rule.",
+ )
+ organization_member = serializers.UUIDField(
+ source="organization_member_id",
+ allow_null=True,
+ help_text="The organization member UUID this rule applies to, if any.",
+ )
+ role = serializers.UUIDField(
+ source="role_id",
+ allow_null=True,
+ help_text="The role UUID this rule applies to, if any.",
+ )
+ created_by = serializers.IntegerField(
+ source="created_by_id",
+ allow_null=True,
+ read_only=True,
+ )
+ created_at = serializers.DateTimeField(read_only=True)
+ updated_at = serializers.DateTimeField(read_only=True)
+
+ def to_representation(self, instance: contracts.PropertyAccessControlRule) -> dict:
+ data = super().to_representation(instance)
+ # Serializer would otherwise coerce the enum via its str() (fine),
+ # but we normalize explicitly to the enum value string.
+ data["access_level"] = instance.access_level.value
+ return data
+
+
+class PropertyAccessControlStateSerializer(serializers.Serializer):
+ """Serializes the aggregate state for a property definition.
+
+ Preserves the existing API shape: ``access_controls`` is the list
+ of rules, plus the available levels and the computed default.
+ """
+
+ access_controls = PropertyAccessControlRuleSerializer(
+ source="rules",
+ many=True,
+ help_text="List of all access control rules for this property definition.",
+ )
+ available_access_levels = serializers.ListField(
+ child=serializers.CharField(),
+ help_text="Available access levels that can be assigned.",
+ )
+ default_access_level = serializers.CharField(
+ help_text="The default access level when no rules match.",
+ )
+
+ def to_representation(self, instance: contracts.PropertyAccessControlState) -> dict:
+ return {
+ "access_controls": PropertyAccessControlRuleSerializer(instance.rules, many=True).data,
+ "available_access_levels": [level.value for level in instance.available_access_levels],
+ "default_access_level": instance.default_access_level.value,
+ }
+
+
+class PropertyAccessControlUpdateSerializer(serializers.Serializer):
+ """Request body for upserting a rule (create or update)."""
+
+ property_definition_id = serializers.CharField(
+ help_text="The property definition ID this rule applies to.",
+ )
+ access_level = serializers.ChoiceField(
+ choices=_ACCESS_LEVEL_CHOICES,
+ help_text="The access level to set for this rule.",
+ )
+ organization_member = serializers.UUIDField(
+ required=False,
+ allow_null=True,
+ default=None,
+ help_text="The organization member UUID to set an override for.",
+ )
+ role = serializers.UUIDField(
+ required=False,
+ allow_null=True,
+ default=None,
+ help_text="The role UUID to set an override for.",
+ )
+
+
+class PropertyAccessControlDeleteSerializer(serializers.Serializer):
+ """Query parameters for deleting a rule.
+
+ Identifies the rule by ``property_definition_id`` plus an optional
+ ``organization_member`` or ``role`` override target. Omitting both
+ targets deletes the default rule for the property definition.
+ """
+
+ property_definition_id = serializers.CharField(
+ help_text="The property definition ID the rule applies to.",
+ )
+ organization_member = serializers.UUIDField(
+ required=False,
+ allow_null=True,
+ default=None,
+ help_text="The organization member UUID whose override should be deleted.",
+ )
+ role = serializers.UUIDField(
+ required=False,
+ allow_null=True,
+ default=None,
+ help_text="The role UUID whose override should be deleted.",
+ )
diff --git a/products/access_control/backend/presentation/urls.py b/products/access_control/backend/presentation/urls.py
index e18b9320fcbc..cb93f0972a51 100644
--- a/products/access_control/backend/presentation/urls.py
+++ b/products/access_control/backend/presentation/urls.py
@@ -1,8 +1,46 @@
-"""URL routes for access_control."""
+"""URL routes for field access controls on property definitions."""
-from rest_framework.routers import DefaultRouter
+from typing import Any
-# from .views import ...
+from rest_framework.routers import DefaultRouter, Route
+from rest_framework.viewsets import ViewSetMixin
-router = DefaultRouter()
+from .views import PropertyAccessControlViewSet
+
+
+class _CollectionDeleteRouter(DefaultRouter):
+ """DefaultRouter that dispatches DELETE on the collection URL and has no detail URL.
+
+ The property access control resource has no detail (pk) URL — rules are
+ identified by the (property_definition_id, organization_member, role)
+ tuple passed as query parameters. We patch the list route so that DELETE
+ on the collection URL is bound to the viewset's ``destroy`` action, and
+ drop the default detail route so DRF doesn't auto-expose a duplicate
+ ``/{lookup}/`` DELETE — which would otherwise collide with this one in
+ the OpenAPI schema.
+ """
+
+ _DETAIL_MAPPING = {
+ "get": "retrieve",
+ "put": "update",
+ "patch": "partial_update",
+ "delete": "destroy",
+ }
+
+ def get_routes(self, viewset: type[ViewSetMixin]) -> list[Any]:
+ routes = super().get_routes(viewset)
+ patched: list[Any] = []
+ for route in routes:
+ if isinstance(route, Route):
+ if route.mapping == {"get": "list", "post": "create"}:
+ route = route._replace(mapping={**route.mapping, "delete": "destroy"})
+ elif route.mapping == self._DETAIL_MAPPING:
+ # No detail URL — skip the auto-generated /{lookup}/ route.
+ continue
+ patched.append(route)
+ return patched
+
+
+router = _CollectionDeleteRouter()
+router.register(r"", PropertyAccessControlViewSet, basename="property-access-controls")
urlpatterns = router.urls
diff --git a/products/access_control/backend/presentation/views.py b/products/access_control/backend/presentation/views.py
index 13bc369256cd..b8fb58c5ae12 100644
--- a/products/access_control/backend/presentation/views.py
+++ b/products/access_control/backend/presentation/views.py
@@ -3,12 +3,172 @@ DRF views for access_control.
Responsibilities:
- Validate incoming JSON (via serializers)
-- Convert JSON to frozen dataclasses
-- Call facade methods (facade/api.py)
-- Convert frozen dataclasses to JSON responses
+- Convert JSON to DTOs
+- Call facade methods
+- Convert DTOs to JSON responses
-No business logic here - that belongs in logic.py via the facade.
+No business logic or ORM access here — that belongs in the facade / logic layer.
"""
+from typing import Any
-# from ..facade import api
+from drf_spectacular.openapi import AutoSchema
+from drf_spectacular.utils import OpenApiParameter, extend_schema
+from rest_framework import status
+from rest_framework.exceptions import NotFound, ValidationError
+from rest_framework.request import Request
+from rest_framework.response import Response
+from rest_framework.viewsets import GenericViewSet
+
+from posthog.api.routing import TeamAndOrgViewSetMixin
+from posthog.permissions import TeamMemberStrictManagementPermission
+
+from ..facade import api
+from ..facade.contracts import DeletePropertyAccessControlInput, PropertyAccessLevel, UpsertPropertyAccessControlInput
+from .serializers import (
+ PropertyAccessControlDeleteSerializer,
+ PropertyAccessControlRuleSerializer,
+ PropertyAccessControlStateSerializer,
+ PropertyAccessControlUpdateSerializer,
+)
+
+
+class _SingletonStateSchema(AutoSchema):
+ """Prevents drf-spectacular from wrapping the ``list`` response in an array.
+
+ The GET endpoint returns an aggregate ``PropertyAccessControlState`` object,
+ not a paginated/collection list.
+ """
+
+ def _is_list_view(self, serializer: object = None) -> bool:
+ return False
+
+
+class PropertyAccessControlViewSet(TeamAndOrgViewSetMixin, GenericViewSet):
+ """
+ Manages property-level access control rules for property definitions.
+
+ Mounted at `/api/environments/{team_id}/property_access_controls/`. The target
+ property definition is provided via the `property_definition_id` query parameter
+ on GET requests and in the request body on POST requests.
+ """
+
+ scope_object = "access_control"
+ serializer_class = PropertyAccessControlRuleSerializer
+ permission_classes = [TeamMemberStrictManagementPermission]
+ # The list endpoint returns an aggregate state object, not a paginated
+ # collection. Disable pagination and tell drf-spectacular not to wrap
+ # the response schema in an array, so the generated OpenAPI — and the
+ # downstream TypeScript / MCP types — reflect the actual response shape.
+ pagination_class = None
+ schema = _SingletonStateSchema()
+
+ @extend_schema(
+ parameters=[
+ OpenApiParameter(
+ name="property_definition_id",
+ description="The property definition ID to fetch access control rules for.",
+ required=True,
+ type=str,
+ ),
+ ],
+ responses={200: PropertyAccessControlStateSerializer},
+ description="Get all property access control rules for a property definition.",
+ )
+ def list(self, request: Request, *args: Any, **kwargs: Any) -> Response:
+ property_definition_id = request.query_params.get("property_definition_id")
+ if not property_definition_id:
+ raise ValidationError({"property_definition_id": "This query parameter is required."})
+
+ try:
+ state = api.get_property_access_state(
+ team_id=self.team_id,
+ property_definition_id=property_definition_id,
+ )
+ except api.PropertyDefinitionNotFoundError:
+ raise NotFound("Property definition not found.")
+
+ return Response(PropertyAccessControlStateSerializer(state).data)
+
+ @extend_schema(
+ request=PropertyAccessControlUpdateSerializer,
+ responses={200: PropertyAccessControlRuleSerializer},
+ description="Create or update a property access control rule.",
+ )
+ def create(self, request: Request, *args: Any, **kwargs: Any) -> Response:
+ serializer = PropertyAccessControlUpdateSerializer(data=request.data)
+ serializer.is_valid(raise_exception=True)
+ data = serializer.validated_data
+
+ created_by_id: int | None = request.user.pk if request.user.is_authenticated else None
+ try:
+ rule = api.upsert_property_access_control(
+ team_id=self.team_id,
+ created_by_id=created_by_id,
+ input=UpsertPropertyAccessControlInput(
+ property_definition_id=data["property_definition_id"],
+ access_level=PropertyAccessLevel(data["access_level"]),
+ organization_member_id=data.get("organization_member"),
+ role_id=data.get("role"),
+ ),
+ )
+ except api.PropertyDefinitionNotFoundError:
+ raise NotFound("Property definition not found.")
+ except api.InvalidPropertyAccessControlTargetError as exc:
+ raise ValidationError(str(exc))
+
+ return Response(
+ PropertyAccessControlRuleSerializer(rule).data,
+ status=status.HTTP_200_OK,
+ )
+
+ @extend_schema(
+ parameters=[
+ OpenApiParameter(
+ name="property_definition_id",
+ description="The property definition ID the rule applies to.",
+ required=True,
+ type=str,
+ ),
+ OpenApiParameter(
+ name="organization_member",
+ description="The organization member UUID whose override should be deleted.",
+ required=False,
+ type=str,
+ ),
+ OpenApiParameter(
+ name="role",
+ description="The role UUID whose override should be deleted.",
+ required=False,
+ type=str,
+ ),
+ ],
+ responses={204: None},
+ description=(
+ "Delete a property access control rule. The rule is identified by "
+ "`property_definition_id` plus an optional `organization_member` or "
+ "`role` query parameter. Omitting both targets deletes the default rule."
+ ),
+ )
+ def destroy(self, request: Request, *args: Any, **kwargs: Any) -> Response:
+ serializer = PropertyAccessControlDeleteSerializer(data=request.query_params)
+ serializer.is_valid(raise_exception=True)
+ data = serializer.validated_data
+
+ try:
+ api.delete_property_access_control(
+ team_id=self.team_id,
+ input=DeletePropertyAccessControlInput(
+ property_definition_id=data["property_definition_id"],
+ organization_member_id=data.get("organization_member"),
+ role_id=data.get("role"),
+ ),
+ )
+ except api.PropertyDefinitionNotFoundError:
+ raise NotFound("Property definition not found.")
+ except api.PropertyAccessControlRuleNotFoundError:
+ raise NotFound("Property access control rule not found.")
+ except api.InvalidPropertyAccessControlTargetError as exc:
+ raise ValidationError(str(exc))
+
+ return Response(status=status.HTTP_204_NO_CONTENT)
diff --git a/products/access_control/backend/property_access_control.py b/products/access_control/backend/property_access_control.py
index 85acdec6b01d..93e15a2eb205 100644
--- a/products/access_control/backend/property_access_control.py
+++ b/products/access_control/backend/property_access_control.py
@@ -1,12 +1,12 @@
from __future__ import annotations
-from enum import Enum
from typing import TYPE_CHECKING
from uuid import UUID
from posthog.models import OrganizationMembership
from posthog.models.team import Team
+from products.access_control.backend.facade.contracts import PropertyAccessLevel
from products.access_control.backend.models.property_access_control import PropertyAccessControl
from ee.models.rbac.role import RoleMembership
@@ -17,14 +17,16 @@ if TYPE_CHECKING:
from products.event_definitions.backend.models.property_definition import PropertyDefinition
-class PropertyAccessLevel(Enum):
- READ_WRITE = "read_write"
- READ = "read"
- NONE = "none"
-
- def grants_access(self) -> bool:
- """Returns True if this level allows the property to be read in queries."""
- return self in (PropertyAccessLevel.READ_WRITE, PropertyAccessLevel.READ)
+# Re-exported for legacy callers; canonical definition lives in facade.contracts.
+__all__ = [
+ "PropertyAccessLevel",
+ "get_default_access_level",
+ "get_non_writable_property_names",
+ "get_property_access_level",
+ "get_restricted_properties_for_team",
+ "get_restricted_property_names",
+ "strip_restricted_properties",
+]
def get_default_access_level() -> PropertyAccessLevel:
diff --git a/products/access_control/backend/tests/test_property_access_control_viewset.py b/products/access_control/backend/tests/test_property_access_control_viewset.py
new file mode 100644
index 000000000000..45fded3ff783
--- /dev/null
+++ b/products/access_control/backend/tests/test_property_access_control_viewset.py
@@ -0,0 +1,235 @@
+from posthog.test.base import APIBaseTest
+
+from rest_framework import status
+
+from posthog.models import OrganizationMembership, PropertyDefinition
+
+from products.access_control.backend.models.property_access_control import PropertyAccessControl
+from products.access_control.backend.property_access_control import PropertyAccessLevel
+
+
+class TestPropertyAccessControlViewSet(APIBaseTest):
+ def setUp(self):
+ super().setUp()
+ # Write operations require project admin privileges
+ self.organization_membership.level = OrganizationMembership.Level.ADMIN
+ self.organization_membership.save()
+
+ self.prop_def = PropertyDefinition.objects.create(
+ team=self.team,
+ name="secret_field",
+ property_type="String",
+ type=PropertyDefinition.Type.EVENT,
+ )
+ self.url = f"/api/environments/{self.team.pk}/property_access_controls/"
+ self.list_url = f"{self.url}?property_definition_id={self.prop_def.id}"
+
+ def _post(self, data: dict):
+ payload = {"property_definition_id": str(self.prop_def.id), **data}
+ return self.client.post(self.url, payload, format="json")
+
+ def test_list_empty(self):
+ response = self.client.get(self.list_url)
+ assert response.status_code == status.HTTP_200_OK
+ data = response.json()
+ assert data["access_controls"] == []
+ assert data["default_access_level"] == PropertyAccessLevel.READ_WRITE.value
+ assert set(data["available_access_levels"]) == {e.value for e in PropertyAccessLevel}
+
+ def test_list_missing_property_definition_id_returns_400(self):
+ response = self.client.get(self.url)
+ assert response.status_code == status.HTTP_400_BAD_REQUEST
+
+ def test_create_default_rule(self):
+ response = self._post({"access_level": PropertyAccessLevel.NONE.value})
+ assert response.status_code == status.HTTP_200_OK
+ assert response.json()["access_level"] == PropertyAccessLevel.NONE.value
+
+ # verify it shows up in list
+ list_response = self.client.get(self.list_url)
+ assert list_response.json()["default_access_level"] == PropertyAccessLevel.NONE.value
+ assert len(list_response.json()["access_controls"]) == 1
+
+ def test_create_member_override(self):
+ response = self._post(
+ {
+ "access_level": PropertyAccessLevel.READ_WRITE.value,
+ "organization_member": str(self.organization_membership.id),
+ }
+ )
+ assert response.status_code == status.HTTP_200_OK
+ assert response.json()["access_level"] == PropertyAccessLevel.READ_WRITE.value
+ # PrimaryKeyRelatedField serializes the FK as the PK value
+ assert str(response.json()["organization_member"]) == str(self.organization_membership.id)
+
+ def test_create_role_override(self):
+ from ee.models.rbac.role import Role
+
+ role = Role.objects.create(name="Analyst", organization=self.organization)
+ response = self._post(
+ {
+ "access_level": PropertyAccessLevel.READ.value,
+ "role": str(role.id),
+ }
+ )
+ assert response.status_code == status.HTTP_200_OK
+ assert response.json()["access_level"] == PropertyAccessLevel.READ.value
+ assert str(response.json()["role"]) == str(role.id)
+
+ def test_update_existing_rule(self):
+ # create a rule
+ self._post({"access_level": PropertyAccessLevel.NONE.value})
+ # update it
+ response = self._post({"access_level": PropertyAccessLevel.READ_WRITE.value})
+ assert response.status_code == status.HTTP_200_OK
+ assert response.json()["access_level"] == PropertyAccessLevel.READ_WRITE.value
+
+ # only one rule should exist
+ assert PropertyAccessControl.objects.filter(property_definition=self.prop_def).count() == 1
+
+ def test_update_preserves_original_created_by(self):
+ from posthog.models import User
+
+ # initial creator is self.user (logged in via APIBaseTest)
+ self._post({"access_level": PropertyAccessLevel.NONE.value})
+ rule = PropertyAccessControl.objects.get(property_definition=self.prop_def)
+ original_creator_id = rule.created_by_id
+ assert original_creator_id == self.user.id
+
+ # log in as a different admin and update the rule
+ other_user = User.objects.create_and_join(
+ organization=self.organization,
+ password="password",
+ level=OrganizationMembership.Level.ADMIN,
+ )
+ self.client.force_login(other_user)
+
+ response = self._post({"access_level": PropertyAccessLevel.READ_WRITE.value})
+ assert response.status_code == status.HTTP_200_OK
+
+ rule.refresh_from_db()
+ # created_by must remain the original creator, not the editor
+ assert rule.created_by_id == original_creator_id
+
+ def test_delete_default_rule(self):
+ # create a rule first
+ self._post({"access_level": PropertyAccessLevel.NONE.value})
+ assert PropertyAccessControl.objects.filter(property_definition=self.prop_def).count() == 1
+
+ # delete it via DELETE
+ response = self.client.delete(f"{self.url}?property_definition_id={self.prop_def.id}")
+ assert response.status_code == status.HTTP_204_NO_CONTENT
+ assert PropertyAccessControl.objects.filter(property_definition=self.prop_def).count() == 0
+
+ def test_delete_member_override(self):
+ self._post(
+ {
+ "access_level": PropertyAccessLevel.READ_WRITE.value,
+ "organization_member": str(self.organization_membership.id),
+ }
+ )
+ assert PropertyAccessControl.objects.filter(property_definition=self.prop_def).count() == 1
+
+ response = self.client.delete(
+ f"{self.url}?property_definition_id={self.prop_def.id}"
+ f"&organization_member={self.organization_membership.id}"
+ )
+ assert response.status_code == status.HTTP_204_NO_CONTENT
+ assert PropertyAccessControl.objects.filter(property_definition=self.prop_def).count() == 0
+
+ def test_delete_missing_rule_returns_404(self):
+ response = self.client.delete(f"{self.url}?property_definition_id={self.prop_def.id}")
+ assert response.status_code == status.HTTP_404_NOT_FOUND
+
+ def test_delete_missing_property_definition_id_returns_400(self):
+ response = self.client.delete(self.url)
+ assert response.status_code == status.HTTP_400_BAD_REQUEST
+
+ def test_create_with_null_access_level_returns_400(self):
+ response = self._post({"access_level": None})
+ assert response.status_code == status.HTTP_400_BAD_REQUEST
+
+ def test_list_with_multiple_rules(self):
+ from ee.models.rbac.role import Role
+
+ role = Role.objects.create(name="Analyst", organization=self.organization)
+
+ # default rule
+ self._post({"access_level": PropertyAccessLevel.NONE.value})
+ # member override
+ self._post(
+ {
+ "access_level": PropertyAccessLevel.READ_WRITE.value,
+ "organization_member": str(self.organization_membership.id),
+ }
+ )
+ # role override
+ self._post(
+ {"access_level": PropertyAccessLevel.READ.value, "role": str(role.id)},
+ )
+
+ response = self.client.get(self.list_url)
+ assert response.status_code == status.HTTP_200_OK
+ data = response.json()
+ assert len(data["access_controls"]) == 3
+ assert data["default_access_level"] == PropertyAccessLevel.NONE.value
+
+ def test_cross_org_role_rejected(self):
+ from posthog.models import Organization
+
+ from ee.models.rbac.role import Role
+
+ other_org = Organization.objects.create(name="Other org")
+ other_role = Role.objects.create(name="Other org role", organization=other_org)
+
+ response = self._post(
+ {
+ "access_level": PropertyAccessLevel.READ.value,
+ "role": str(other_role.id),
+ }
+ )
+ assert response.status_code == status.HTTP_400_BAD_REQUEST
+ assert PropertyAccessControl.objects.filter(property_definition=self.prop_def).count() == 0
+
+ def test_cross_org_organization_member_rejected(self):
+ from posthog.models import Organization, OrganizationMembership, User
+
+ other_org = Organization.objects.create(name="Other org")
+ other_user = User.objects.create(email="[email protected]")
+ other_membership = OrganizationMembership.objects.create(
+ organization=other_org, user=other_user, level=OrganizationMembership.Level.MEMBER
+ )
+
+ response = self._post(
+ {
+ "access_level": PropertyAccessLevel.READ.value,
+ "organization_member": str(other_membership.id),
+ }
+ )
+ assert response.status_code == status.HTTP_400_BAD_REQUEST
+ assert PropertyAccessControl.objects.filter(property_definition=self.prop_def).count() == 0
+
+ def test_delete_cross_org_role_rejected(self):
+ from posthog.models import Organization
+
+ from ee.models.rbac.role import Role
+
+ other_org = Organization.objects.create(name="Other org")
+ other_role = Role.objects.create(name="Other org role", organization=other_org)
+
+ response = self.client.delete(f"{self.url}?property_definition_id={self.prop_def.id}&role={other_role.id}")
+ assert response.status_code == status.HTTP_400_BAD_REQUEST
+
+ def test_non_admin_can_read_but_not_write(self):
+ # Downgrade to regular member
+ self.organization_membership.level = OrganizationMembership.Level.MEMBER
+ self.organization_membership.save()
+
+ # GET should work (read access)
+ response = self.client.get(self.list_url)
+ assert response.status_code == status.HTTP_200_OK
+
+ # POST should be forbidden (write access requires admin)
+ response = self._post({"access_level": PropertyAccessLevel.NONE.value})
+ assert response.status_code == status.HTTP_403_FORBIDDEN
diff --git a/products/access_control/frontend/generated/api.schemas.ts b/products/access_control/frontend/generated/api.schemas.ts
new file mode 100644
index 000000000000..8fe40a2bf2cd
--- /dev/null
+++ b/products/access_control/frontend/generated/api.schemas.ts
@@ -0,0 +1,109 @@
+/**
+ * Auto-generated from the Django backend OpenAPI schema.
+ * To modify these types, update the Django serializers or views, then run:
+ * hogli build:openapi
+ * Questions or issues? #team-devex on Slack
+ *
+ * PostHog API - generated
+ * OpenAPI spec version: 1.0.0
+ */
+/**
+ * * `read_write` - read_write
+ * `read` - read
+ * `none` - none
+ */
+export type AccessLevelEnumApi = (typeof AccessLevelEnumApi)[keyof typeof AccessLevelEnumApi]
+
+export const AccessLevelEnumApi = {
+ ReadWrite: 'read_write',
+ Read: 'read',
+ None: 'none',
+} as const
+
+/**
+ * Serializes a single access control rule DTO.
+ */
+export interface PropertyAccessControlRuleApi {
+ readonly id: string
+ /** The access level for this rule.
+
+ * `read_write` - read_write
+ * `read` - read
+ * `none` - none */
+ access_level: AccessLevelEnumApi
+ /**
+ * The organization member UUID this rule applies to, if any.
+ * @nullable
+ */
+ organization_member: string | null
+ /**
+ * The role UUID this rule applies to, if any.
+ * @nullable
+ */
+ role: string | null
+ /** @nullable */
+ readonly created_by: number | null
+ readonly created_at: string
+ readonly updated_at: string
+}
+
+/**
+ * Serializes the aggregate state for a property definition.
+
+Preserves the existing API shape: ``access_controls`` is the list
+of rules, plus the available levels and the computed default.
+ */
+export interface PropertyAccessControlStateApi {
+ /** List of all access control rules for this property definition. */
+ access_controls: PropertyAccessControlRuleApi[]
+ /** Available access levels that can be assigned. */
+ available_access_levels: string[]
+ /** The default access level when no rules match. */
+ default_access_level: string
+}
+
+/**
+ * Request body for upserting a rule (create or update).
+ */
+export interface PropertyAccessControlUpdateApi {
+ /** The property definition ID this rule applies to. */
+ property_definition_id: string
+ /** The access level to set for this rule.
+
+ * `read_write` - read_write
+ * `read` - read
+ * `none` - none */
+ access_level: AccessLevelEnumApi
+ /**
+ * The organization member UUID to set an override for.
+ * @nullable
+ */
+ organization_member?: string | null
+ /**
+ * The role UUID to set an override for.
+ * @nullable
+ */
+ role?: string | null
+}
+
+export type PropertyAccessControlsRetrieveParams = {
+ /**
+ * The property definition ID to fetch access control rules for.
+ */
+ property_definition_id: string
+}
+
+export type PropertyAccessControlsDestroyParams = {
+ /**
+ * The organization member UUID whose override should be deleted.
+ */
+ organization_member?: string
+ /**
+ * The property definition ID the rule applies to.
+ */
+ property_definition_id: string
+ /**
+ * The role UUID whose override should be deleted.
+ */
+ role?: string
+}
diff --git a/products/access_control/frontend/generated/api.ts b/products/access_control/frontend/generated/api.ts
new file mode 100644
index 000000000000..7d2288cbf095
--- /dev/null
+++ b/products/access_control/frontend/generated/api.ts
@@ -0,0 +1,100 @@
+import { apiMutator } from '../../../../frontend/src/lib/api-orval-mutator'
+/**
+ * Auto-generated from the Django backend OpenAPI schema.
+ * To modify these types, update the Django serializers or views, then run:
+ * hogli build:openapi
+ * Questions or issues? #team-devex on Slack
+ *
+ * PostHog API - generated
+ * OpenAPI spec version: 1.0.0
+ */
+import type {
+ PropertyAccessControlRuleApi,
+ PropertyAccessControlStateApi,
+ PropertyAccessControlUpdateApi,
+ PropertyAccessControlsDestroyParams,
+ PropertyAccessControlsRetrieveParams,
+} from './api.schemas'
+
+export const getPropertyAccessControlsRetrieveUrl = (
+ projectId: string,
+ params: PropertyAccessControlsRetrieveParams
+) => {
+ const normalizedParams = new URLSearchParams()
+
+ Object.entries(params || {}).forEach(([key, value]) => {
+ if (value !== undefined) {
+ normalizedParams.append(key, value === null ? 'null' : value.toString())
+ }
+ })
+
+ const stringifiedParams = normalizedParams.toString()
+
+ return stringifiedParams.length > 0
+ ? `/api/environments/${projectId}/property_access_controls/?${stringifiedParams}`
+ : `/api/environments/${projectId}/property_access_controls/`
+}
+
+/**
+ * Get all property access control rules for a property definition.
+ */
+export const propertyAccessControlsRetrieve = async (
+ projectId: string,
+ params: PropertyAccessControlsRetrieveParams,
+ options?: RequestInit
+): Promise<PropertyAccessControlStateApi> => {
+ return apiMutator<PropertyAccessControlStateApi>(getPropertyAccessControlsRetrieveUrl(projectId, params), {
+ ...options,
+ method: 'GET',
+ })
+}
+
+export const getPropertyAccessControlsCreateUrl = (projectId: string) => {
+ return `/api/environments/${projectId}/property_access_controls/`
+}
+
+/**
+ * Create or update a property access control rule.
+ */
+export const propertyAccessControlsCreate = async (
+ projectId: string,
+ propertyAccessControlUpdateApi: PropertyAccessControlUpdateApi,
+ options?: RequestInit
+): Promise<PropertyAccessControlRuleApi> => {
+ return apiMutator<PropertyAccessControlRuleApi>(getPropertyAccessControlsCreateUrl(projectId), {
+ ...options,
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json', ...options?.headers },
+ body: JSON.stringify(propertyAccessControlUpdateApi),
+ })
+}
+
+export const getPropertyAccessControlsDestroyUrl = (projectId: string, params: PropertyAccessControlsDestroyParams) => {
+ const normalizedParams = new URLSearchParams()
+
+ Object.entries(params || {}).forEach(([key, value]) => {
+ if (value !== undefined) {
+ normalizedParams.append(key, value === null ? 'null' : value.toString())
+ }
+ })
+
+ const stringifiedParams = normalizedParams.toString()
+
+ return stringifiedParams.length > 0
+ ? `/api/environments/${projectId}/property_access_controls/?${stringifiedParams}`
+ : `/api/environments/${projectId}/property_access_controls/`
+}
+
+/**
+ * Delete a property access control rule. The rule is identified by `property_definition_id` plus an optional `organization_member` or `role` query parameter. Omitting both targets deletes the default rule.
+ */
+export const propertyAccessControlsDestroy = async (
+ projectId: string,
+ params: PropertyAccessControlsDestroyParams,
+ options?: RequestInit
+): Promise<void> => {
+ return apiMutator<void>(getPropertyAccessControlsDestroyUrl(projectId, params), {
+ ...options,
+ method: 'DELETE',
+ })
+}
diff --git a/products/access_control/frontend/generated/api.zod.ts b/products/access_control/frontend/generated/api.zod.ts
new file mode 100644
index 000000000000..32787713b102
--- /dev/null
+++ b/products/access_control/frontend/generated/api.zod.ts
@@ -0,0 +1,27 @@
+/**
+ * Auto-generated Zod validation schemas from the Django backend OpenAPI schema.
+ * To modify these schemas, update the Django serializers or views, then run:
+ * hogli build:openapi
+ * Questions or issues? #team-devex on Slack
+ *
+ * PostHog API - generated
+ * OpenAPI spec version: 1.0.0
+ */
+import * as zod from 'zod'
+
+/**
+ * Create or update a property access control rule.
+ */
+export const PropertyAccessControlsCreateBody = /* @__PURE__ */ zod
+ .object({
+ property_definition_id: zod.string().describe('The property definition ID this rule applies to.'),
+ access_level: zod
+ .enum(['read_write', 'read', 'none'])
+ .describe('\* `read_write` - read_write\n\* `read` - read\n\* `none` - none')
+ .describe(
+ 'The access level to set for this rule.\n\n\* `read_write` - read_write\n\* `read` - read\n\* `none` - none'
+ ),
+ organization_member: zod.uuid().nullish().describe('The organization member UUID to set an override for.'),
+ role: zod.uuid().nullish().describe('The role UUID to set an override for.'),
+ })
+ .describe('Request body for upserting a rule (create or update).')
diff --git a/products/access_control/mcp/tools.yaml b/products/access_control/mcp/tools.yaml
new file mode 100644
index 000000000000..7bc0244e2d92
--- /dev/null
+++ b/products/access_control/mcp/tools.yaml
@@ -0,0 +1,20 @@
+# MCP tool definition — tool entries are scaffolded from the OpenAPI schema.
+# The tool list and operation IDs are kept in sync automatically:
+# pnpm --filter=@posthog/mcp run scaffold-yaml -- --sync-all
+#
+# To enable a tool, set enabled: true and add required scopes + annotations.
+# All other fields (title, description, enrich_url, etc.) are yours to configure.
+category: Access control
+feature: access_control
+url_prefix: /
+ui_apps: {}
+tools:
+ property-access-controls-create:
+ operation: property_access_controls_create
+ enabled: false
+ property-access-controls-destroy:
+ operation: property_access_controls_destroy
+ enabled: false
+ property-access-controls-retrieve:
+ operation: property_access_controls_retrieve
+ enabled: false
diff --git a/products/platform_features/backend/org_intelligence/__init__.py b/products/platform_features/backend/org_intelligence/__init__.py
deleted file mode 100644
index e69de29bb2d1..000000000000
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 119c1671f646..d540a552f285 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -31,6 +31,20 @@ export namespace Schemas {
AiGenerationClusters: '$ai_generation_clusters',
} as const;
+ /**
+ * * `read_write` - read_write
+ * `read` - read
+ * `none` - none
+ */
+ export type AccessLevelEnum = typeof AccessLevelEnum[keyof typeof AccessLevelEnum];
+
+
+ export const AccessLevelEnum = {
+ ReadWrite: 'read_write',
+ Read: 'read',
+ None: 'none',
+ } as const;
+
/**
* * `warehouse` - warehouse
* `direct` - direct
@@ -31814,6 +31828,72 @@ export namespace Schemas {
values: PropertyItem[];
}
+ /**
+ * Serializes a single access control rule DTO.
+ */
+ export interface PropertyAccessControlRule {
+ readonly id: string;
+ /** The access level for this rule.
+
+ * `read_write` - read_write
+ * `read` - read
+ * `none` - none */
+ access_level: AccessLevelEnum;
+ /**
+ * The organization member UUID this rule applies to, if any.
+ * @nullable
+ */
+ organization_member: string | null;
+ /**
+ * The role UUID this rule applies to, if any.
+ * @nullable
+ */
+ role: string | null;
+ /** @nullable */
+ readonly created_by: number | null;
+ readonly created_at: string;
+ readonly updated_at: string;
+ }
+
+ /**
+ * Serializes the aggregate state for a property definition.
+
+ Preserves the existing API shape: ``access_controls`` is the list
+ of rules, plus the available levels and the computed default.
+ */
+ export interface PropertyAccessControlState {
+ /** List of all access control rules for this property definition. */
+ access_controls: PropertyAccessControlRule[];
+ /** Available access levels that can be assigned. */
+ available_access_levels: string[];
+ /** The default access level when no rules match. */
+ default_access_level: string;
+ }
+
+ /**
+ * Request body for upserting a rule (create or update).
+ */
+ export interface PropertyAccessControlUpdate {
+ /** The property definition ID this rule applies to. */
+ property_definition_id: string;
+ /** The access level to set for this rule.
+
+ * `read_write` - read_write
+ * `read` - read
+ * `none` - none */
+ access_level: AccessLevelEnum;
+ /**
+ * The organization member UUID to set an override for.
+ * @nullable
+ */
+ organization_member?: string | null;
+ /**
+ * The role UUID to set an override for.
+ * @nullable
+ */
+ role?: string | null;
+ }
+
export type PropertyType = typeof PropertyType[keyof typeof PropertyType];
@@ -40013,6 +40093,28 @@ export namespace Schemas {
target_type?: string;
};
+ export type PropertyAccessControlsRetrieveParams = {
+ /**
+ * The property definition ID to fetch access control rules for.
+ */
+ property_definition_id: string;
+ };
+
+ export type PropertyAccessControlsDestroyParams = {
+ /**
+ * The organization member UUID whose override should be deleted.
+ */
+ organization_member?: string;
+ /**
+ * The property definition ID the rule applies to.
+ */
+ property_definition_id: string;
+ /**
+ * The role UUID whose override should be deleted.
+ */
+ role?: string;
+ };
+
export type QuickFiltersListParams = {
/**
* Number of results to return per page.
diff --git a/tach.toml b/tach.toml
index 4a4d8ccf2e7a..9351e49be0fe 100644
--- a/tach.toml
+++ b/tach.toml
@@ -583,6 +583,16 @@ depends_on = [
]
layer = "modules"
+[[interfaces]]
+expose = [
+ "backend\\.facade.*",
+ "backend\\.presentation\\.views.*",
+]
+from = [
+ "products.access_control",
+]
+
+# Legacy leaks — core (posthog/ee) still imports these internals directly.
[[interfaces]]
expose = [
"backend\\.models.*",