bestlong / node-red-contrib-mssql-plus

A Node-RED node to read and write to Microsoft MS SQL Databases
MIT License
31 stars 18 forks source link

Credentials via Environment-Variable #15

Closed wolli-lenzen closed 4 years ago

wolli-lenzen commented 4 years ago

In Node documentation you write "You can use environment variables in any connection field, using mustache format."

This works fine for connection information stored in flow.json but not for user and password.

My unencrypted flows_cred.json looks like {"7cd6f15f.369f7":{"username":"{{{DB_USER}}}","password":"{{{DB_PASSWORD}}}"}}

When trying to connect, I get the following errormessage: Error connecting to server : 172.16.3.164, database : ASP, port : 1433, user : {{{DB_USER}}}

So it looks like there is no mustache token replacement for credentials. Values for server, database and port are set correctly via env.

wolli-lenzen commented 4 years ago

as far as I can see in the code, you do the mustache.render only on config values but not on node.credentials.xxx

That´s quite inconsistent, because if I deploy a flow as microservice in a container-environment, it should be possible to configure the microservice via ENV.

mrauter commented 4 years ago

@wolli-lenzen I have added a pull request for this issue. But it is already possible to use the default environment variable support (https://nodered.org/docs/user-guide/environment-variables). Example: ${DB_USER}. Mustache is only needed if you want to concat strings.