
* root: initial rename * web: rename custom element prefix * root: rename external functions with pb_ prefix * root: fix formatting * root: replace domain with goauthentik.io * proxy: update path * root: rename remaining prefixes * flows: rename file extension * root: pbadmin -> akadmin * docs: fix image filenames * lifecycle: ignore migration files * ci: copy default config from current source before loading last tagged * *: new sentry dsn * tests: fix missing python3.9-dev package * root: add additional migrations for service accounts created by outposts * core: mark system-created service accounts with attribute * policies/expression: fix pb_ replacement not working * web: fix last linting errors, add lit-analyse * policies/expressions: fix lint errors * web: fix sidebar display on screens where not all items fit * proxy: attempt to fix proxy pipeline * proxy: use go env GOPATH to get gopath * lib: fix user_default naming inconsistency * docs: add upgrade docs * docs: update screenshots to use authentik * admin: fix create button on empty-state of outpost * web: fix modal submit not refreshing SiteShell and Table * web: fix height of app-card and height of generic icon * web: fix rendering of subtext * admin: fix version check error not being caught * web: fix worker count not being shown * docs: update screenshots * root: new icon * web: fix lint error * admin: fix linting error * root: migrate coverage config to pyproject
37 lines
1.4 KiB
Python
37 lines
1.4 KiB
Python
"""authentik outpost signals"""
|
|
from django.db.models import Model
|
|
from django.db.models.signals import post_save, pre_delete
|
|
from django.dispatch import receiver
|
|
from structlog import get_logger
|
|
|
|
from authentik.lib.utils.reflection import class_to_path
|
|
from authentik.outposts.models import Outpost
|
|
from authentik.outposts.tasks import outpost_post_save, outpost_pre_delete
|
|
|
|
LOGGER = get_logger()
|
|
|
|
|
|
@receiver(post_save)
|
|
# pylint: disable=unused-argument
|
|
def post_save_update(sender, instance: Model, **_):
|
|
"""If an Outpost is saved, Ensure that token is created/updated
|
|
|
|
If an OutpostModel, or a model that is somehow connected to an OutpostModel is saved,
|
|
we send a message down the relevant OutpostModels WS connection to trigger an update"""
|
|
if instance.__module__ == "django.db.migrations.recorder":
|
|
return
|
|
if instance.__module__ == "__fake__":
|
|
return
|
|
outpost_post_save.delay(class_to_path(instance.__class__), instance.pk)
|
|
|
|
|
|
@receiver(pre_delete, sender=Outpost)
|
|
# pylint: disable=unused-argument
|
|
def pre_delete_cleanup(sender, instance: Outpost, **_):
|
|
"""Ensure that Outpost's user is deleted (which will delete the token through cascade)"""
|
|
instance.user.delete()
|
|
# To ensure that deployment is cleaned up *consistently* we call the controller, and wait
|
|
# for it to finish. We don't want to call it in this thread, as we don't have the K8s
|
|
# credentials here
|
|
outpost_pre_delete.delay(instance.pk.hex).get()
|