From 2c389be05cd37ab81cae35e4f49ff905a5efa00f Mon Sep 17 00:00:00 2001 From: rdimaio Date: Mon, 8 Apr 2024 10:58:39 +0200 Subject: [PATCH] Auth: ssh_sign, add type hints; #6600 Follow-up from this PR: https://github.com/rucio/rucio/pull/6497 --- lib/rucio/common/utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/rucio/common/utils.py b/lib/rucio/common/utils.py index d3af0d8505..4d5c1be63d 100644 --- a/lib/rucio/common/utils.py +++ b/lib/rucio/common/utils.py @@ -1271,7 +1271,7 @@ def detect_client_location(): 'longitude': longitude} -def ssh_sign(private_key, message): +def ssh_sign(private_key: str, message: str) -> str: """ Sign a string message using the private key. @@ -1279,13 +1279,13 @@ def ssh_sign(private_key, message): :param message: The message to sign as a string. :return: Base64 encoded signature as a string. """ - message = message.encode() + encoded_message = message.encode() if not EXTRA_MODULES['paramiko']: raise MissingModuleException('The paramiko module is not installed or faulty.') sio_private_key = StringIO(private_key) priv_k = RSAKey.from_private_key(sio_private_key) sio_private_key.close() - signature_stream = priv_k.sign_ssh_data(message) + signature_stream = priv_k.sign_ssh_data(encoded_message) signature_stream.rewind() base64_encoded = base64.b64encode(signature_stream.get_remainder()) base64_encoded = base64_encoded.decode()