# How do I dynamically change httpNodeAuth externally (setting.js)

**URL:** <https://discourse.nodered.org/t/how-do-i-dynamically-change-httpnodeauth-externally-setting-js/54665>\
**Category:** General\
**Created:** [3 December 2021 11:44 UTC](https://discourse.nodered.org/t/how-do-i-dynamically-change-httpnodeauth-externally-setting-js/54665 "2021-12-03T11:44:57Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![sercancetin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sercancetin/32/50083_2.png) [@sercancetin](https://discourse.nodered.org/u/sercancetin)\
**Post date:** [3 December 2021 11:44 UTC](https://discourse.nodered.org/t/how-do-i-dynamically-change-httpnodeauth-externally-setting-js/54665/1 "2021-12-03T11:44:57Z")

</div>

Hello to everyone.

How do I dynamically change httpNodeAuth externally (setting.js). The scenario is: The customer will edit the setting.js file via the form on the browser without manually changing it. Maybe it has nothing to do with node-red, but I'm new to node.js. I need every opinion. Thank you for your help.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [3 December 2021 11:53 UTC](https://discourse.nodered.org/t/how-do-i-dynamically-change-httpnodeauth-externally-setting-js/54665/2 "2021-12-03T11:53:53Z")

</div>

Once you make a change to settings.js, you will have to restart Node-RED.

Rather than directly changing settings.js, it would probably be better to use one or more external modules. That way, you can limit the changes to just those files. Either way, a restart is needed after a change except for the properties that allow dynamic functions.

It would help if you shared exactly what properties you were wanting to change.

---

<div class="post-metadata">

**Author:** ![sercancetin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sercancetin/32/50083_2.png) [@sercancetin](https://discourse.nodered.org/u/sercancetin)\
**Post date:** [3 December 2021 12:42 UTC](https://discourse.nodered.org/t/how-do-i-dynamically-change-httpnodeauth-externally-setting-js/54665/3 "2021-12-03T12:42:08Z")

</div>

My goal is to read the httpNodeAuth part through the form and change it. So dynamically changing the person accessing /ui

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [3 December 2021 13:56 UTC](https://discourse.nodered.org/t/how-do-i-dynamically-change-httpnodeauth-externally-setting-js/54665/4 "2021-12-03T13:56:48Z")

</div>

If you are just interested in security the Dashboard, you might try using the Dashboard middleware function in settings.js. Extracted from one of mine:

```auto
    /** If you installed the optional node-red-dashboard you can set it's path relative to httpNodeRoot
     * Other optional properties include
     * readOnly:{boolean},
     * middleware:{function or array}, (req,res,next) - http middleware
     * ioMiddleware:{function or array}, (socket,next) - socket.io middleware
     */
    //ui: { path: 'ui' },

```

`httpNodeAuth` only gives you fixed basic auth. You can change it by a call to an external module as mentioned previously. However, this is **not** _dynamci_. It is static and you have to restart Node-RED after you change it.

The Dashboard middleware **is** dynamic. The function is called on every HTTP request. Of course, you will need to know how to apply security to HTTP requests or will need to find a suitable library.

* * *

Oh, and don't forget that you _ **MUST** _ be using HTTPS, not plain HTTP for all requests where you want to apply security.

---

<div class="post-metadata">

**Author:** ![sercancetin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sercancetin/32/50083_2.png) [@sercancetin](https://discourse.nodered.org/u/sercancetin)\
**Post date:** [6 December 2021 07:43 UTC](https://discourse.nodered.org/t/how-do-i-dynamically-change-httpnodeauth-externally-setting-js/54665/5 "2021-12-06T07:43:24Z")

</div>

Thank you for your interest.

---

<div class="post-metadata">

**Author:** ![aderici](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/aderici/32/37279_2.png) [@aderici](https://discourse.nodered.org/u/aderici)\
**Post date:** [6 December 2021 10:52 UTC](https://discourse.nodered.org/t/how-do-i-dynamically-change-httpnodeauth-externally-setting-js/54665/6 "2021-12-06T10:52:25Z")

</div>

Hi Sercan. Http node auth doesnt have to be implemented in settings.js. I usually implement it as a part of the flow, usually as a subflow places as the first node after http in. That way you can use a persisted flow variable and have clients change it. You can also do really complex auth like microsoft login etc. hope this helps,

---

<div class="post-metadata">

**Author:** ![sercancetin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sercancetin/32/50083_2.png) [@sercancetin](https://discourse.nodered.org/u/sercancetin)\
**Post date:** [6 December 2021 11:11 UTC](https://discourse.nodered.org/t/how-do-i-dynamically-change-httpnodeauth-externally-setting-js/54665/7 "2021-12-06T11:11:47Z")

</div>

Is there a sample project about the approach you are talking about?

---

<div class="post-metadata">

**Author:** ![aderici](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/aderici/32/37279_2.png) [@aderici](https://discourse.nodered.org/u/aderici)\
**Post date:** [6 December 2021 11:16 UTC](https://discourse.nodered.org/t/how-do-i-dynamically-change-httpnodeauth-externally-setting-js/54665/8 "2021-12-06T11:16:00Z")

</div>

No, but whats stoping you from connecting a function node to http in and develop basic auth there?
