Skip to content

Commit

Permalink
simplejwt compatability for 3.6 version #467
Browse files Browse the repository at this point in the history
  • Loading branch information
tfranzel committed Jul 26, 2021
1 parent 0c4499d commit 6594e95
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions drf_spectacular/contrib/rest_framework_simplejwt.py
Expand Up @@ -61,24 +61,25 @@ def get_security_definition(self, auto_schema):
f'OpenAPI3 can only have one "bearerFormat". JWT Settings specify '
f'{api_settings.AUTH_HEADER_TYPES}. Using the first one.'
)
header_name = getattr(api_settings, 'AUTH_HEADER_NAME', 'HTTP_AUTHORIZATION')

if (
api_settings.AUTH_HEADER_TYPES[0] == 'Bearer'
and api_settings.AUTH_HEADER_NAME == 'HTTP_AUTHORIZATION'
and header_name == 'HTTP_AUTHORIZATION'
):
return {
'type': 'http',
'scheme': 'bearer',
'bearerFormat': "JWT",
}
else:
header = api_settings.AUTH_HEADER_NAME
if header.startswith('HTTP_'):
header = header[5:]
header = header.capitalize()
if header_name.startswith('HTTP_'):
header_name = header_name[5:]
header_name = header_name.capitalize()
return {
'type': 'apiKey',
'in': 'header',
'name': header,
'name': header_name,
'description': _(
'Token-based authentication with required prefix "%s"'
) % api_settings.AUTH_HEADER_TYPES[0]
Expand Down

0 comments on commit 6594e95

Please sign in to comment.