Skip to content

Commit

Permalink
Update middleware.py (jazzband#1380)
Browse files Browse the repository at this point in the history
* Update middleware.py

Use `get_access_token_model` instead of `AccessToken`

* Update CHANGELOG.md

* Update AUTHORS
  • Loading branch information
lazToum authored May 6, 2024
1 parent 2b56a48 commit ea51411
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ Julien Palard
Jun Zhou
Kaleb Porter
Kristian Rune Larsen
Lazaros Toumanidis
Ludwig Hähne
Łukasz Skarżyński
Marcus Sonestedt
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* #1336 Fix encapsulation for Redirect URI scheme validation
* #1357 Move import of setting_changed signal from test to django core modules
* #1268 fix prompt=none redirects to login screen
* #1381 fix AttributeError in OAuth2ExtraTokenMiddleware when a custom AccessToken model is used

### Removed
* #1350 Remove support for Python 3.7 and Django 2.2
Expand Down
3 changes: 2 additions & 1 deletion oauth2_provider/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.contrib.auth import authenticate
from django.utils.cache import patch_vary_headers

from oauth2_provider.models import AccessToken
from oauth2_provider.models import get_access_token_model


log = logging.getLogger(__name__)
Expand Down Expand Up @@ -53,6 +53,7 @@ def __call__(self, request):
authheader = request.META.get("HTTP_AUTHORIZATION", "")
if authheader.startswith("Bearer"):
tokenstring = authheader.split()[1]
AccessToken = get_access_token_model()
try:
token = AccessToken.objects.get(token=tokenstring)
request.access_token = token
Expand Down

0 comments on commit ea51411

Please sign in to comment.