eclipse-thingweb / eclipse-thingweb/node-wot

Credentials are not validated

Open
#383 2 comments 1 reaction 0 assignees View on GitHub
core
Dominant language
TypeScript
Stars
192
Forks
100
Avg merge
3d 2h
Merged PRs (30d)
6

Description

If someone writes the following code:
```js
let servient = new Servient();

servient.addClientFactory(new HttpsClientFactory(httpConfig));
servient.addCredentials(
{
"urn:dev:ops:32473-sensehat-003": {
"username": "USERNAME",
"pasword": "PASSWORD" // look here
}
});
```

in the mentioned line, there is `pasword` instead of `password`. Until a WoT operation is done, no error is shown. When the error finally shows up, it is like the following:

```
Error: No Basic credentials for Thing
at new BasicCredential (/home/me/Downloads/test/node_modules/@node-wot/binding-http/dist/credential.js:68:19)
at HttpClient.setSecurity (/home/me/Downloads/test/node_modules/@node-wot/binding-http/dist/http-client.js:209:35)
at Object.ConsumedThing.ensureClientSecurity (/home/me/Downloads/test/node_modules/@node-wot/core/dist/consumed-thing.js:100:20)
at Object.ConsumedThing.getClientFor (/home/me/Downloads/test/node_modules/@node-wot/core/dist/consumed-thing.js:146:22)
at /home/me/Downloads/test/node_modules/@node-wot/core/dist/consumed-thing.js:161:32
at new Promise ()
at Object.ConsumedThing.readProperty (/home/me/Downloads/test/node_modules/@node-wot/core/dist/consumed-thing.js:155:16)
```

So it is clear that something is wrong with credentials but the error is not specific or even misleading, i.e. making me think that my password is wrong. I had to debug to find this mistake since it is silly but hard to spot. When the credentials are added, everything works perfectly and when they are retrieved, the password is undefined and thus bad credentials.

Environment: Linux
node-wot version: 0.7.4 but valid for all probably

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.