# Basic auth for dashboard 2 It stops working

**URL:** https://discourse.nodered.org/t/basic-auth-for-dashboard-2-it-stops-working/95538
**Category:** Dashboard
**Tags:** security, dashboard-2
**Created:** [20 February 2025 16:13 UTC](https://discourse.nodered.org/t/basic-auth-for-dashboard-2-it-stops-working/95538 "2025-02-20T16:13:53Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Pepex7](https://avatars.discourse-cdn.com/v4/letter/p/a88e57/32.png) [@Pepex7](https://discourse.nodered.org/u/Pepex7)
#### Post date: [20 February 2025 16:13 UTC](https://discourse.nodered.org/t/basic-auth-for-dashboard-2-it-stops-working/95538/1 "2025-02-20T16:13:53Z")

</div>

I'm using basic auth for dashboard 2 (@aikitori/node-red-dashboard-2-basic-auth)

 ![Captura de Pantalla 2025-02-20 a la(s) 13.10.49](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/1/d161d77a2f4fde5ce1b74045570ccf592de7e18a.png)

but when I restart the server it stops working.

 ![Captura de Pantalla 2025-02-20 a la(s) 11.30.30](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/e/ee1042b7b7f4f888a2d7d463b0d21292a6ad6015.png)

in the console it says:  
node-red-dashboard-2-basic-auth: Dashboard interacted with by user1

but in the debug it does not show the user.  
If I remove and reinstall node, it works again.

What could it be?

---

<div class="post-metadata">

### Author: ![joepavitt](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/joepavitt/32/59722_2.png) [@joepavitt](https://discourse.nodered.org/u/joepavitt)
#### Post date: [21 February 2025 09:08 UTC](https://discourse.nodered.org/t/basic-auth-for-dashboard-2-it-stops-working/95538/2 "2025-02-21T09:08:15Z")

</div>

I suspect this may be a difference between the maintenance of the server/client sessions. When you restart your server, the authentication session should be lost, so I would expect the `undefined`.

As for the log you're seeing, I can't explain that off the top of my head. I'd expect you to be prompted again for authentication

---

<div class="post-metadata">

### Author: ![kitori](https://avatars.discourse-cdn.com/v4/letter/k/f08c70/32.png) [@kitori](https://discourse.nodered.org/u/kitori)
#### Post date: [21 February 2025 10:27 UTC](https://discourse.nodered.org/t/basic-auth-for-dashboard-2-it-stops-working/95538/3 "2025-02-21T10:27:24Z")

</div>

What do you do when you _restart the server_ ?

Restart the System(Webserver/Node-red): `sudo systemctl reboot`  
Restart the webserver: `sudo systemctl restart nginx.service`  
Restart node-red: `sudo systemctl restart nodered.service`

---

<div class="post-metadata">

### Author: ![Pepex7](https://avatars.discourse-cdn.com/v4/letter/p/a88e57/32.png) [@Pepex7](https://discourse.nodered.org/u/Pepex7)
#### Post date: [21 February 2025 14:10 UTC](https://discourse.nodered.org/t/basic-auth-for-dashboard-2-it-stops-working/95538/4 "2025-02-21T14:10:29Z")

</div>

> [@joepavitt](#):
>
> I suspect this may be a difference between the maintenance of the server/client sessions. When you restart your server, the authentication session should be lost, so I would expect the `undefined`.
> 
> As for the log you're seeing, I can't explain that off the top of my head. I'd expect you to be prompted again for authentication

It asks me again to enter username and password but it no longer shows it in the debug

---

<div class="post-metadata">

### Author: ![Pepex7](https://avatars.discourse-cdn.com/v4/letter/p/a88e57/32.png) [@Pepex7](https://discourse.nodered.org/u/Pepex7)
#### Post date: [21 February 2025 14:11 UTC](https://discourse.nodered.org/t/basic-auth-for-dashboard-2-it-stops-working/95538/5 "2025-02-21T14:11:18Z")

</div>

sudo reboot

(Debían 12)

---

<div class="post-metadata">

### Author: ![joepavitt](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/joepavitt/32/59722_2.png) [@joepavitt](https://discourse.nodered.org/u/joepavitt)
#### Post date: [21 February 2025 14:23 UTC](https://discourse.nodered.org/t/basic-auth-for-dashboard-2-it-stops-working/95538/6 "2025-02-21T14:23:19Z")

</div>

So, to sanity check please, the steps you have taken:

1. Navigate to Dashboard
2. See prompt for authentication
3. Authenticate & redirect to Dashboard
4. See the output in Node-RED with the correct user assigned
5. Restart the Node-RED Server
6. Navigate to Dashboard
7. See prompt for authentication
8. Successfully login and redirect to Dashboard
9. See the output in Node-RED, but without any associated `user` object

---

<div class="post-metadata">

### Author: ![Pepex7](https://avatars.discourse-cdn.com/v4/letter/p/a88e57/32.png) [@Pepex7](https://discourse.nodered.org/u/Pepex7)
#### Post date: [21 February 2025 15:22 UTC](https://discourse.nodered.org/t/basic-auth-for-dashboard-2-it-stops-working/95538/7 "2025-02-21T15:22:43Z")

</div>

Thank you for you reply and help.  
That's right, I've done the steps again and the same thing happens.  
Just to say that my address is to the editor, I have to adjust my nginx to redirect to the dashboard, but I still can't do it. If I enter directly to the dashboard 192.168.130.12:1880/dashboard/page1 it doesn't ask me for authentication and the console says:

```auto
node-red-dashboard-2-basic-auth: Session is not authenticated by Basic Auth; no user detected.

```

 ![Captura de Pantalla 2025-02-21 a la(s) 11.54.07](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/e/be1e24e1581f4fd24cf1a78cd4bce2f3581c5824.png)

my config nginx

```auto
server {
        listen 80;
        listen [::]:80;
        server_name 192.168.130.12;

        location / {
                auth_basic "Dashboard";
                auth_basic_user_file /etc/nginx/htpasswd;
                proxy_set_header X-Forwarded-User $remote_user;
                proxy_pass http://192.168.130.12:1880;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                # try_files $uri $uri/ =404;
        }

```

debug before restart:

 ![Captura de Pantalla 2025-02-21 a la(s) 12.08.40](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/a/6a34a5f30240317fe5e185d538cc3f31ee02d359.png)

debug after restart:

 ![Captura de Pantalla 2025-02-21 a la(s) 12.21.12](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/5/652ac8546678d80b3eb6b2932af9cd50cefb1db0.png)

---

<div class="post-metadata">

### Author: ![Pepex7](https://avatars.discourse-cdn.com/v4/letter/p/a88e57/32.png) [@Pepex7](https://discourse.nodered.org/u/Pepex7)
#### Post date: [21 February 2025 22:41 UTC](https://discourse.nodered.org/t/basic-auth-for-dashboard-2-it-stops-working/95538/8 "2025-02-21T22:41:18Z")

</div>

After further testing and checking, it seems that there was some conflict with flowfuse/node-red-dashboard-2-user-addon. I had both installed, uninstalled it and tested again and now it works after rebooting.

Thank You..!!

---

<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: [23 March 2025 22:42 UTC](https://discourse.nodered.org/t/basic-auth-for-dashboard-2-it-stops-working/95538/9 "2025-03-23T22:42:12Z")

</div>

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