authentik.core.migrations.0068_move_source_icons

 1# Generated by Django 5.2.17 on 2026-10-30 04:07
 2from django.apps.registry import Apps
 3from django.db import migrations
 4from django.db.backends.base.schema import BaseDatabaseSchemaEditor
 5
 6PREFIX = "/static/authentik/sources/"
 7
 8# Built-in source icons moved from a single file to a folder with a variant per theme
 9MOVED_ICONS = {
10    f"{PREFIX}{name}.svg": f"{PREFIX}{name}/%(theme)s.svg"
11    for name in (
12        "apple",
13        "azuread",
14        "discord",
15        "dropbox",
16        "entraid",
17        "facebook",
18        "github",
19        "gitlab",
20        "google",
21        "mailcow",
22        "okta",
23        "openidconnect",
24        "patreon",
25        "plex",
26        "proxy",
27        "rac",
28        "radius",
29        "reddit",
30        "slack",
31        "ssf",
32        "telegram",
33        "twitch",
34        "twitter",
35        "wechat",
36        "wsfed",
37    )
38} | {
39    f"{PREFIX}kerberos.png": f"{PREFIX}kerberos/%(theme)s.png",
40    f"{PREFIX}ldap.png": f"{PREFIX}ldap/%(theme)s.svg",
41    f"{PREFIX}saml.png": f"{PREFIX}saml/%(theme)s.png",
42    f"{PREFIX}scim.png": f"{PREFIX}scim/%(theme)s.svg",
43}
44
45# Fields set through the file picker, where admins could pick a built-in icon
46FILE_FIELDS = (
47    ("authentik_core", "source", "icon"),
48    ("authentik_core", "application", "meta_icon"),
49    ("authentik_brands", "brand", "branding_logo"),
50    ("authentik_brands", "brand", "branding_favicon"),
51    ("authentik_brands", "brand", "branding_default_flow_background"),
52    ("authentik_flows", "flow", "background"),
53)
54
55
56def move_source_icons(apps: Apps, schema_editor: BaseDatabaseSchemaEditor):
57    db_alias = schema_editor.connection.alias
58    for app_label, model_name, field in FILE_FIELDS:
59        model = apps.get_model(app_label, model_name)
60        for old, new in MOVED_ICONS.items():
61            model.objects.using(db_alias).filter(**{field: old}).update(**{field: new})
62
63
64class Migration(migrations.Migration):
65
66    dependencies = [
67        ("authentik_core", "0067_password_devices"),
68        ("authentik_brands", "0016_brand_branding_map_tiles"),
69        ("authentik_flows", "0031_alter_flow_layout"),
70    ]
71
72    operations = [
73        migrations.RunPython(move_source_icons, migrations.RunPython.noop),
74    ]
PREFIX = '/static/authentik/sources/'
MOVED_ICONS = {'/static/authentik/sources/apple.svg': '/static/authentik/sources/apple/%(theme)s.svg', '/static/authentik/sources/azuread.svg': '/static/authentik/sources/azuread/%(theme)s.svg', '/static/authentik/sources/discord.svg': '/static/authentik/sources/discord/%(theme)s.svg', '/static/authentik/sources/dropbox.svg': '/static/authentik/sources/dropbox/%(theme)s.svg', '/static/authentik/sources/entraid.svg': '/static/authentik/sources/entraid/%(theme)s.svg', '/static/authentik/sources/facebook.svg': '/static/authentik/sources/facebook/%(theme)s.svg', '/static/authentik/sources/github.svg': '/static/authentik/sources/github/%(theme)s.svg', '/static/authentik/sources/gitlab.svg': '/static/authentik/sources/gitlab/%(theme)s.svg', '/static/authentik/sources/google.svg': '/static/authentik/sources/google/%(theme)s.svg', '/static/authentik/sources/mailcow.svg': '/static/authentik/sources/mailcow/%(theme)s.svg', '/static/authentik/sources/okta.svg': '/static/authentik/sources/okta/%(theme)s.svg', '/static/authentik/sources/openidconnect.svg': '/static/authentik/sources/openidconnect/%(theme)s.svg', '/static/authentik/sources/patreon.svg': '/static/authentik/sources/patreon/%(theme)s.svg', '/static/authentik/sources/plex.svg': '/static/authentik/sources/plex/%(theme)s.svg', '/static/authentik/sources/proxy.svg': '/static/authentik/sources/proxy/%(theme)s.svg', '/static/authentik/sources/rac.svg': '/static/authentik/sources/rac/%(theme)s.svg', '/static/authentik/sources/radius.svg': '/static/authentik/sources/radius/%(theme)s.svg', '/static/authentik/sources/reddit.svg': '/static/authentik/sources/reddit/%(theme)s.svg', '/static/authentik/sources/slack.svg': '/static/authentik/sources/slack/%(theme)s.svg', '/static/authentik/sources/ssf.svg': '/static/authentik/sources/ssf/%(theme)s.svg', '/static/authentik/sources/telegram.svg': '/static/authentik/sources/telegram/%(theme)s.svg', '/static/authentik/sources/twitch.svg': '/static/authentik/sources/twitch/%(theme)s.svg', '/static/authentik/sources/twitter.svg': '/static/authentik/sources/twitter/%(theme)s.svg', '/static/authentik/sources/wechat.svg': '/static/authentik/sources/wechat/%(theme)s.svg', '/static/authentik/sources/wsfed.svg': '/static/authentik/sources/wsfed/%(theme)s.svg', '/static/authentik/sources/kerberos.png': '/static/authentik/sources/kerberos/%(theme)s.png', '/static/authentik/sources/ldap.png': '/static/authentik/sources/ldap/%(theme)s.svg', '/static/authentik/sources/saml.png': '/static/authentik/sources/saml/%(theme)s.png', '/static/authentik/sources/scim.png': '/static/authentik/sources/scim/%(theme)s.svg'}
FILE_FIELDS = (('authentik_core', 'source', 'icon'), ('authentik_core', 'application', 'meta_icon'), ('authentik_brands', 'brand', 'branding_logo'), ('authentik_brands', 'brand', 'branding_favicon'), ('authentik_brands', 'brand', 'branding_default_flow_background'), ('authentik_flows', 'flow', 'background'))
def move_source_icons( apps: django.apps.registry.Apps, schema_editor: django.db.backends.base.schema.BaseDatabaseSchemaEditor):
57def move_source_icons(apps: Apps, schema_editor: BaseDatabaseSchemaEditor):
58    db_alias = schema_editor.connection.alias
59    for app_label, model_name, field in FILE_FIELDS:
60        model = apps.get_model(app_label, model_name)
61        for old, new in MOVED_ICONS.items():
62            model.objects.using(db_alias).filter(**{field: old}).update(**{field: new})
class Migration(django.db.migrations.migration.Migration):
65class Migration(migrations.Migration):
66
67    dependencies = [
68        ("authentik_core", "0067_password_devices"),
69        ("authentik_brands", "0016_brand_branding_map_tiles"),
70        ("authentik_flows", "0031_alter_flow_layout"),
71    ]
72
73    operations = [
74        migrations.RunPython(move_source_icons, migrations.RunPython.noop),
75    ]

The base class for all migrations.

Migration files will import this from django.db.migrations.Migration and subclass it as a class called Migration. It will have one or more of the following attributes:

  • operations: A list of Operation instances, probably from django.db.migrations.operations
  • dependencies: A list of tuples of (app_path, migration_name)
  • run_before: A list of tuples of (app_path, migration_name)
  • replaces: A list of migration_names

Note that all migrations come out of migrations and into the Loader or Graph as instances, having been initialized with their app label and name.

dependencies = [('authentik_core', '0067_password_devices'), ('authentik_brands', '0016_brand_branding_map_tiles'), ('authentik_flows', '0031_alter_flow_layout')]
operations = [<RunPython <function move_source_icons>, <function RunPython.noop>>]