diff --git a/apps/gooyal_oauth2/migrations/0002_alter_accesstoken_client_owner.py b/apps/gooyal_oauth2/migrations/0002_alter_accesstoken_client_owner.py deleted file mode 100644 index 41c0f9d..0000000 --- a/apps/gooyal_oauth2/migrations/0002_alter_accesstoken_client_owner.py +++ /dev/null @@ -1,21 +0,0 @@ -# Generated by Django 5.0.6 on 2024-07-04 11:38 - -import django.db.models.deletion -from django.conf import settings -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('gooyal_oauth2', '0001_initial'), - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ] - - operations = [ - migrations.AlterField( - model_name='accesstoken', - name='client_owner', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL), - ), - ] diff --git a/apps/gooyal_oauth2/models.py b/apps/gooyal_oauth2/models.py index 34ad8f7..0ffd2bb 100644 --- a/apps/gooyal_oauth2/models.py +++ b/apps/gooyal_oauth2/models.py @@ -2,9 +2,11 @@ from django.db import models from oauth2_provider.models import AbstractApplication, AbstractAccessToken, AbstractGrant, AbstractRefreshToken, \ AbstractIDToken - +import uuid class AccessToken(AbstractAccessToken): + id = None + uuid = models.UUIDField(primary_key=True, editable=False, default=uuid.uuid4, unique=True, db_index=True) detail = models.JSONField(null=True, blank=True) client_id = models.CharField(max_length=255, null=True, blank=True) client_owner = models.ForeignKey('users.User', on_delete=models.PROTECT, null=True, blank=True) @@ -14,21 +16,33 @@ class AccessToken(AbstractAccessToken): class Application(AbstractApplication): + id = None + uuid = models.UUIDField(primary_key=True, editable=False, default=uuid.uuid4, unique=True, db_index=True) + class Meta: abstract = False class Grant(AbstractGrant): + id = None + uuid = models.UUIDField(primary_key=True, editable=False, default=uuid.uuid4, unique=True, db_index=True) + class Meta: abstract = False class RefreshToken(AbstractRefreshToken): + id = None + uuid = models.UUIDField(primary_key=True, editable=False, default=uuid.uuid4, unique=True, db_index=True) + class Meta: abstract = False class IDToken(AbstractIDToken): + id = None + uuid = models.UUIDField(primary_key=True, editable=False, default=uuid.uuid4, unique=True, db_index=True) + class Meta: abstract = False