authentik.stages.authenticator_webauthn.migrations.0001_initial

 1# Generated by Django 3.1.6 on 2021-02-17 10:48
 2
 3import django.db.models.deletion
 4import django.utils.timezone
 5from django.conf import settings
 6from django.db import migrations, models
 7
 8
 9class Migration(migrations.Migration):
10    initial = True
11
12    dependencies = [
13        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
14        ("authentik_flows", "0016_auto_20201202_1307"),
15    ]
16
17    operations = [
18        migrations.CreateModel(
19            name="WebAuthnDevice",
20            fields=[
21                (
22                    "id",
23                    models.AutoField(
24                        auto_created=True,
25                        primary_key=True,
26                        serialize=False,
27                        verbose_name="ID",
28                    ),
29                ),
30                ("name", models.TextField(max_length=200)),
31                ("credential_id", models.CharField(max_length=300, unique=True)),
32                ("public_key", models.TextField()),
33                ("sign_count", models.IntegerField(default=0)),
34                ("rp_id", models.CharField(max_length=253)),
35                ("created_on", models.DateTimeField(auto_now_add=True)),
36                (
37                    "last_used_on",
38                    models.DateTimeField(default=django.utils.timezone.now),
39                ),
40                (
41                    "user",
42                    models.ForeignKey(
43                        on_delete=django.db.models.deletion.CASCADE,
44                        to=settings.AUTH_USER_MODEL,
45                    ),
46                ),
47            ],
48        ),
49        migrations.CreateModel(
50            name="AuthenticateWebAuthnStage",
51            fields=[
52                (
53                    "stage_ptr",
54                    models.OneToOneField(
55                        auto_created=True,
56                        on_delete=django.db.models.deletion.CASCADE,
57                        parent_link=True,
58                        primary_key=True,
59                        serialize=False,
60                        to="authentik_flows.stage",
61                    ),
62                ),
63                (
64                    "configure_flow",
65                    models.ForeignKey(
66                        blank=True,
67                        help_text=(
68                            "Flow used by an authenticated user to configure this Stage. If empty,"
69                            " user will not be able to configure this stage."
70                        ),
71                        null=True,
72                        on_delete=django.db.models.deletion.SET_NULL,
73                        to="authentik_flows.flow",
74                    ),
75                ),
76            ],
77            options={
78                "verbose_name": "WebAuthn Authenticator Setup Stage",
79                "verbose_name_plural": "WebAuthn Authenticator Setup Stages",
80            },
81            bases=("authentik_flows.stage", models.Model),
82        ),
83    ]
class Migration(django.db.migrations.migration.Migration):
10class Migration(migrations.Migration):
11    initial = True
12
13    dependencies = [
14        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
15        ("authentik_flows", "0016_auto_20201202_1307"),
16    ]
17
18    operations = [
19        migrations.CreateModel(
20            name="WebAuthnDevice",
21            fields=[
22                (
23                    "id",
24                    models.AutoField(
25                        auto_created=True,
26                        primary_key=True,
27                        serialize=False,
28                        verbose_name="ID",
29                    ),
30                ),
31                ("name", models.TextField(max_length=200)),
32                ("credential_id", models.CharField(max_length=300, unique=True)),
33                ("public_key", models.TextField()),
34                ("sign_count", models.IntegerField(default=0)),
35                ("rp_id", models.CharField(max_length=253)),
36                ("created_on", models.DateTimeField(auto_now_add=True)),
37                (
38                    "last_used_on",
39                    models.DateTimeField(default=django.utils.timezone.now),
40                ),
41                (
42                    "user",
43                    models.ForeignKey(
44                        on_delete=django.db.models.deletion.CASCADE,
45                        to=settings.AUTH_USER_MODEL,
46                    ),
47                ),
48            ],
49        ),
50        migrations.CreateModel(
51            name="AuthenticateWebAuthnStage",
52            fields=[
53                (
54                    "stage_ptr",
55                    models.OneToOneField(
56                        auto_created=True,
57                        on_delete=django.db.models.deletion.CASCADE,
58                        parent_link=True,
59                        primary_key=True,
60                        serialize=False,
61                        to="authentik_flows.stage",
62                    ),
63                ),
64                (
65                    "configure_flow",
66                    models.ForeignKey(
67                        blank=True,
68                        help_text=(
69                            "Flow used by an authenticated user to configure this Stage. If empty,"
70                            " user will not be able to configure this stage."
71                        ),
72                        null=True,
73                        on_delete=django.db.models.deletion.SET_NULL,
74                        to="authentik_flows.flow",
75                    ),
76                ),
77            ],
78            options={
79                "verbose_name": "WebAuthn Authenticator Setup Stage",
80                "verbose_name_plural": "WebAuthn Authenticator Setup Stages",
81            },
82            bases=("authentik_flows.stage", models.Model),
83        ),
84    ]

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.

initial = True
dependencies = [('authentik_core', '__first__'), ('authentik_flows', '0016_auto_20201202_1307')]
operations = [<CreateModel name='WebAuthnDevice', fields=[('id', <django.db.models.fields.AutoField>), ('name', <django.db.models.fields.TextField>), ('credential_id', <django.db.models.fields.CharField>), ('public_key', <django.db.models.fields.TextField>), ('sign_count', <django.db.models.fields.IntegerField>), ('rp_id', <django.db.models.fields.CharField>), ('created_on', <django.db.models.fields.DateTimeField>), ('last_used_on', <django.db.models.fields.DateTimeField>), ('user', <django.db.models.fields.related.ForeignKey>)]>, <CreateModel name='AuthenticateWebAuthnStage', fields=[('stage_ptr', <django.db.models.fields.related.OneToOneField>), ('configure_flow', <django.db.models.fields.related.ForeignKey>)], options={'verbose_name': 'WebAuthn Authenticator Setup Stage', 'verbose_name_plural': 'WebAuthn Authenticator Setup Stages'}, bases=('authentik_flows.stage', <class 'django.db.models.base.Model'>)>]