From 0733fbc5563d745be5f16478921155c705b245cd Mon Sep 17 00:00:00 2001 From: David Maxwell Date: Fri, 26 Mar 2021 17:52:11 +0000 Subject: [PATCH] Version 0.5.1 --- CHANGELOG.md | 6 ++++++ worker/logui_apps/control_api/flight/views.py | 2 +- .../websocket/consumers/endpoint.py | 21 ++++++++++--------- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 695efea..b84ea29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,4 +24,10 @@ This Markdown file contains the `CHANGELOG` for LogUI server. Changes are made a * Basic Django applications and data models to handle capturing and management of data. * Functional WebSocket server to handle incoming requests from the LogUI client. * Functional basic authorisation via use of an encrypted string. + +2021-03-26 Version 0.5.1 + + Works with LogUI client version 0.5.1 and above. + + Altered the configuration object to include an authorisation token, not an authentication token. Tidying up terminology. ``` \ No newline at end of file diff --git a/worker/logui_apps/control_api/flight/views.py b/worker/logui_apps/control_api/flight/views.py index dfe3e07..79d767f 100644 --- a/worker/logui_apps/control_api/flight/views.py +++ b/worker/logui_apps/control_api/flight/views.py @@ -52,7 +52,7 @@ class FlightAuthorisationTokenView(APIView): def get_authorisation_object(self, flight): return { - 'type': 'logUI-authentication-object', + 'type': 'logUI-authorisation-object', 'applicationID': str(flight.application.id), 'flightID': str(flight.id), } diff --git a/worker/logui_apps/websocket/consumers/endpoint.py b/worker/logui_apps/websocket/consumers/endpoint.py index 767da8b..1ace71f 100644 --- a/worker/logui_apps/websocket/consumers/endpoint.py +++ b/worker/logui_apps/websocket/consumers/endpoint.py @@ -77,8 +77,9 @@ def validate_request(self, request_dict): def validate_handshake(self, request_dict): if not self._handshake_success: if request_dict['type'] == 'handshake': + print(request_dict) if ('clientVersion' not in request_dict['payload'] or - 'authenticationToken' not in request_dict['payload'] or + 'authorisationToken' not in request_dict['payload'] or 'pageOrigin' not in request_dict['payload'] or 'userAgent' not in request_dict['payload'] or 'clientTimestamp' not in request_dict['payload']): @@ -90,9 +91,9 @@ def validate_handshake(self, request_dict): self.close(code=4003) return False - # Is the authentication token OK? + # Is the authorisation token OK? try: - if not self.is_authentication_valid(signing.loads(request_dict['payload']['authenticationToken']), request_dict['payload']['pageOrigin']): + if not self.is_authorisation_valid(signing.loads(request_dict['payload']['authorisationToken']), request_dict['payload']['pageOrigin']): return False except signing.BadSignature: self.close(code=4004) @@ -115,27 +116,27 @@ def validate_handshake(self, request_dict): return True - def is_authentication_valid(self, authentication_object, page_origin): - if ('type' not in authentication_object or - 'applicationID' not in authentication_object or - 'flightID' not in authentication_object): + def is_authorisation_valid(self, authorisation_object, page_origin): + if ('type' not in authorisation_object or + 'applicationID' not in authorisation_object or + 'flightID' not in authorisation_object): self.close(code=4004) return False - if authentication_object['type'] != 'logUI-authentication-object': + if authorisation_object['type'] != 'logUI-authorisation-object': self.close(code=4004) return False # Check the application exists. Set the instance variable. try: - self._application = Application.objects.get(id=authentication_object['applicationID']) + self._application = Application.objects.get(id=authorisation_object['applicationID']) except Application.DoesNotExist: self.close(code=4004) return False # Check the flight exists. Set the instance variable. try: - self._flight = Flight.objects.get(id=authentication_object['flightID']) + self._flight = Flight.objects.get(id=authorisation_object['flightID']) except Flight.DoesNotExist: self.close(code=4004) return False