awslabs / awslabs/aws-crt-nodejs

IoT unsigned custom authentication builder broken

Open
#527 10 comments 0 reactions 0 assignees View on GitHub
CRT/IoT feature-request p3
Dominant language
TypeScript
Stars
43
Forks
32
Avg merge
1d 17h
Merged PRs (30d)
1

Description

### 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

```js
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 https://github.com/awslabs/aws-crt-nodejs/blob/d1729bf773912f0b3e2dfbec9f18d5a3b973a8e5/lib/common/aws_iot_shared.ts#L85-L93 to
```js
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

Contributor guide

Open the contributing guide

Research direction

Start in lib/common/aws_iot_shared.ts at lines 85-93, following AwsIotMqttConnectionConfigBuilder.with_custom_authorizer(). Reproduce the issue with the Node.js example and verify that a configuration using only the authorizer name, token key name, and token value builds successfully without signing-related properties.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, nodejs, typescript
Domain
cloud, embedded-iot
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.