# Web Page Authentication

**URL:** https://discourse.nodered.org/t/web-page-authentication/32945
**Category:** Developing Nodes
**Created:** [16 September 2020 07:30 UTC](https://discourse.nodered.org/t/web-page-authentication/32945 "2020-09-16T07:30:37Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Devbrat](https://avatars.discourse-cdn.com/v4/letter/d/a183cd/32.png) [@Devbrat](https://discourse.nodered.org/u/Devbrat)
#### Post date: [16 September 2020 07:30 UTC](https://discourse.nodered.org/t/web-page-authentication/32945/1 "2020-09-16T07:30:38Z")

</div>

Hi All,

I am trying to implement authentication in my web page created in my node.

Created below get API based in node to work only if user has logged-in in node-red **or** opening from the link which is availatble on config page of my node.

```auto
RED.httpAdmin.get('/mynode/web/', RED.auth.needsPermission('mynode.CMD.write'), function(req, res) {
    res.render('somefile.html');
});

```

URl in config

```auto
<a href="/mynode/web/" target="_blank"></a>

```

But I am getting **Unauthorized** message after opening even though user has logged-in in node-red.

Can anyone tell me how to achieve this from node-red default authentication?

---

<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: [16 September 2020 07:46 UTC](https://discourse.nodered.org/t/web-page-authentication/32945/2 "2020-09-16T07:46:50Z")

</div>

Hi @Devbrat

the authentication mechanism uses a custom http header to provide the authentication token. There is code in the editor that ensures that token is attached to any request sent back to the runtime.

But that means it only works for requests sent by the editor. You cannot use this to protect other pages - as the browser won't know to include the authentication token when opening the page.

I'm currently looking at moving the editor to use a more traditional cookie-based method of providing the auth token due to an issue that was recently raised and that would also help you here. I don't know if that'll happen in the 1.2 timeframe or not.

---

<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: [15 November 2020 07:46 UTC](https://discourse.nodered.org/t/web-page-authentication/32945/3 "2020-11-15T07:46:59Z")

</div>

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