Intercept requests for iisnode with HttpModule

孤者浪人 提交于 2019-12-13 04:07:03

问题


I have a nodejs app running using iisnode in a sub directory for a .net application (umbraco actually).

The .net application is using forms authentication and I want to secure the iisnode application using the same mechanism as the .net application.

I've tried registering modules with the iisnode app but it doesn't even seem to fire the event handlers. Is it possible to do this?


回答1:


It seems that creating an HttpModule to intercept nodejs requests is impossible. However, I did find a way to get the authentication information I was after.

I created some middleware in my nodejs (expressjs) app that picks up the headers from the request (including the cookies) and make a request to a specially created url on the asp.net application using those same headers.

This url simply returns the user info for the user specified in the cookie (if the cookie is present). If I get back some information then I know the user is logged in. No information means they are not logged in and I redirect to the umbraco login page.



来源:https://stackoverflow.com/questions/13165404/intercept-requests-for-iisnode-with-httpmodule

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!