# How to check if cred encryption is turned off when using projects?

**URL:** <https://discourse.nodered.org/t/how-to-check-if-cred-encryption-is-turned-off-when-using-projects/74014>\
**Category:** Developing Nodes\
**Created:** [21 January 2023 16:04 UTC](https://discourse.nodered.org/t/how-to-check-if-cred-encryption-is-turned-off-when-using-projects/74014 "2023-01-21T16:04:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevinGodell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kevingodell/32/27040_2.png) [@kevinGodell](https://discourse.nodered.org/u/kevinGodell)\
**Post date:** [21 January 2023 16:04 UTC](https://discourse.nodered.org/t/how-to-check-if-cred-encryption-is-turned-off-when-using-projects/74014/1 "2023-01-21T16:04:39Z")

</div>

I am working on a little auth middleware experiment and I want to enforce some settings before enabling the middleware, such as https and cred encryption.

When **not** using projects, I can simply check if **RED.settings.credentialSecret === false** and reasonably assume that the creds are not encrypted due to the explicit setting.

When using projects, I cannot seem to find an api that can give me the info. Of course, I can check for the value manually to see if it is `=== false` wrapped in a try/catch block in case the files don't exist:

```auto
const { projects, activeProject } = require(`${RED.settings.userDir}/.config.projects.json`);

const { credentialSecret } = projects[activeProject];

```

---

<div class="post-metadata">

**Author:** ![kevinGodell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kevingodell/32/27040_2.png) [@kevinGodell](https://discourse.nodered.org/u/kevinGodell)\
**Post date:** [24 January 2023 22:20 UTC](https://discourse.nodered.org/t/how-to-check-if-cred-encryption-is-turned-off-when-using-projects/74014/2 "2023-01-24T22:20:00Z")

</div>

Well, I found a different way using the runtime api. Of course, I would prefer if the project data was already available to the node, but it works just fine.

```auto
module.paths.push(process.env.NODE_RED_HOME);

const runtime = require('node_modules/@node-red/runtime');

runtime.projects.getActiveProject(process.env.USER)
  .then(project => {
    console.log(data.credentialSecret === false);
});

```

Requiring the `node_modules/@node-red` is loosely based on how ralphwetzel does it in [node-red-mcu-plugin/mcu\_plugin.js at main · ralphwetzel/node-red-mcu-plugin · GitHub](https://github.com/ralphwetzel/node-red-mcu-plugin/blob/main/mcu_plugin.js), with the small change of pushing the path for require to find the global libs and then not need another dependency such as `resolve-package-path`.

---

<div class="post-metadata">

**Author:** ![ralphwetzel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ralphwetzel/32/53713_2.png) [@ralphwetzel](https://discourse.nodered.org/u/ralphwetzel)\
**Post date:** [24 January 2023 22:47 UTC](https://discourse.nodered.org/t/how-to-check-if-cred-encryption-is-turned-off-when-using-projects/74014/3 "2023-01-24T22:47:17Z")

</div>

> [@kevinGodell](#):
>
> pushing the path for require to find the global libs

That's a nice move ... 👍

---

<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:** [25 March 2023 22:47 UTC](https://discourse.nodered.org/t/how-to-check-if-cred-encryption-is-turned-off-when-using-projects/74014/4 "2023-03-25T22:47:54Z")

</div>

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