adding session id to uds actor

This commit is contained in:
Adolfo Gómez García 2022-08-06 19:23:51 +02:00
parent 0ed8bd6027
commit ec89a2cfa8
3 changed files with 14 additions and 5 deletions

View File

@ -54,7 +54,7 @@ if __name__ == "__main__":
qApp = UDSClientQApp(sys.argv) qApp = UDSClientQApp(sys.argv)
if 'linux' not in sys.platform: if 'win' in sys.platform:
# The "hidden window" is only needed to process events on Windows # The "hidden window" is only needed to process events on Windows
# Not needed on Linux # Not needed on Linux
mw = QMainWindow() mw = QMainWindow()

View File

@ -131,7 +131,7 @@ class UDSApi: # pylint: disable=too-few-public-methods
headers=headers, headers=headers,
verify=self._validateCert, verify=self._validateCert,
timeout=TIMEOUT, timeout=TIMEOUT,
proxies=NO_PROXY # type: ignore proxies=NO_PROXY # type: ignore
if disableProxy if disableProxy
else None, # if not proxies wanted, enforce it else None, # if not proxies wanted, enforce it
) )
@ -329,7 +329,11 @@ class UDSServerApi(UDSApi):
) -> types.LoginResultInfoType: ) -> types.LoginResultInfoType:
if not token: if not token:
return types.LoginResultInfoType( return types.LoginResultInfoType(
ip='0.0.0.0', hostname=UNKNOWN, dead_line=None, max_idle=None # nosec: this is not a binding ip='0.0.0.0', # nosec: this is not a binding
hostname=UNKNOWN,
dead_line=None,
max_idle=None,
session_id=None,
) )
payload = { payload = {
'type': actor_type or types.MANAGED, 'type': actor_type or types.MANAGED,
@ -340,11 +344,12 @@ class UDSServerApi(UDSApi):
'secret': secret or '', 'secret': secret or '',
} }
result = self._doPost('login', payload) result = self._doPost('login', payload)
return types.LoginResultInfoType( return types.LoginResultInfoType( # nosec: this is not a binding
ip=result['ip'], ip=result['ip'],
hostname=result['hostname'], hostname=result['hostname'],
dead_line=result['dead_line'], dead_line=result['dead_line'],
max_idle=result['max_idle'], max_idle=result['max_idle'],
session_id=result['session_id'],
) )
def logout( def logout(
@ -352,6 +357,7 @@ class UDSServerApi(UDSApi):
actor_type: typing.Optional[str], actor_type: typing.Optional[str],
token: str, token: str,
username: str, username: str,
session_id: typing.Optional[str],
interfaces: typing.Iterable[types.InterfaceInfoType], interfaces: typing.Iterable[types.InterfaceInfoType],
secret: typing.Optional[str], secret: typing.Optional[str],
) -> None: ) -> None:
@ -362,6 +368,7 @@ class UDSServerApi(UDSApi):
'id': [{'mac': i.mac, 'ip': i.ip} for i in interfaces], 'id': [{'mac': i.mac, 'ip': i.ip} for i in interfaces],
'token': token, 'token': token,
'username': username, 'username': username,
'session_id': session_id or '',
'secret': secret or '', 'secret': secret or '',
} }
self._doPost('logout', payload) self._doPost('logout', payload)
@ -417,6 +424,7 @@ class UDSClientApi(UDSApi):
hostname=result['hostname'], hostname=result['hostname'],
dead_line=result['dead_line'], dead_line=result['dead_line'],
max_idle=result['max_idle'], max_idle=result['max_idle'],
session_id=result['session_id'],
) )
def logout(self, username: str) -> None: def logout(self, username: str) -> None:

View File

@ -57,7 +57,8 @@ class LoginResultInfoType(typing.NamedTuple):
ip: str ip: str
hostname: str hostname: str
dead_line: typing.Optional[int] dead_line: typing.Optional[int]
max_idle: typing.Optional[int] # Not provided by broker max_idle: typing.Optional[int]
session_id: typing.Optional[str]
class CertificateInfoType(typing.NamedTuple): class CertificateInfoType(typing.NamedTuple):
private_key: str private_key: str