Skip to content

Commit 019cfcd

Browse files
committed
Adhere content-type request header to CGI standard
Django represents headers according to the common gateway interface(CGI) standard. This means it's in all caps with words divided with a hyphen However a lot of libraries follow the pattern of Something-Something so this ensures the header is set correctly so libraries like oauthlib can read it
1 parent d6feb72 commit 019cfcd

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

oauth2_provider/oauth2_backends.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from oauthlib.common import Request as OauthlibRequest
66
from oauthlib.common import quote, urlencode, urlencoded
77
from oauthlib.oauth2 import OAuth2Error
8+
from django.http import HttpRequest
89

910
from .exceptions import FatalClientError, OAuthToolkitError
1011
from .settings import oauth2_settings
@@ -75,6 +76,8 @@ def extract_headers(self, request):
7576
del headers["wsgi.errors"]
7677
if "HTTP_AUTHORIZATION" in headers:
7778
headers["Authorization"] = headers["HTTP_AUTHORIZATION"]
79+
if "CONTENT_TYPE" in headers:
80+
headers["Content-Type"] = headers["CONTENT_TYPE"]
7881
# Add Access-Control-Allow-Origin header to the token endpoint response for authentication code grant,
7982
# if the origin is allowed by RequestValidator.is_origin_allowed.
8083
# https://github.com/oauthlib/oauthlib/pull/791

0 commit comments

Comments
 (0)