Skip to content

Commit c7494f9

Browse files
committed
feat: use token for websocket authentication
The cli expects to receive websocket-access-token, websocket-refresh-token, and websocket-token-address. It does not send the authentication header if above arguments are not provided, so it works with the old eda-server that does not authenticate incomming websocket connecitons. Linked AAP-17776: ansible-rulebook uses token for authentication
1 parent 8743f53 commit c7494f9

File tree

5 files changed

+254
-97
lines changed

5 files changed

+254
-97
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
### Added
77
- ssl_verify option now also supports "true" or "false" values
88
- Support for standalone boolean in conditions
9+
- Use token for websocket authentication
910

1011
### Fixed
1112

ansible_rulebook/app.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,12 @@ async def run(parsed_args: argparse.Namespace) -> None:
6767
if parsed_args.worker and parsed_args.websocket_address and parsed_args.id:
6868
logger.info("Starting worker mode")
6969
startup_args = await request_workload(
70-
parsed_args.id,
71-
parsed_args.websocket_address,
72-
parsed_args.websocket_ssl_verify,
70+
activation_id=parsed_args.id,
71+
websocket_address=parsed_args.websocket_address,
72+
websocket_ssl_verify=parsed_args.websocket_ssl_verify,
73+
websocket_token_address=parsed_args.websocket_token_address,
74+
websocket_access_token=parsed_args.websocket_access_token,
75+
websocket_refresh_token=parsed_args.websocket_refresh_token,
7376
)
7477
if not startup_args:
7578
logger.error("Error communicating with web socket server")
@@ -121,9 +124,12 @@ async def run(parsed_args: argparse.Namespace) -> None:
121124
if parsed_args.websocket_address:
122125
feedback_task = asyncio.create_task(
123126
send_event_log_to_websocket(
124-
event_log,
125-
parsed_args.websocket_address,
126-
parsed_args.websocket_ssl_verify,
127+
event_log=event_log,
128+
websocket_address=parsed_args.websocket_address,
129+
websocket_ssl_verify=parsed_args.websocket_ssl_verify,
130+
websocket_token_address=parsed_args.websocket_token_address,
131+
websocket_access_token=parsed_args.websocket_access_token,
132+
websocket_refresh_token=parsed_args.websocket_refresh_token,
127133
)
128134
)
129135
tasks.append(feedback_task)

ansible_rulebook/cli.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,19 @@ def get_parser() -> argparse.ArgumentParser:
105105
"default to yes for wss connection.",
106106
default="yes",
107107
)
108+
parser.add_argument(
109+
"--websocket-access-token",
110+
help="Token used to autheticate the websocket connection.",
111+
)
112+
parser.add_argument(
113+
"--websocket-refresh-token",
114+
help="Token used to renew a websocket access token.",
115+
)
116+
parser.add_argument(
117+
"--websocket-token-address",
118+
"--websocket-token-url",
119+
help="Url to renew websocket access token.",
120+
)
108121
parser.add_argument("--id", help="Identifier")
109122
parser.add_argument(
110123
"-w",

0 commit comments

Comments
 (0)