# Optional admin authentication

**URL:** <https://discourse.nodered.org/t/optional-admin-authentication/60144>\
**Category:** General\
**Created:** [21 March 2022 12:01 UTC](https://discourse.nodered.org/t/optional-admin-authentication/60144 "2022-03-21T12:01:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![DJDev](https://avatars.discourse-cdn.com/v4/letter/d/59ef9b/32.png) [@DJDev](https://discourse.nodered.org/u/DJDev)\
**Post date:** [21 March 2022 12:01 UTC](https://discourse.nodered.org/t/optional-admin-authentication/60144/1 "2022-03-21T12:01:24Z")

</div>

Hi,

I have a question regarding the adminauth option in the settingsfile.js. I need multiple nodered instances running. The settings.js is aside from some configurable settings fairly similar for each environment. But some of the environments need oauth authentication using the adminauth setting and some don't. I hope I can cover this scenario using a single settings file.  
Is it possible to activate\deactivate the adminauth somehow? I tried to use setting httpAdminRoot, but setting this setting to false did not enable to open the regular node red page if setting adminauth is configured.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [21 March 2022 12:05 UTC](https://discourse.nodered.org/t/optional-admin-authentication/60144/2 "2022-03-21T12:05:25Z")

</div>

As the settings file is a JavaScript file, you can build whatever logic you want in it to programmatically set `adminAuth`, or leave it unset.

The following pseudo-code shows the sort of thing you could do. This assumes that within the code you can provide some way of knowing which environment you are running in:

```auto
// Default is adminAuth to be left undefined
let myAdminAuth;
if (environmentA) {
   myAdminAuth = { ... }
} else if (environmentB) {
   myAdminAuth = { ... }
}

module.exports = {
   // ...
   adminAuth: myAdminAuth
   // ...
}

```

---

<div class="post-metadata">

**Author:** ![DJDev](https://avatars.discourse-cdn.com/v4/letter/d/59ef9b/32.png) [@DJDev](https://discourse.nodered.org/u/DJDev)\
**Post date:** [21 March 2022 13:09 UTC](https://discourse.nodered.org/t/optional-admin-authentication/60144/3 "2022-03-21T13:09:08Z")

</div>

Hi Nick,

Thanks for the answer. I will try that.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [20 May 2022 11:52 UTC](https://discourse.nodered.org/t/optional-admin-authentication/60144/4 "2022-05-20T11:52:44Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
