Skip to content

Commit

Permalink
Merge pull request #7 from GeoNode/ISSUE_6
Browse files Browse the repository at this point in the history
[Fixes #6] Fix uniqueness of UUID
  • Loading branch information
Alessio Fabiani authored May 28, 2021
2 parents df5deaf + 0ad2897 commit 4e6485b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion oauth2_provider/migrations/0014_auto_20210510_0935.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='idtoken',
name='jti',
field=models.UUIDField(default=uuid.uuid4, editable=False, unique=True, verbose_name='JWT Token ID'),
field=models.UUIDField(default=uuid.uuid4, editable=False, unique=False, verbose_name='JWT Token ID'),
),
migrations.AlterField(
model_name='application',
Expand Down
18 changes: 18 additions & 0 deletions oauth2_provider/migrations/0015_fix_uuid_20210527_1930.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from django.db import migrations
import uuid

def gen_uuid(apps, schema_editor):
MyModel = apps.get_model('oauth2_provider', 'idtoken')
for row in MyModel.objects.all():
row.jti = uuid.uuid4()
row.save(update_fields=['jti'])

class Migration(migrations.Migration):

dependencies = [
('oauth2_provider', '0014_auto_20210510_0935'),
]

operations = [
migrations.RunPython(gen_uuid, reverse_code=migrations.RunPython.noop),
]

0 comments on commit 4e6485b

Please sign in to comment.