Ejemplo n.º 1
0
    def receive_json(self, content: Data):
        msg = from_dict(WebsocketMessage, content)
        state = OutpostState(
            uid=self.channel_name,
            last_seen=datetime.now(),
            _outpost=self.outpost,
        )
        if msg.instruction == WebsocketMessageInstruction.HELLO:
            state.version = msg.args.get("version", None)
        elif msg.instruction == WebsocketMessageInstruction.ACK:
            return
        state.save(timeout=OUTPOST_HELLO_INTERVAL * 1.5)

        response = WebsocketMessage(
            instruction=WebsocketMessageInstruction.ACK)
        self.send_json(asdict(response))
Ejemplo n.º 2
0
 def connect(self):
     super().connect()
     uuid = self.scope["url_route"]["kwargs"]["pk"]
     outpost = get_objects_for_user(
         self.user, "authentik_outposts.view_outpost").filter(pk=uuid)
     if not outpost.exists():
         raise DenyConnection()
     self.accept()
     self.outpost = outpost.first()
     OutpostState(
         uid=self.channel_name,
         last_seen=datetime.now(),
         _outpost=self.outpost).save(timeout=OUTPOST_HELLO_INTERVAL * 1.5)
     LOGGER.debug(
         "added outpost instace to cache",
         outpost=self.outpost,
         channel_name=self.channel_name,
     )