Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Roll out plugins fully #3291

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions ee/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
"SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_DOMAINS"
].split(",")

# TODO: eliminate this setting for full rollout of Plugins on EE/Cloud
PLUGINS_CLOUD_WHITELISTED_ORG_IDS: List[str] = os.getenv("PLUGINS_CLOUD_WHITELISTED_ORG_IDS", "").split(",")

# ClickHouse and Kafka
CLICKHOUSE_DENORMALIZED_PROPERTIES = os.getenv("CLICKHOUSE_DENORMALIZED_PROPERTIES", "").split(",")
KAFKA_ENABLED = PRIMARY_DB == RDBMS.CLICKHOUSE and not TEST
8 changes: 0 additions & 8 deletions posthog/api/test/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,11 +526,3 @@ def test_plugin_config_attachment(self, mock_get, mock_reload):
)
self.assertEqual(response.data["config"], {"bar": "moop"}) # type: ignore
self.assertEqual(PluginAttachment.objects.count(), 0)

def test_cloud_plugin_whitelisting(self, mock_get, mock_reload):
with self.settings(MULTI_TENANCY=True, TEST=False):
self.assertFalse(can_install_plugins_via_api(self.organization))
self.assertFalse(can_configure_plugins_via_api(self.organization))
with self.settings(PLUGINS_CLOUD_WHITELISTED_ORG_IDS=f"{self.organization.id},"):
self.assertTrue(can_install_plugins_via_api(self.organization))
self.assertTrue(can_configure_plugins_via_api(self.organization))
23 changes: 4 additions & 19 deletions posthog/plugins/access.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,9 @@
from posthog.models.organization import Organization


# We disable Plugins on Cloud, except for whitelisted organizations
# Disregarding this in TEST mode, so that we can be sure plugins actually work in EE if/when needed
def guard_cloud(organization_or_id: Optional[Union[Organization, UUID, str]]):
organization_id: Optional[str] = (
None
if not organization_or_id
else str(organization_or_id if isinstance(organization_or_id, (str, UUID)) else organization_or_id.id)
)
return (
settings.TEST
or not getattr(settings, "MULTI_TENANCY", False)
or (organization_id and organization_id in getattr(settings, "PLUGINS_CLOUD_WHITELISTED_ORG_IDS", []))
)
def can_install_plugins_via_api(organization_or_id: Optional[Union[Organization, UUID]]):
return settings.PLUGINS_INSTALL_VIA_API


def can_install_plugins_via_api(organization_or_id: Optional[Union[Organization, UUID]]) -> bool:
return bool(settings.PLUGINS_INSTALL_VIA_API and guard_cloud(organization_or_id))


def can_configure_plugins_via_api(organization_or_id: Optional[Union[Organization, UUID]]) -> bool:
return bool(settings.PLUGINS_CONFIGURE_VIA_API and guard_cloud(organization_or_id))
def can_configure_plugins_via_api(organization_or_id: Optional[Union[Organization, UUID]]):
return settings.PLUGINS_CONFIGURE_VIA_API
4 changes: 0 additions & 4 deletions task-definition.web.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@
"name": "SITE_URL",
"value": "https://app.posthog.com"
},
{
"name": "PLUGINS_CLOUD_WHITELISTED_ORG_IDS",
"value": "4dc8564d-bd82-1065-2f40-97f7c50f67cf,2f3a6d88-4789-027b-6205-7b9a0e12217d"
},
{
"name": "EMAIL_DEFAULT_FROM",
"value": "hey@posthog.com"
Expand Down