class_docstr: Implements a custom Tornado WebSocketHandler for the Bokeh Server.
  
      
docstr: Implement a check_origin policy for Tornado to call.
  
  The supplied origin will be compared to the Bokeh server allowlist. If the
  origin is not allow, an error will be logged and ``False`` will be returned.
  
  Args:
      origin (str) :
          The URL of the connection origin
  
  Returns:
      bool, True if the connection is allowed, False otherwise
docstr_tok: ["Implement","a","check_origin","policy","for","Tornado","to","call",".","The","supplied","origin","will","be","compared","to","the","Bokeh","server","allowlist",".","If","the","origin","is","not","allow",",","an","error","will","be","logged","and","``","False","``","will","be","returned",".","Args",":","origin","(","str",")",":","The","URL","of","the","connection","origin","Returns",":","bool",",","True","if","the","connection","is","allowed",",","False","otherwise"]
code: def check_origin(self, origin: str) -> bool:
      """Implement a check_origin policy for Tornado to call.
  
      The supplied origin will be compared to the Bokeh server allowlist. If the
      origin is not allow, an error will be logged and ``False`` will be returned.
  
      Args:
          origin (str) :
              The URL of the connection origin
  
      Returns:
          bool, True if the connection is allowed, False otherwise
  
      """
      from ..util import check_allowlist
  
      parsed_origin = urlparse(origin)
      origin_host = parsed_origin.netloc.lower()
  
      allowed_hosts = self.application.websocket_origins
      if settings.allowed_ws_origin():
          allowed_hosts = set(settings.allowed_ws_origin())
  
      allowed = check_allowlist(origin_host, allowed_hosts)
      if allowed:
          return True
      else:
          log.error(
              "Refusing websocket connection from Origin '%s'; \
                        use --allow-websocket-origin=%s or set BOKEH_ALLOW_WS_ORIGIN=%s to permit this; currently we allow origins %r",
              origin,
              origin_host,
              origin_host,
              allowed_hosts,
          )
          return False
  
imports: from __future__ import annotations
  import logging
  import calendar
  import datetime
  from typing import TYPE_CHECKING, Any, cast
  from urllib.parse import urlparse
  from tornado import locks, web
  from tornado.websocket import WebSocketClosedError, WebSocketHandler
  from bokeh.settings import settings
  from bokeh.util.token import check_token_signature, get_session_id, get_token_payload
  from ...protocol import Protocol
  from ...protocol.exceptions import MessageError, ProtocolError, ValidationError
  from ...protocol.message import Message
  from ...protocol.receiver import Receiver
  from ...util.dataclasses import dataclass
  from ..protocol_handler import ProtocolHandler
  from .auth_request_handler import AuthRequestHandler
label_desc: Use image node_id 3 for calling the WSHandler obj's underlying member method code with example usage: obj.check_origin(origin) and returns: True, False