Skip to content

Commit

Permalink
Version 0.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
maxwelld90 committed Mar 26, 2021
1 parent af17f01 commit 0733fbc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
```
2 changes: 1 addition & 1 deletion worker/logui_apps/control_api/flight/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down
21 changes: 11 additions & 10 deletions worker/logui_apps/websocket/consumers/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']):
Expand All @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 0733fbc

Please sign in to comment.