authentik.providers.saml.migrations.0009_auto_20201112_2016
1# Generated by Django 3.1.3 on 2020-11-12 20:16 2 3from django.apps.registry import Apps 4from django.db import migrations, models 5from django.db.backends.base.schema import BaseDatabaseSchemaEditor 6 7from authentik.common.saml import constants 8 9 10def update_algorithms(apps: Apps, schema_editor: BaseDatabaseSchemaEditor): 11 SAMLProvider = apps.get_model("authentik_providers_saml", "SAMLProvider") 12 signature_translation_map = { 13 "rsa-sha1": constants.RSA_SHA1, 14 "rsa-sha256": constants.RSA_SHA256, 15 "ecdsa-sha256": constants.RSA_SHA256, 16 "dsa-sha1": constants.DSA_SHA1, 17 } 18 digest_translation_map = { 19 "sha1": constants.SHA1, 20 "sha256": constants.SHA256, 21 } 22 23 for source in SAMLProvider.objects.all(): 24 source.signature_algorithm = signature_translation_map.get( 25 source.signature_algorithm, constants.RSA_SHA256 26 ) 27 source.digest_algorithm = digest_translation_map.get( 28 source.digest_algorithm, constants.SHA256 29 ) 30 source.save() 31 32 33class Migration(migrations.Migration): 34 dependencies = [ 35 ("authentik_providers_saml", "0008_auto_20201112_1036"), 36 ] 37 38 operations = [ 39 migrations.AlterField( 40 model_name="samlprovider", 41 name="digest_algorithm", 42 field=models.CharField( 43 choices=[ 44 (constants.SHA1, "SHA1"), 45 (constants.SHA256, "SHA256"), 46 (constants.SHA384, "SHA384"), 47 (constants.SHA512, "SHA512"), 48 ], 49 default=constants.SHA256, 50 max_length=50, 51 ), 52 ), 53 migrations.AlterField( 54 model_name="samlprovider", 55 name="signature_algorithm", 56 field=models.CharField( 57 choices=[ 58 (constants.RSA_SHA1, "RSA-SHA1"), 59 (constants.RSA_SHA256, "RSA-SHA256"), 60 (constants.RSA_SHA384, "RSA-SHA384"), 61 (constants.RSA_SHA512, "RSA-SHA512"), 62 (constants.DSA_SHA1, "DSA-SHA1"), 63 ], 64 default=constants.RSA_SHA256, 65 max_length=50, 66 ), 67 ), 68 ]
def
update_algorithms( apps: django.apps.registry.Apps, schema_editor: django.db.backends.base.schema.BaseDatabaseSchemaEditor):
11def update_algorithms(apps: Apps, schema_editor: BaseDatabaseSchemaEditor): 12 SAMLProvider = apps.get_model("authentik_providers_saml", "SAMLProvider") 13 signature_translation_map = { 14 "rsa-sha1": constants.RSA_SHA1, 15 "rsa-sha256": constants.RSA_SHA256, 16 "ecdsa-sha256": constants.RSA_SHA256, 17 "dsa-sha1": constants.DSA_SHA1, 18 } 19 digest_translation_map = { 20 "sha1": constants.SHA1, 21 "sha256": constants.SHA256, 22 } 23 24 for source in SAMLProvider.objects.all(): 25 source.signature_algorithm = signature_translation_map.get( 26 source.signature_algorithm, constants.RSA_SHA256 27 ) 28 source.digest_algorithm = digest_translation_map.get( 29 source.digest_algorithm, constants.SHA256 30 ) 31 source.save()
class
Migration(django.db.migrations.migration.Migration):
34class Migration(migrations.Migration): 35 dependencies = [ 36 ("authentik_providers_saml", "0008_auto_20201112_1036"), 37 ] 38 39 operations = [ 40 migrations.AlterField( 41 model_name="samlprovider", 42 name="digest_algorithm", 43 field=models.CharField( 44 choices=[ 45 (constants.SHA1, "SHA1"), 46 (constants.SHA256, "SHA256"), 47 (constants.SHA384, "SHA384"), 48 (constants.SHA512, "SHA512"), 49 ], 50 default=constants.SHA256, 51 max_length=50, 52 ), 53 ), 54 migrations.AlterField( 55 model_name="samlprovider", 56 name="signature_algorithm", 57 field=models.CharField( 58 choices=[ 59 (constants.RSA_SHA1, "RSA-SHA1"), 60 (constants.RSA_SHA256, "RSA-SHA256"), 61 (constants.RSA_SHA384, "RSA-SHA384"), 62 (constants.RSA_SHA512, "RSA-SHA512"), 63 (constants.DSA_SHA1, "DSA-SHA1"), 64 ], 65 default=constants.RSA_SHA256, 66 max_length=50, 67 ), 68 ), 69 ]
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.