Added JWTs and API protection
This commit is contained in:
parent
197068ebfa
commit
8633bb09d2
@ -49,12 +49,13 @@ INSTALLED_APPS = [
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'rest_framework',
|
||||
'django_hopid'
|
||||
]
|
||||
|
||||
HOPID_URL = 'http://localhost:8000'
|
||||
HOPID_CLIENT_ID = 'Gq8AgUy4SE5FnbzLLIsToAgU7HOA4oUDqQFaJaEB'
|
||||
HOPID_CLIENT_SECRET = 'M0Rah0D6IP4neJ7mwrDTsM9GJgEequatZZdKCYXqXLByGDNyma0MdYNT9hTvtC3J2gwnW2uY1hQml9fWeEu99bCFvkdI8SVE3rztaDbaXz0n8ev9WRJyXdn7Jfi83fw4'
|
||||
HOPID_CLIENT_ID = 'yxYyX4aza4c43GCEhFtzJspJSkoKE8U2dBLTgVHR'
|
||||
HOPID_CLIENT_SECRET = '8hX83NE2yW1RI95hhO8LZO98l5EhNixvLoTQ9fdEnXDUTeyFDINaDpR3o72f5RsoJ2mruvwd0D6xCj5HNJby4fCQZbMr2y2mnGYBkZdnGDrTTe2d68st6vyWL7WSwbZ1'
|
||||
HOPID_CLIENT_URI = 'http://localhost:8001'
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
@ -33,6 +33,7 @@ urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path('', views.index, name='index'),
|
||||
path("id/", include("django_hopid.urls")),
|
||||
path("test/", views.api_test, name="test"),
|
||||
]
|
||||
|
||||
if settings.DEBUG:
|
||||
|
@ -23,6 +23,16 @@ SOFTWARE.
|
||||
"""
|
||||
|
||||
from django.shortcuts import render
|
||||
from django_hopid.decorators import hopid_protected
|
||||
from rest_framework.decorators import api_view
|
||||
from django.http import JsonResponse
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
@hopid_protected
|
||||
def api_test(request):
|
||||
return JsonResponse({'status': 'ok'})
|
||||
|
||||
|
||||
def index(request):
|
||||
return render(request, "templates/index.html")
|
||||
|
Loading…
x
Reference in New Issue
Block a user