Skip to content

Commit

Permalink
Add djangorestframework-jwt auth handler
Browse files Browse the repository at this point in the history
Related to tfranzel#28
  • Loading branch information
jayvdb committed May 3, 2020
1 parent c21a177 commit 2f48a47
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions drf_spectacular/contrib/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@ def get_security_definition(self, auto_schema):
}


class JWTScheme(OpenApiAuthenticationExtension):
target_class = 'rest_framework_jwt.authentication.JSONWebTokenAuthentication'
name = 'jwtAuth'

def get_security_definition(self, auto_schema):
from rest_framework_jwt.settings import api_settings

return {
'type': 'http',
'scheme': 'bearer',
'bearerFormat': api_settings.JWT_AUTH_HEADER_PREFIX,
}


class DjangoOAuthToolkitScheme(OpenApiAuthenticationExtension):
target_class = 'oauth2_provider.contrib.rest_framework.OAuth2Authentication'
name = 'oauth2'
Expand Down

0 comments on commit 2f48a47

Please sign in to comment.