From d4c7b670af7790bc188ad24e0822bc23a258aa2e Mon Sep 17 00:00:00 2001 From: Robert Andrei Moldoveanu Date: Tue, 8 Apr 2025 15:54:55 +0300 Subject: [PATCH 1/2] feat(auth): allow reuse address --- src/uipath/_cli/_auth/_auth_server.py | 41 +++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/src/uipath/_cli/_auth/_auth_server.py b/src/uipath/_cli/_auth/_auth_server.py index cfba7345..15995f28 100644 --- a/src/uipath/_cli/_auth/_auth_server.py +++ b/src/uipath/_cli/_auth/_auth_server.py @@ -113,7 +113,13 @@ def do_OPTIONS(self): class HTTPSServer: def __init__(self, port=6234, cert_file="localhost.crt", key_file="localhost.key"): - """Initialize HTTPS server with configurable parameters.""" + """Initialize HTTPS server with configurable parameters. + + Args: + port (int, optional): Port number to run the server on. Defaults to 6234. + cert_file (str, optional): SSL certificate file. Defaults to "localhost.crt". + key_file (str, optional): SSL key file. Defaults to "localhost.key". + """ self.current_path = os.path.dirname(os.path.abspath(__file__)) self.port = port self.cert_file = os.path.join(self.current_path, "localhost.crt") @@ -123,17 +129,31 @@ def __init__(self, port=6234, cert_file="localhost.crt", key_file="localhost.key self.should_shutdown = False def token_received_callback(self, token_data): - """Callback for when a token is received.""" + """Callback for when a token is received. + + Args: + token_data (dict): The received token data. + """ self.token_data = token_data self.should_shutdown = True def create_server(self, state, code_verifier, domain): - """Create and configure the HTTPS server.""" + """Create and configure the HTTPS server. + + Args: + state (str): The OAuth state parameter. + code_verifier (str): The PKCE code verifier. + domain (str): The domain for authentication. + + Returns: + socketserver.TCPServer: The configured HTTPS server. + """ # Create SSL context context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER) context.load_cert_chain(self.cert_file, self.key_file) - # Create server + # Create server with address reuse + socketserver.TCPServer.allow_reuse_address = True handler = make_request_handler_class( state, code_verifier, self.token_received_callback, domain ) @@ -143,7 +163,16 @@ def create_server(self, state, code_verifier, domain): return self.httpd def start(self, state, code_verifier, domain): - """Start the server.""" + """Start the server. + + Args: + state (str): The OAuth state parameter. + code_verifier (str): The PKCE code verifier. + domain (str): The domain for authentication. + + Returns: + dict: The received token data or an empty dict if no token was received. + """ if not self.httpd: self.create_server(state, code_verifier, domain) @@ -159,7 +188,7 @@ def start(self, state, code_verifier, domain): return self.token_data if self.token_data else {} def stop(self): - """Stop the server gracefully.""" + """Stop the server gracefully and cleanup resources.""" if self.httpd: self.httpd.server_close() self.httpd = None From 535626c8ef5a4b7d231b43a69ee9bf3d21a6a1ec Mon Sep 17 00:00:00 2001 From: Robert Andrei Moldoveanu Date: Tue, 8 Apr 2025 15:55:36 +0300 Subject: [PATCH 2/2] chore: increase sdk version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 24c45e62..a283ba95 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "uipath" -version = "2.0.2.dev2" +version = "2.0.3" description = "Python SDK and CLI for UiPath Platform, enabling programmatic interaction with automation services, process management, and deployment tools." readme = { file = "README.md", content-type = "text/markdown" } requires-python = ">=3.10"