Skip to content

IoT unsigned custom authentication builder broken #527

Open
@jawilson

Description

@jawilson

Describe the bug

AwsIotMqttConnectionConfigBuilder.with_custom_authorizer() is broken, signing isn't required for custom authorizers, yet it enforces it.

Expected Behavior

Using with_custom_authorizer() with only the authorizer_name, token_key_name, and token_value successfully builds a configuration.

Current Behavior

Using with_custom_authorizer() with only the authorizer_name, token_key_name, and token_value throws error Signing-based custom authentication requires all token-related properties to be set.

Reproduction Steps

const { iot } = require('aws-crt');
iot.AwsIotMqttConnectionConfigBuilder.new_default_builder()
    .with_custom_authorizer(null, 'test-authorizer', null, null, 'x-api-key', '1234')
    .build();

Possible Solution

Change

if (is_string_and_not_empty(input_signature) || is_string_and_not_empty(input_token_value) || is_string_and_not_empty(input_token_key_name)) {
if (!input_token_value || !input_token_key_name || !input_signature) {
throw new Error("Signing-based custom authentication requires all token-related properties to be set");
}
}
if (is_string_and_not_empty(input_signature) && input_signature) {
username_string = add_to_username_parameter(username_string, input_signature, "x-amz-customauthorizer-signature=");
}
to

 if (is_string_and_not_empty(input_signature) && input_signature) { 
     if (!is_string_and_not_empty(input_token_value) || !is_string_and_not_empty(input_token_key_name)) {
         throw new Error("Signing-based custom authentication requires all token-related properties to be set"); 
     }
     username_string = add_to_username_parameter(username_string, input_signature, "x-amz-customauthorizer-signature="); 
 } 

Additional Information/Context

No response

aws-crt-nodejs version used

1.21.0

nodejs version used

v20.10.0

Operating System and version

Ubuntu 22.04.3 LTS

Metadata

Metadata

Assignees

No one assigned

    Labels

    CRT/IoTfeature-requestA feature should be added or improved.p3This is a minor priority issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions