authentik.sources.oauth.views.dispatcher
Dispatch OAuth views to respective views
1"""Dispatch OAuth views to respective views""" 2 3from django.shortcuts import get_object_or_404 4from django.utils.decorators import method_decorator 5from django.views import View 6from django.views.decorators.csrf import csrf_exempt 7from structlog.stdlib import get_logger 8 9from authentik.sources.oauth.models import OAuthSource 10from authentik.sources.oauth.types.registry import RequestKind, registry 11 12LOGGER = get_logger() 13 14 15@method_decorator(csrf_exempt, name="dispatch") 16class DispatcherView(View): 17 """Dispatch OAuth Redirect/Callback views to their proper class based on URL parameters""" 18 19 kind = "" 20 21 def dispatch(self, *args, source_slug: str, **kwargs): 22 """Find Source by slug and forward request""" 23 source = get_object_or_404(OAuthSource, slug=source_slug) 24 view = registry.find(source.provider_type, kind=RequestKind(self.kind)) 25 LOGGER.debug("dispatching OAuth2 request to", view=view, kind=self.kind) 26 return view.as_view()(*args, source_slug=source_slug, **kwargs)
LOGGER =
<BoundLoggerLazyProxy(logger=None, wrapper_class=None, processors=None, context_class=None, initial_values={}, logger_factory_args=())>
@method_decorator(csrf_exempt, name='dispatch')
class
DispatcherView16@method_decorator(csrf_exempt, name="dispatch") 17class DispatcherView(View): 18 """Dispatch OAuth Redirect/Callback views to their proper class based on URL parameters""" 19 20 kind = "" 21 22 def dispatch(self, *args, source_slug: str, **kwargs): 23 """Find Source by slug and forward request""" 24 source = get_object_or_404(OAuthSource, slug=source_slug) 25 view = registry.find(source.provider_type, kind=RequestKind(self.kind)) 26 LOGGER.debug("dispatching OAuth2 request to", view=view, kind=self.kind) 27 return view.as_view()(*args, source_slug=source_slug, **kwargs)
Dispatch OAuth Redirect/Callback views to their proper class based on URL parameters
def
dispatch(self, *args, source_slug: str, **kwargs):
22 def dispatch(self, *args, source_slug: str, **kwargs): 23 """Find Source by slug and forward request""" 24 source = get_object_or_404(OAuthSource, slug=source_slug) 25 view = registry.find(source.provider_type, kind=RequestKind(self.kind)) 26 LOGGER.debug("dispatching OAuth2 request to", view=view, kind=self.kind) 27 return view.as_view()(*args, source_slug=source_slug, **kwargs)
Find Source by slug and forward request