Some endpoints for testing authentication

This commit is contained in:
Xeryus Stokkel 2022-01-18 15:21:58 +01:00
parent 03a7eda48e
commit b2a64e4227
Signed by: Xeryus Stokkel
GPG Key ID: 7023C2C891DDE681
2 changed files with 17 additions and 0 deletions

View File

@ -23,4 +23,6 @@ urlpatterns = [
path('oauth/', include('oauth2_provider.urls', namespace='oauth2_provider')),
path('admin/', admin.site.urls),
path('scim/v2/', include('django_scim.urls')),
path('api/hello/', views.ApiEndpoint.as_view()),
path('secret/', views.secret_page, name='secret'),
]

View File

@ -1,5 +1,20 @@
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse
from django.utils.decorators import method_decorator
from django.views.generic import TemplateView
from oauth2_provider.views.generic import ProtectedResourceView
class AuthView(TemplateView):
template_name = "index.html"
class ApiEndpoint(ProtectedResourceView):
def get(self, request, *args, **kwargs):
return HttpResponse('Hello world!')
@login_required
def secret_page(request, *args, **kwargs):
return HttpResponse('Secret contents!', status=200)