Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Alan Crosswell
Aleksander Vaskevich
Alessandro De Angelis
Allisson Azevedo
Andrew Chen Wang
Anvesh Agarwal
Aristóbulo Meneses
Aryan Iyappan
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [unreleased]
* Remove support for Django 3.0
* Add support for Django 3.2
* #989 Change any HttpResponse to JsonResponse if possible

### Added
* #712, #636, #808. Calls to `django.contrib.auth.authenticate()` now pass a `request`
Expand Down
20 changes: 10 additions & 10 deletions oauth2_provider/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,56 +563,56 @@ class Meta(AbstractIDToken.Meta):


def get_application_model():
""" Return the Application model that is active in this project. """
"""Return the Application model that is active in this project."""
return apps.get_model(oauth2_settings.APPLICATION_MODEL)


def get_grant_model():
""" Return the Grant model that is active in this project. """
"""Return the Grant model that is active in this project."""
return apps.get_model(oauth2_settings.GRANT_MODEL)


def get_access_token_model():
""" Return the AccessToken model that is active in this project. """
"""Return the AccessToken model that is active in this project."""
return apps.get_model(oauth2_settings.ACCESS_TOKEN_MODEL)


def get_id_token_model():
""" Return the AccessToken model that is active in this project. """
"""Return the AccessToken model that is active in this project."""
return apps.get_model(oauth2_settings.ID_TOKEN_MODEL)


def get_refresh_token_model():
""" Return the RefreshToken model that is active in this project. """
"""Return the RefreshToken model that is active in this project."""
return apps.get_model(oauth2_settings.REFRESH_TOKEN_MODEL)


def get_application_admin_class():
""" Return the Application admin class that is active in this project. """
"""Return the Application admin class that is active in this project."""
application_admin_class = oauth2_settings.APPLICATION_ADMIN_CLASS
return application_admin_class


def get_access_token_admin_class():
""" Return the AccessToken admin class that is active in this project. """
"""Return the AccessToken admin class that is active in this project."""
access_token_admin_class = oauth2_settings.ACCESS_TOKEN_ADMIN_CLASS
return access_token_admin_class


def get_grant_admin_class():
""" Return the Grant admin class that is active in this project. """
"""Return the Grant admin class that is active in this project."""
grant_admin_class = oauth2_settings.GRANT_ADMIN_CLASS
return grant_admin_class


def get_id_token_admin_class():
""" Return the IDToken admin class that is active in this project. """
"""Return the IDToken admin class that is active in this project."""
id_token_admin_class = oauth2_settings.ID_TOKEN_ADMIN_CLASS
return id_token_admin_class


def get_refresh_token_admin_class():
""" Return the RefreshToken admin class that is active in this project. """
"""Return the RefreshToken admin class that is active in this project."""
refresh_token_admin_class = oauth2_settings.REFRESH_TOKEN_ADMIN_CLASS
return refresh_token_admin_class

Expand Down
19 changes: 4 additions & 15 deletions oauth2_provider/views/introspect.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import calendar
import json

from django.core.exceptions import ObjectDoesNotExist
from django.http import HttpResponse
from django.http import JsonResponse
from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt

Expand All @@ -29,9 +28,7 @@ def get_token_response(token_value=None):
get_access_token_model().objects.select_related("user", "application").get(token=token_value)
)
except ObjectDoesNotExist:
return HttpResponse(
content=json.dumps({"active": False}), status=401, content_type="application/json"
)
return JsonResponse({"active": False}, status=401)
else:
if token.is_valid():
data = {
Expand All @@ -43,17 +40,9 @@ def get_token_response(token_value=None):
data["client_id"] = token.application.client_id
if token.user:
data["username"] = token.user.get_username()
return HttpResponse(content=json.dumps(data), status=200, content_type="application/json")
return JsonResponse(data)
else:
return HttpResponse(
content=json.dumps(
{
"active": False,
}
),
status=200,
content_type="application/json",
)
return JsonResponse({"active": False})

def get(self, request, *args, **kwargs):
"""
Expand Down