# Terminate library connection from httpAdminMiddleware

**URL:** <https://discourse.nodered.org/t/terminate-library-connection-from-httpadminmiddleware/71825>\
**Category:** General\
**Tags:** security\
**Created:** [7 December 2022 15:16 UTC](https://discourse.nodered.org/t/terminate-library-connection-from-httpadminmiddleware/71825 "2022-12-07T15:16:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mw75](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mw75/32/52490_2.png) [@mw75](https://discourse.nodered.org/u/mw75)\
**Post date:** [7 December 2022 15:16 UTC](https://discourse.nodered.org/t/terminate-library-connection-from-httpadminmiddleware/71825/1 "2022-12-07T15:16:24Z")

</div>

Hi community,

i've connected node-red to an OIDC provider and assign permissions by mapping roles to the username. I have two roles: flow-admin and flow-designer. They only differ in the capability of reading and writing one particular library.

As the library has no access (as far as i found out) to user, session, request or response objects i need to handle the library permission in settings.httpAdminMiddleware.

I get the library from req.url, the current token from req.rawHeaders, sessions from the storage class and the method from req.method. For reading i can terminate by writing an empty object as json with res.write and res.status(200).end(). That all works as expected.

To deny write access i would like to terminate with an "Permission denied" message and a status code of 400 to let the frontend show the message - just like the core when the library has no saveEntry method. But when i quit with res.status(400).end() the response on the client is still 200 and the frontend displays a successful write message.

Any hint is appreciated!

Thanks and regards,  
Mario

---

<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:** [5 February 2023 15:17 UTC](https://discourse.nodered.org/t/terminate-library-connection-from-httpadminmiddleware/71825/2 "2023-02-05T15:17:20Z")

</div>

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