Skip to main content

http_server

HTTP server for authentication in Datalayer Core.

class LoginRequestHandler(*args, directory=None, **kwargs)

Handle HTTP requests for authentication flow.

This handler serves static files from a directory and handles receiving the authentication token for CLI usage.

do_GET() -> 'None'

Handle GET requests for authentication flow.

do_POST() -> 'None'

Handle POST requests with authentication data.

log_message(format: 'str', *args: 't.Tuple[t.Any]') -> 'None'

Log HTTP server messages.

Parameters

  • format : str

    Format string for the log message.

  • *args : tuple[Any]

    Arguments for the format string.

class DualStackServer(server_address: 'tuple[str | bytes | bytearray, int]', RequestHandlerClass: 't.Callable[[t.Any, t.Any, t.Self], BaseRequestHandler]', run_url: 'str', bind_and_activate: 'bool' = True) -> 'None'

HTTP server supporting both IPv4 and IPv6.

Parameters

  • server_address : tuple[str | bytes | bytearray, int]

    The server address and port.

  • RequestHandlerClass : Callable

    The request handler class.

  • run_url : str

    The runtime URL.

  • bind_and_activate : bool, default True

    Whether to bind and activate the server.

__init__(server_address: 'tuple[str | bytes | bytearray, int]', RequestHandlerClass: 't.Callable[[t.Any, t.Any, t.Self], BaseRequestHandler]', run_url: 'str', bind_and_activate: 'bool' = True) -> 'None'

Initialize the dual stack HTTP server.

Parameters

  • server_address : tuple[str | bytes | bytearray, int]

    The server address and port.

  • RequestHandlerClass : Callable

    The request handler class.

  • run_url : str

    The runtime URL.

  • bind_and_activate : bool, default True

    Whether to bind and activate the server.

server_bind() -> 'None'

Bind the server socket, supporting both IPv4 and IPv6.

Returns

  • None

    This method does not return a value.

finish_request(request: 't.Any', client_address: 'str') -> 'None'

Complete an incoming request.

Parameters

  • request : Any

    The request object.

  • client_address : str

    The client address.

def get_token(run_url: 'str', port: 'int | None' = None, logger: 'logging.Logger' = <Logger datalayer_core.authn.http_server (WARNING)>) -> 'tuple[str, str] | None'

Get the user handle and token.

Parameters

  • run_url : str

    The runtime URL.

  • port : int or None, default None

    The port to use for the authentication server.

  • logger : logging.Logger, default logger

    The logger instance to use.

Returns

  • tuple[str, str] or None

    A tuple containing the user handle and token, or None if authentication fails.