authentik.brands.views.webfinger
1from typing import Any 2 3from django.http import HttpRequest, HttpResponse, JsonResponse 4from django.views import View 5 6from authentik.brands.models import Brand, WebfingerProvider 7from authentik.core.models import Application 8 9 10class WebFingerView(View): 11 """Webfinger endpoint""" 12 13 def get(self, request: HttpRequest) -> HttpResponse: 14 brand: Brand = request.brand 15 if not brand.default_application: 16 return JsonResponse({}) 17 application: Application = brand.default_application 18 provider = application.get_provider() 19 if not provider or not isinstance(provider, WebfingerProvider): 20 return JsonResponse({}) 21 webfinger_data = provider.webfinger(request.GET.get("resource"), request) 22 return JsonResponse(webfinger_data) 23 24 def dispatch(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: 25 response = super().dispatch(request, *args, **kwargs) 26 # RFC7033 spec 27 response["Access-Control-Allow-Origin"] = "*" 28 response["Content-Type"] = "application/jrd+json" 29 return response
class
WebFingerView(django.views.generic.base.View):
11class WebFingerView(View): 12 """Webfinger endpoint""" 13 14 def get(self, request: HttpRequest) -> HttpResponse: 15 brand: Brand = request.brand 16 if not brand.default_application: 17 return JsonResponse({}) 18 application: Application = brand.default_application 19 provider = application.get_provider() 20 if not provider or not isinstance(provider, WebfingerProvider): 21 return JsonResponse({}) 22 webfinger_data = provider.webfinger(request.GET.get("resource"), request) 23 return JsonResponse(webfinger_data) 24 25 def dispatch(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: 26 response = super().dispatch(request, *args, **kwargs) 27 # RFC7033 spec 28 response["Access-Control-Allow-Origin"] = "*" 29 response["Content-Type"] = "application/jrd+json" 30 return response
Webfinger endpoint
def
get( self, request: django.http.request.HttpRequest) -> django.http.response.HttpResponse:
14 def get(self, request: HttpRequest) -> HttpResponse: 15 brand: Brand = request.brand 16 if not brand.default_application: 17 return JsonResponse({}) 18 application: Application = brand.default_application 19 provider = application.get_provider() 20 if not provider or not isinstance(provider, WebfingerProvider): 21 return JsonResponse({}) 22 webfinger_data = provider.webfinger(request.GET.get("resource"), request) 23 return JsonResponse(webfinger_data)