authentik.enterprise.endpoints.connectors.google_chrome.stage

 1from django.http import HttpResponse
 2from django.urls import reverse
 3from django.utils.translation import gettext as _
 4
 5from authentik.endpoints.models import StageMode
 6from authentik.flows.challenge import (
 7    Challenge,
 8    ChallengeResponse,
 9    FrameChallenge,
10    FrameChallengeResponse,
11)
12from authentik.flows.planner import PLAN_CONTEXT_DEVICE
13from authentik.flows.stage import ChallengeStageView
14
15
16class GoogleChromeStageView(ChallengeStageView):
17    """Endpoint stage"""
18
19    response_class = FrameChallengeResponse
20
21    def get_challenge(self, *args, **kwargs) -> Challenge:
22        return FrameChallenge(
23            data={
24                "component": "xak-flow-frame",
25                "url": self.request.build_absolute_uri(
26                    reverse("authentik_endpoints_connectors_google_chrome:chrome")
27                ),
28                "loading_overlay": True,
29                "loading_text": _("Verifying your browser..."),
30            }
31        )
32
33    def challenge_valid(self, response: ChallengeResponse) -> HttpResponse:
34        if (
35            PLAN_CONTEXT_DEVICE not in self.executor.plan.context
36            and self.executor.current_stage.mode == StageMode.REQUIRED
37        ):
38            return self.executor.stage_invalid("Invalid challenge response")
39        return self.executor.stage_ok()
class GoogleChromeStageView(authentik.flows.stage.ChallengeStageView):
17class GoogleChromeStageView(ChallengeStageView):
18    """Endpoint stage"""
19
20    response_class = FrameChallengeResponse
21
22    def get_challenge(self, *args, **kwargs) -> Challenge:
23        return FrameChallenge(
24            data={
25                "component": "xak-flow-frame",
26                "url": self.request.build_absolute_uri(
27                    reverse("authentik_endpoints_connectors_google_chrome:chrome")
28                ),
29                "loading_overlay": True,
30                "loading_text": _("Verifying your browser..."),
31            }
32        )
33
34    def challenge_valid(self, response: ChallengeResponse) -> HttpResponse:
35        if (
36            PLAN_CONTEXT_DEVICE not in self.executor.plan.context
37            and self.executor.current_stage.mode == StageMode.REQUIRED
38        ):
39            return self.executor.stage_invalid("Invalid challenge response")
40        return self.executor.stage_ok()

Endpoint stage

def get_challenge(self, *args, **kwargs) -> authentik.flows.challenge.Challenge:
22    def get_challenge(self, *args, **kwargs) -> Challenge:
23        return FrameChallenge(
24            data={
25                "component": "xak-flow-frame",
26                "url": self.request.build_absolute_uri(
27                    reverse("authentik_endpoints_connectors_google_chrome:chrome")
28                ),
29                "loading_overlay": True,
30                "loading_text": _("Verifying your browser..."),
31            }
32        )

Return the challenge that the client should solve

def challenge_valid( self, response: authentik.flows.challenge.ChallengeResponse) -> django.http.response.HttpResponse:
34    def challenge_valid(self, response: ChallengeResponse) -> HttpResponse:
35        if (
36            PLAN_CONTEXT_DEVICE not in self.executor.plan.context
37            and self.executor.current_stage.mode == StageMode.REQUIRED
38        ):
39            return self.executor.stage_invalid("Invalid challenge response")
40        return self.executor.stage_ok()

Callback when the challenge has the correct format