2020-08-26 10:34:57 +02:00
|
|
|
"""
|
|
|
|
Django settings for PostHog Enterprise Edition.
|
|
|
|
"""
|
2024-04-19 14:19:10 +02:00
|
|
|
|
2020-12-04 19:54:27 +01:00
|
|
|
import os
|
2020-10-22 18:46:33 +02:00
|
|
|
|
2024-10-25 14:19:45 +02:00
|
|
|
from posthog.settings import AUTHENTICATION_BACKENDS, DEBUG, DEMO, SITE_URL
|
2023-06-15 14:03:08 +02:00
|
|
|
from posthog.settings.utils import get_from_env
|
|
|
|
from posthog.utils import str_to_bool
|
2020-08-26 10:34:57 +02:00
|
|
|
|
2022-03-31 11:04:12 +02:00
|
|
|
# SSO
|
2024-04-19 14:19:10 +02:00
|
|
|
AUTHENTICATION_BACKENDS = [
|
|
|
|
*AUTHENTICATION_BACKENDS,
|
2022-03-31 11:04:12 +02:00
|
|
|
"ee.api.authentication.MultitenantSAMLAuth",
|
|
|
|
"social_core.backends.google.GoogleOAuth2",
|
|
|
|
]
|
|
|
|
|
|
|
|
# SAML base attributes
|
2021-08-27 16:20:49 +02:00
|
|
|
SOCIAL_AUTH_SAML_SP_ENTITY_ID = SITE_URL
|
|
|
|
SOCIAL_AUTH_SAML_SECURITY_CONFIG = {
|
2022-11-17 12:31:16 +01:00
|
|
|
"wantAttributeStatement": False, # AttributeStatement is optional in the specification
|
|
|
|
"requestedAuthnContext": False, # do not explicitly request a password login, also allow multifactor and others
|
2021-08-27 16:20:49 +02:00
|
|
|
}
|
|
|
|
# Attributes below are required for the SAML integration from social_core to work properly
|
|
|
|
SOCIAL_AUTH_SAML_SP_PUBLIC_CERT = ""
|
|
|
|
SOCIAL_AUTH_SAML_SP_PRIVATE_KEY = ""
|
|
|
|
SOCIAL_AUTH_SAML_ORG_INFO = {"en-US": {"name": "posthog", "displayname": "PostHog", "url": "https://posthog.com"}}
|
2023-10-26 12:38:15 +02:00
|
|
|
SOCIAL_AUTH_SAML_TECHNICAL_CONTACT = {
|
|
|
|
"givenName": "PostHog Support",
|
|
|
|
"emailAddress": "hey@posthog.com",
|
|
|
|
}
|
2021-08-27 16:20:49 +02:00
|
|
|
SOCIAL_AUTH_SAML_SUPPORT_CONTACT = SOCIAL_AUTH_SAML_TECHNICAL_CONTACT
|
|
|
|
|
2021-12-16 04:45:51 +01:00
|
|
|
|
2022-03-31 11:04:12 +02:00
|
|
|
# Google SSO
|
2022-03-16 14:46:49 +01:00
|
|
|
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = os.getenv("SOCIAL_AUTH_GOOGLE_OAUTH2_KEY")
|
|
|
|
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = os.getenv("SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET")
|
|
|
|
if "SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_DOMAINS" in os.environ:
|
2024-04-25 09:22:28 +02:00
|
|
|
SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_DOMAINS: list[str] = os.environ[
|
2022-03-16 14:46:49 +01:00
|
|
|
"SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_DOMAINS"
|
|
|
|
].split(",")
|
2022-08-17 10:21:28 +02:00
|
|
|
elif DEMO:
|
|
|
|
# Only PostHog team members can use social auth in the demo environment
|
|
|
|
# This is because in the demo env social signups get is_staff=True to facilitate instance management
|
|
|
|
SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_DOMAINS = ["posthog.com"]
|
2022-03-16 14:46:49 +01:00
|
|
|
|
2021-08-26 17:48:57 +02:00
|
|
|
# Schedule to run column materialization on. Follows crontab syntax.
|
|
|
|
# Use empty string to prevent from materializing
|
|
|
|
MATERIALIZE_COLUMNS_SCHEDULE_CRON = get_from_env("MATERIALIZE_COLUMNS_SCHEDULE_CRON", "0 5 * * SAT")
|
|
|
|
# Minimum query time before a query if considered for optimization by adding materialized columns
|
2024-02-05 11:24:44 +01:00
|
|
|
MATERIALIZE_COLUMNS_MINIMUM_QUERY_TIME = get_from_env("MATERIALIZE_COLUMNS_MINIMUM_QUERY_TIME", 40000, type_cast=int)
|
2021-09-04 17:07:20 +02:00
|
|
|
# How many hours backwards to look for queries to optimize
|
|
|
|
MATERIALIZE_COLUMNS_ANALYSIS_PERIOD_HOURS = get_from_env(
|
|
|
|
"MATERIALIZE_COLUMNS_ANALYSIS_PERIOD_HOURS", 7 * 24, type_cast=int
|
|
|
|
)
|
2021-08-26 17:48:57 +02:00
|
|
|
# How big of a timeframe to backfill when materializing event properties. 0 for no backfilling
|
2024-03-28 12:04:00 +01:00
|
|
|
MATERIALIZE_COLUMNS_BACKFILL_PERIOD_DAYS = get_from_env("MATERIALIZE_COLUMNS_BACKFILL_PERIOD_DAYS", 0, type_cast=int)
|
2021-09-07 09:56:29 +02:00
|
|
|
# Maximum number of columns to materialize at once. Avoids running into resource bottlenecks (storage + ingest + backfilling).
|
2024-02-11 21:07:06 +01:00
|
|
|
MATERIALIZE_COLUMNS_MAX_AT_ONCE = get_from_env("MATERIALIZE_COLUMNS_MAX_AT_ONCE", 100, type_cast=int)
|
2022-10-19 08:58:36 +02:00
|
|
|
|
2022-11-10 17:37:56 +01:00
|
|
|
BILLING_SERVICE_URL = get_from_env("BILLING_SERVICE_URL", "https://billing.posthog.com")
|
2023-06-15 14:03:08 +02:00
|
|
|
|
|
|
|
# Whether to enable the admin portal. Default false for self-hosted as if not setup properly can pose security issues.
|
|
|
|
ADMIN_PORTAL_ENABLED = get_from_env("ADMIN_PORTAL_ENABLED", DEMO or DEBUG, type_cast=str_to_bool)
|
2023-09-29 13:06:16 +02:00
|
|
|
|
2024-01-17 17:38:14 +01:00
|
|
|
PARALLEL_ASSET_GENERATION_MAX_TIMEOUT_MINUTES = get_from_env(
|
|
|
|
"PARALLEL_ASSET_GENERATION_MAX_TIMEOUT_MINUTES", 10.0, type_cast=float
|
|
|
|
)
|
2024-08-15 11:46:47 +02:00
|
|
|
|
|
|
|
HOOK_HOG_FUNCTION_TEAMS = get_from_env("HOOK_HOG_FUNCTION_TEAMS", "", type_cast=str)
|
2024-10-25 14:19:45 +02:00
|
|
|
|
|
|
|
# Assistant
|
|
|
|
LANGFUSE_PUBLIC_KEY = get_from_env("LANGFUSE_PUBLIC_KEY", "", type_cast=str)
|
|
|
|
LANGFUSE_SECRET_KEY = get_from_env("LANGFUSE_SECRET_KEY", "", type_cast=str)
|
|
|
|
LANGFUSE_HOST = get_from_env("LANGFUSE_HOST", "https://us.cloud.langfuse.com", type_cast=str)
|