Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Bump django-oauth-toolkit from 1.7.1 to 2.1.0 in /api (#781)

dependabot[bot]c120264b8664
diff --git a/api/Pipfile b/api/Pipfile
index f06384da1..e5c1ad4bc 100644
--- a/api/Pipfile
+++ b/api/Pipfile
@@ -24,7 +24,7 @@ deepdiff = "*"
Django = "==4.0.6"
django-braces = "*"
django-cors-headers = "*"
-django-oauth-toolkit = "==1.7.1"
+django-oauth-toolkit = "==2.1.0"
django-redis = "*"
django-sslserver = "*"
django-storages = "*"
diff --git a/api/Pipfile.lock b/api/Pipfile.lock
index 092bb0dd0..4d9f0a12f 100644
--- a/api/Pipfile.lock
+++ b/api/Pipfile.lock
@@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
- "sha256": "81d10a489b094a0af9a04fb279369606602d05562546088c69be4e4117aae712"
+ "sha256": "2832f6faa6ba508df60afe298a8c82423b73d1a35cbd529035a90f7032757b34"
},
"pipfile-spec": 6,
"requires": {
@@ -249,11 +249,10 @@
},
"django-oauth-toolkit": {
"hashes": [
- "sha256:37b690fa53f340c7391bdbc0fdbb32fd9ef8a7c012e72ee8754c331a2d7b4adb",
- "sha256:756e44421d0993f27705736b6c33a3d89018393859a31ac926296950f76e4433"
+ "sha256:642598d7462e92232a237faa399f9a2361aae1177e15f710b93559d111e12aef"
],
"index": "pypi",
- "version": "==1.7.1"
+ "version": "==2.1.0"
},
"django-redis": {
"hashes": [
diff --git a/api/catalog/api/migrations/0048_alter_throttledapplication_client_secret.py b/api/catalog/api/migrations/0048_alter_throttledapplication_client_secret.py
new file mode 100644
index 000000000..0ea5189e3
--- /dev/null
+++ b/api/catalog/api/migrations/0048_alter_throttledapplication_client_secret.py
@@ -0,0 +1,20 @@
+# Generated by Django 4.0.6 on 2022-07-15 11:48
+
+from django.db import migrations
+import oauth2_provider.generators
+import oauth2_provider.models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('api', '0047_help_text'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='throttledapplication',
+ name='client_secret',
+ field=oauth2_provider.models.ClientSecretField(blank=True, db_index=True, default=oauth2_provider.generators.generate_client_secret, help_text='Hashed on Save. Copy it now if this is a new secret.', max_length=255),
+ ),
+ ]
diff --git a/api/catalog/api/views/oauth2_views.py b/api/catalog/api/views/oauth2_views.py
index 01e8b2c34..45990451c 100644
--- a/api/catalog/api/views/oauth2_views.py
+++ b/api/catalog/api/views/oauth2_views.py
@@ -11,6 +11,7 @@ from rest_framework.views import APIView
from drf_yasg import openapi
from drf_yasg.utils import swagger_auto_schema
+from oauth2_provider.generators import generate_client_secret
from catalog.api.docs.media_docs import refer_sample
from catalog.api.models import OAuth2Verification, ThrottledApplication
@@ -127,12 +128,14 @@ curl \\
# Produce a client ID, client secret, and authorize the application in
# the OAuth2 backend.
+ client_secret = generate_client_secret()
new_application = ThrottledApplication(
name=serialized.validated_data["name"],
skip_authorization=False,
client_type="Confidential",
authorization_grant_type="client-credentials",
verified=False,
+ client_secret=client_secret,
)
new_application.save()
# Send a verification email.
@@ -167,7 +170,7 @@ If you believe you received this message in error, please disregard it.
status=201,
data={
"client_id": new_application.client_id,
- "client_secret": new_application.client_secret,
+ "client_secret": client_secret,
"name": new_application.name,
"msg": "Check your email for a verification link.",
},