# Generated by Django 5.2.8 on 2025-11-20 20:14

import authentik.core.models
import authentik.lib.generators
import authentik.lib.utils.time
import django.db.models.deletion
import uuid
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ("authentik_crypto", "0004_alter_certificatekeypair_name"),
        ("authentik_endpoints", "0001_initial"),
        ("authentik_flows", "0028_flowtoken_revoke_on_execution"),
    ]

    operations = [
        migrations.CreateModel(
            name="AgentDeviceConnection",
            fields=[
                (
                    "deviceconnection_ptr",
                    models.OneToOneField(
                        auto_created=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        parent_link=True,
                        primary_key=True,
                        serialize=False,
                        to="authentik_endpoints.deviceconnection",
                    ),
                ),
                ("apple_signing_key", models.TextField()),
                ("apple_encryption_key", models.TextField()),
                ("apple_key_exchange_key", models.TextField()),
                ("apple_sign_key_id", models.TextField()),
                ("apple_enc_key_id", models.TextField()),
            ],
            options={
                "abstract": False,
            },
            bases=("authentik_endpoints.deviceconnection",),
        ),
        migrations.CreateModel(
            name="AgentDeviceUserBinding",
            fields=[
                (
                    "deviceuserbinding_ptr",
                    models.OneToOneField(
                        auto_created=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        parent_link=True,
                        primary_key=True,
                        serialize=False,
                        to="authentik_endpoints.deviceuserbinding",
                    ),
                ),
                ("apple_secure_enclave_key", models.TextField()),
                ("apple_enclave_key_id", models.TextField()),
            ],
            options={
                "abstract": False,
            },
            bases=("authentik_endpoints.deviceuserbinding",),
        ),
        migrations.CreateModel(
            name="AgentConnector",
            fields=[
                (
                    "connector_ptr",
                    models.OneToOneField(
                        auto_created=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        parent_link=True,
                        primary_key=True,
                        serialize=False,
                        to="authentik_endpoints.connector",
                    ),
                ),
                ("nss_uid_offset", models.PositiveIntegerField(default=1000)),
                ("nss_gid_offset", models.PositiveIntegerField(default=1000)),
                ("auth_terminate_session_on_expiry", models.BooleanField(default=False)),
                (
                    "refresh_interval",
                    models.TextField(
                        default="minutes=30",
                        validators=[authentik.lib.utils.time.timedelta_string_validator],
                    ),
                ),
                (
                    "authentication_flow",
                    models.ForeignKey(
                        default=None,
                        null=True,
                        on_delete=django.db.models.deletion.SET_DEFAULT,
                        to="authentik_flows.flow",
                    ),
                ),
                (
                    "challenge_key",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="authentik_crypto.certificatekeypair",
                    ),
                ),
            ],
            options={
                "verbose_name": "Agent Connector",
                "verbose_name_plural": "Agent Connectors",
            },
            bases=("authentik_endpoints.connector",),
        ),
        migrations.CreateModel(
            name="DeviceToken",
            fields=[
                ("expires", models.DateTimeField(default=None, null=True)),
                ("expiring", models.BooleanField(default=True)),
                (
                    "token_uuid",
                    models.UUIDField(default=uuid.uuid4, primary_key=True, serialize=False),
                ),
                ("key", models.TextField(default=authentik.lib.generators.generate_key)),
                (
                    "device",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="authentik_endpoints_connectors_agent.agentdeviceconnection",
                    ),
                ),
            ],
            options={
                "abstract": False,
                "indexes": [
                    models.Index(fields=["expires"], name="authentik_e_expires_675725_idx"),
                    models.Index(fields=["expiring"], name="authentik_e_expirin_8eb6d1_idx"),
                    models.Index(
                        fields=["expiring", "expires"], name="authentik_e_expirin_bd42e6_idx"
                    ),
                ],
            },
        ),
        migrations.CreateModel(
            name="EnrollmentToken",
            fields=[
                ("expires", models.DateTimeField(default=None, null=True)),
                ("expiring", models.BooleanField(default=True)),
                (
                    "token_uuid",
                    models.UUIDField(
                        default=uuid.uuid4, editable=False, primary_key=True, serialize=False
                    ),
                ),
                ("name", models.TextField()),
                ("key", models.TextField(default=authentik.core.models.default_token_key)),
                (
                    "connector",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="authentik_endpoints_connectors_agent.agentconnector",
                    ),
                ),
                (
                    "device_group",
                    models.ForeignKey(
                        default=None,
                        null=True,
                        on_delete=django.db.models.deletion.SET_DEFAULT,
                        to="authentik_endpoints.devicegroup",
                    ),
                ),
            ],
            options={
                "verbose_name": "Enrollment Token",
                "verbose_name_plural": "Enrollment Tokens",
                "permissions": [("view_enrollment_token_key", "View token's key")],
                "indexes": [
                    models.Index(fields=["expires"], name="authentik_e_expires_98b99c_idx"),
                    models.Index(fields=["expiring"], name="authentik_e_expirin_9a17f7_idx"),
                    models.Index(
                        fields=["expiring", "expires"], name="authentik_e_expirin_7ad82a_idx"
                    ),
                    models.Index(fields=["key"], name="authentik_e_key_8dafaf_idx"),
                ],
            },
        ),
    ]
