Skip to content

Commit

Permalink
[Serial Console] Migrate to a new authentication flow (#7653)
Browse files Browse the repository at this point in the history
* changed readme

* added slag

* tests finally work

* auth flow changes

* working stage

* removed semicolon

* formatting

* removed debug statements from tests

* formatting

* formatting v3456

* fixed typo

* send token after first message is recieved

* remove flag

* changed version

* rebase leftover

* recorsdings tests

* updated tests

* tests

* version update

* change to trigger build

* Update src/serial-console/azext_serialconsole/custom.py

Co-authored-by: kai ru <[email protected]>

---------

Co-authored-by: Dominika Bobik <[email protected]>
Co-authored-by: kai ru <[email protected]>
  • Loading branch information
3 people committed Jun 12, 2024
1 parent 57005b8 commit 5bc43ac
Show file tree
Hide file tree
Showing 6 changed files with 2,275 additions and 2,091 deletions.
4 changes: 4 additions & 0 deletions src/serial-console/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Release History
===============

1.0.0b1
++++++
* Migrated to a new authentication flow to enhance overall security

0.1.8
++++++
* Changed first message flow, fixed typo
Expand Down
9 changes: 3 additions & 6 deletions src/serial-console/azext_serialconsole/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@ def __init__(self, cmd, resource_group_name, vm_vmss_name, vmss_instanceid):

self.websocket_url = None
self.access_token = None
self.new_auth_flow = "1"

@staticmethod
def listen_for_keys():
Expand Down Expand Up @@ -434,8 +433,7 @@ def on_open(_):

def on_message(_, message):
if GV.first_message:
if self.new_auth_flow == "1":
GV.websocket_instance.send(self.access_token)
GV.websocket_instance.send(self.access_token)
GV.first_message = False
GV.loading = False
PC.clear_screen()
Expand All @@ -460,7 +458,7 @@ def on_close(_):
def connect_thread():
if self.load_websocket_url():
GV.websocket_instance = websocket.WebSocketApp(
self.websocket_url + "?authorization=" + self.access_token + "&new=" + self.new_auth_flow,
self.websocket_url,
on_open=on_open,
on_message=on_message,
on_error=on_error,
Expand Down Expand Up @@ -565,8 +563,7 @@ def on_message(ws, _):
ws.close()

wsapp = websocket.WebSocketApp(
self.websocket_url + "?authorization=" + self.access_token + "&new="
+ self.new_auth_flow, on_message=on_message)
self.websocket_url, on_message=on_message)
wsapp.run_forever()
GV.loading = False
if GV.trycount == 0:
Expand Down
Loading

0 comments on commit 5bc43ac

Please sign in to comment.