Skip to content

Commit fde3572

Browse files
Adjust custom auth samples for token key name and token value (#444)
1 parent eee754f commit fde3572

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

samples/custom_authorizer_connect.py

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ def on_connection_resumed(connection, return_code, session_present, **kwargs):
3131
auth_authorizer_name=cmdData.input_custom_authorizer_name,
3232
auth_authorizer_signature=cmdData.input_custom_authorizer_signature,
3333
auth_password=cmdData.input_custom_auth_password,
34+
auth_token_key_name=cmdData.input_custom_authorizer_token_key_name,
35+
auth_token_value=cmdData.input_custom_authorizer_token_value,
3436
on_connection_interrupted=on_connection_interrupted,
3537
on_connection_resumed=on_connection_resumed,
3638
client_id=cmdData.input_clientId,

samples/mqtt5_custom_authorizer_connect.py

+4
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ def on_lifecycle_connection_success(lifecycle_connect_success_data: mqtt5.Lifecy
4343
auth_authorizer_name=cmdData.input_custom_authorizer_name,
4444
auth_authorizer_signature=cmdData.input_custom_authorizer_signature,
4545
auth_password=cmdData.input_custom_auth_password,
46+
auth_token_key_name=cmdData.input_custom_authorizer_token_key_name,
47+
auth_token_value=cmdData.input_custom_authorizer_token_value,
4648
on_lifecycle_stopped=on_lifecycle_stopped,
4749
on_lifecycle_connection_success=on_lifecycle_connection_success,
4850
client_id=cmdData.input_clientId)
@@ -54,6 +56,8 @@ def on_lifecycle_connection_success(lifecycle_connect_success_data: mqtt5.Lifecy
5456
auth_authorizer_name=cmdData.input_custom_authorizer_name,
5557
auth_authorizer_signature=cmdData.input_custom_authorizer_signature,
5658
auth_password=cmdData.input_custom_auth_password,
59+
auth_token_key_name=cmdData.input_custom_authorizer_token_key_name,
60+
auth_token_value=cmdData.input_custom_authorizer_token_value,
5761
on_lifecycle_stopped=on_lifecycle_stopped,
5862
on_lifecycle_connection_success=on_lifecycle_connection_success,
5963
client_id=cmdData.input_clientId)

samples/utils/command_line_utils.py

+16
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,14 @@ def add_common_custom_authorizer_commands(self):
181181
CommandLineUtils.m_cmd_custom_auth_password,
182182
"<str>",
183183
"The password to send when connecting through a custom authorizer (optional)")
184+
self.register_command(
185+
CommandLineUtils.m_cmd_custom_auth_token_key_name,
186+
"<str>",
187+
"Key used to extract the custom authorizer token (optional)")
188+
self.register_command(
189+
CommandLineUtils.m_cmd_custom_auth_token_value,
190+
"<str>",
191+
"The opaque token value for the custom authorizer (optional)")
184192

185193
def add_common_x509_commands(self):
186194
self.register_command(
@@ -245,6 +253,8 @@ class CmdData:
245253
input_custom_authorizer_name : str
246254
input_custom_authorizer_signature : str
247255
input_custom_auth_password : str
256+
input_custom_authorizer_token_key_name : str
257+
input_custom_authorizer_token_value : str
248258
# Fleet provisioning
249259
input_template_name : str
250260
input_template_parameters : str
@@ -400,6 +410,8 @@ def parse_sample_input_custom_authorizer_connect():
400410
cmdData.input_custom_authorizer_signature = cmdUtils.get_command(CommandLineUtils.m_cmd_custom_auth_authorizer_signature)
401411
cmdData.input_custom_auth_password = cmdUtils.get_command(CommandLineUtils.m_cmd_custom_auth_password)
402412
cmdData.input_custom_auth_username = cmdUtils.get_command(CommandLineUtils.m_cmd_custom_auth_username)
413+
cmdData.input_custom_authorizer_token_key_name = cmdUtils.get_command(CommandLineUtils.m_cmd_custom_auth_token_key_name)
414+
cmdData.input_custom_authorizer_token_value = cmdUtils.get_command(CommandLineUtils.m_cmd_custom_auth_token_value)
403415
cmdData.input_clientId = cmdUtils.get_command(CommandLineUtils.m_cmd_client_id, "test-" + str(uuid4()))
404416
cmdData.input_is_ci = cmdUtils.get_command(CommandLineUtils.m_cmd_is_ci, None) != None
405417
return cmdData
@@ -488,6 +500,8 @@ def parse_sample_input_mqtt5_custom_authorizer_connect():
488500
cmdData.input_custom_authorizer_signature = cmdUtils.get_command(CommandLineUtils.m_cmd_custom_auth_authorizer_signature)
489501
cmdData.input_custom_auth_password = cmdUtils.get_command(CommandLineUtils.m_cmd_custom_auth_password)
490502
cmdData.input_custom_auth_username = cmdUtils.get_command(CommandLineUtils.m_cmd_custom_auth_username)
503+
cmdData.input_custom_authorizer_token_key_name = cmdUtils.get_command(CommandLineUtils.m_cmd_custom_auth_token_key_name)
504+
cmdData.input_custom_authorizer_token_value = cmdUtils.get_command(CommandLineUtils.m_cmd_custom_auth_token_value)
491505
cmdData.input_clientId = cmdUtils.get_command(CommandLineUtils.m_cmd_client_id, "test-" + str(uuid4()))
492506
cmdData.input_use_websockets = bool(cmdUtils.get_command(CommandLineUtils.m_cmd_use_websockets, False))
493507
cmdData.input_is_ci = cmdUtils.get_command(CommandLineUtils.m_cmd_is_ci, None) != None
@@ -802,6 +816,8 @@ def parse_sample_input_x509_connect():
802816
m_cmd_custom_auth_authorizer_name = "custom_auth_authorizer_name"
803817
m_cmd_custom_auth_authorizer_signature = "custom_auth_authorizer_signature"
804818
m_cmd_custom_auth_password = "custom_auth_password"
819+
m_cmd_custom_auth_token_key_name = "custom_auth_token_key_name"
820+
m_cmd_custom_auth_token_value = "custom_auth_token_value"
805821
m_cmd_cognito_identity = "cognito_identity"
806822
m_cmd_x509_endpoint = "x509_endpoint"
807823
m_cmd_x509_thing_name = "x509_thing_name"

0 commit comments

Comments
 (0)