authentik.sources.saml.migrations.0017_fix_x509subjectname
1# Generated by Django 5.0.9 on 2024-10-10 15:45 2 3from django.db import migrations, models 4from django.apps.registry import Apps 5 6from django.db.backends.base.schema import BaseDatabaseSchemaEditor 7 8 9def fix_X509SubjectName(apps: Apps, schema_editor: BaseDatabaseSchemaEditor): 10 db_alias = schema_editor.connection.alias 11 12 SAMLSource = apps.get_model("authentik_sources_saml", "SAMLSource") 13 SAMLSource.objects.using(db_alias).filter( 14 name_id_policy="urn:oasis:names:tc:SAML:2.0:nameid-format:X509SubjectName" 15 ).update(name_id_policy="urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName") 16 17 18class Migration(migrations.Migration): 19 20 dependencies = [ 21 ("authentik_sources_saml", "0016_samlsource_encryption_kp"), 22 ] 23 24 operations = [ 25 migrations.RunPython(fix_X509SubjectName), 26 migrations.AlterField( 27 model_name="samlsource", 28 name="name_id_policy", 29 field=models.TextField( 30 choices=[ 31 ("urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress", "Email"), 32 ("urn:oasis:names:tc:SAML:2.0:nameid-format:persistent", "Persistent"), 33 ("urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName", "X509"), 34 ( 35 "urn:oasis:names:tc:SAML:2.0:nameid-format:WindowsDomainQualifiedName", 36 "Windows", 37 ), 38 ("urn:oasis:names:tc:SAML:2.0:nameid-format:transient", "Transient"), 39 ], 40 default="urn:oasis:names:tc:SAML:2.0:nameid-format:persistent", 41 help_text="NameID Policy sent to the IdP. Can be unset, in which case no Policy is sent.", 42 ), 43 ), 44 ]
def
fix_X509SubjectName( apps: django.apps.registry.Apps, schema_editor: django.db.backends.base.schema.BaseDatabaseSchemaEditor):
10def fix_X509SubjectName(apps: Apps, schema_editor: BaseDatabaseSchemaEditor): 11 db_alias = schema_editor.connection.alias 12 13 SAMLSource = apps.get_model("authentik_sources_saml", "SAMLSource") 14 SAMLSource.objects.using(db_alias).filter( 15 name_id_policy="urn:oasis:names:tc:SAML:2.0:nameid-format:X509SubjectName" 16 ).update(name_id_policy="urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName")
class
Migration(django.db.migrations.migration.Migration):
19class Migration(migrations.Migration): 20 21 dependencies = [ 22 ("authentik_sources_saml", "0016_samlsource_encryption_kp"), 23 ] 24 25 operations = [ 26 migrations.RunPython(fix_X509SubjectName), 27 migrations.AlterField( 28 model_name="samlsource", 29 name="name_id_policy", 30 field=models.TextField( 31 choices=[ 32 ("urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress", "Email"), 33 ("urn:oasis:names:tc:SAML:2.0:nameid-format:persistent", "Persistent"), 34 ("urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName", "X509"), 35 ( 36 "urn:oasis:names:tc:SAML:2.0:nameid-format:WindowsDomainQualifiedName", 37 "Windows", 38 ), 39 ("urn:oasis:names:tc:SAML:2.0:nameid-format:transient", "Transient"), 40 ], 41 default="urn:oasis:names:tc:SAML:2.0:nameid-format:persistent", 42 help_text="NameID Policy sent to the IdP. Can be unset, in which case no Policy is sent.", 43 ), 44 ), 45 ]
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.