问题
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