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.

721 B
Raw Blame
"""Django app configuration for authorization."""

from django.apps import AppConfig
from django.db.models.signals import post_delete, post_save

from .logic import session

# A write to these models clears the session's cached rules.
RULE_MODELS = ("ee.AccessControl", "ee.RoleMembership", "posthog.OrganizationMembership")


class AuthorizationConfig(AppConfig):
    name = "products.authorization.backend"
    label = "authorization"

    def ready(self) -> None:
        for model in RULE_MODELS:
            post_save.connect(session.invalidate, sender=model, dispatch_uid=f"authorization-save-{model}")
            post_delete.connect(session.invalidate, sender=model, dispatch_uid=f"authorization-delete-{model}")