forked from jpadilla/django-rest-framework-jwt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
44 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,40 @@ | ||
""" | ||
Blank URLConf just to keep the test suite happy | ||
""" | ||
urlpatterns = [] | ||
from django.conf.urls import url | ||
from django.http import HttpResponse | ||
from rest_framework import permissions | ||
from rest_framework.views import APIView | ||
try: | ||
from rest_framework_oauth.authentication import OAuth2Authentication | ||
except ImportError: | ||
try: | ||
from rest_framework.authentication import OAuth2Authentication | ||
except ImportError: | ||
OAuth2Authentication = None | ||
|
||
from rest_framework_jwt import views | ||
from rest_framework_jwt.authentication import JSONWebTokenAuthentication | ||
|
||
|
||
class MockView(APIView): | ||
permission_classes = (permissions.IsAuthenticated,) | ||
|
||
def get(self, request): | ||
return HttpResponse({'a': 1, 'b': 2, 'c': 3}) | ||
|
||
def post(self, request): | ||
return HttpResponse({'a': 1, 'b': 2, 'c': 3}) | ||
|
||
|
||
urlpatterns = [ | ||
url(r'^auth-token/$', views.obtain_jwt_token), | ||
url(r'^auth-token-refresh/$', views.refresh_jwt_token), | ||
url(r'^auth-token-verify/$', views.verify_jwt_token), | ||
|
||
url(r'^jwt/$', MockView.as_view( | ||
authentication_classes=[JSONWebTokenAuthentication])), | ||
url(r'^jwt-oauth2/$', MockView.as_view( | ||
authentication_classes=[ | ||
JSONWebTokenAuthentication, OAuth2Authentication])), | ||
url(r'^oauth2-jwt/$', MockView.as_view( | ||
authentication_classes=[ | ||
OAuth2Authentication, JSONWebTokenAuthentication])), | ||
] |