Prepare for django-oauth-toolkit 1.3.2 upgrade (#23637)

Prepare to upgrade to django-oauth-toolkit (module name oauth2_provider) 1.3.2 concurrently with the Django 2.2 upgrade (versions after 1.1.3 dropped support for Django 1.11). Key points:

* We can stop using a commit hash since versions 1.3.0 through 1.3.2 have been released since that commit.
* The validator in oauth_dispatch migration 0002 has been removed from DOT, but the whole table was removed in migration 0004 anyway. Newer DOT versions moved where redirect URI validation happens so it's no longer needed here.
* DOT 1.3.0 squashed its original 6 migrations and immediately deleted them. This required some changes in oauth_dispatch migrations 0006 and 0007 to deal with either numbering system.

When deploying to stage and production, we'll need to delete the history for oauth2_provider migrations 0002-0006 first (the new squashed 0001 migration has the same name as the original 0001). The deployment with DOT 1.3.2 will add a new 0002 migration which should then apply cleanly on the existing database state.

Should resolve https://openedx.atlassian.net/browse/BOM-1456 .
This commit is contained in:
Jeremy Bowman
2020-04-06 19:10:19 -04:00
committed by GitHub
parent c4352a0a78
commit 3309078242
6 changed files with 25 additions and 15 deletions

View File

@@ -5,7 +5,6 @@
import django.db.models.deletion
import django_mysql.models
import oauth2_provider.generators
import oauth2_provider.validators
from django.conf import settings
from django.db import migrations, models
@@ -23,7 +22,7 @@ class Migration(migrations.Migration):
name='ScopedApplication',
fields=[
('client_id', models.CharField(db_index=True, default=oauth2_provider.generators.generate_client_id, max_length=100, unique=True)),
('redirect_uris', models.TextField(blank=True, help_text='Allowed URIs list, space separated', validators=[oauth2_provider.validators.validate_uris])),
('redirect_uris', models.TextField(blank=True, help_text='Allowed URIs list, space separated')),
('client_type', models.CharField(choices=[('confidential', 'Confidential'), ('public', 'Public')], max_length=32)),
('authorization_grant_type', models.CharField(choices=[('authorization-code', 'Authorization code'), ('implicit', 'Implicit'), ('password', 'Resource owner password-based'), ('client-credentials', 'Client credentials')], max_length=32)),
('client_secret', models.CharField(blank=True, db_index=True, default=oauth2_provider.generators.generate_client_secret, max_length=255)),

View File

@@ -2,20 +2,27 @@
# Generated by Django 1.11.14 on 2018-07-23 14:58
import django
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
DEPENDENCIES = [
('oauth_dispatch', '0005_applicationaccess_type'),
]
RUN_BEFORE = []
if django.VERSION >= (2, 0):
# Using django-oauth-toolkit 1.3.2+, which squashed and deleted the original 6 migrations
DEPENDENCIES.append(('oauth2_provider', '0001_initial'))
else:
# Using django-oauth-toolkit 1.1.3 or earlier, before the migrations squashing
RUN_BEFORE.append(('oauth2_provider', '0005_auto_20170514_1141'))
class Migration(migrations.Migration):
dependencies = [
('oauth_dispatch', '0005_applicationaccess_type'),
]
run_before = [
('oauth2_provider', '0005_auto_20170514_1141'),
]
dependencies = DEPENDENCIES
run_before = RUN_BEFORE
operations = [
migrations.AlterField(

View File

@@ -2,16 +2,22 @@
# Generated by Django 1.11.14 on 2018-07-23 15:12
import django
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
if django.VERSION >= (2, 0):
dot_migration = '0001_initial'
else:
dot_migration = '0006_auto_20171214_2232'
class Migration(migrations.Migration):
dependencies = [
('oauth_dispatch', '0006_drop_application_id_constraints'),
('oauth2_provider', '0006_auto_20171214_2232'),
('oauth2_provider', dot_migration),
]
operations = [

View File

@@ -1,3 +1,2 @@
Django>=2.0,<2.1
git+https://github.com/jazzband/django-oauth-toolkit.git@bf1525e85a06929016b1fe35d863e62e58124a2f#egg=oauth2_provider
django-oauth-toolkit==1.3.2

View File

@@ -1,3 +1,3 @@
Django>=2.1,<2.2
git+https://github.com/jazzband/django-oauth-toolkit.git@bf1525e85a06929016b1fe35d863e62e58124a2f#egg=oauth2_provider
django-oauth-toolkit==1.3.2

View File

@@ -1,3 +1,2 @@
Django>=2.2,<3.0
git+https://github.com/jazzband/django-oauth-toolkit.git@bf1525e85a06929016b1fe35d863e62e58124a2f#egg=oauth2_provider
django-oauth-toolkit==1.3.2