Skip to content

django-mfa2 User_Keys uses project DEFAULT_AUTO_FIELD instead of its integer migration PK #112

Description

@BVengo

mfa.models.User_Keys does not declare its primary key and the mfa app config does not set default_auto_field.

This means the host project's DEFAULT_AUTO_FIELD is used at runtime, despite django-mfa2s migrations
relying upon AutoField. This causes a runtime/schema mismatch in projects that use a non-integer default key (e.g. UUIDs).

To fix, just specify the default_auto_field in apps.py:

from django.apps import AppConfig


class myAppNameConfig(AppConfig):
    name = "mfa"
    verbose_name = "A Much Better Name"
    default_auto_field = "django.db.models.AutoField"

I'll open up a PR for this. We're trying to implement django-mfa2 in a project at work, and we had to specify a custom app config to workaround it in the interim.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions