Custom HTTP Module unable to read the HTTP Headers set by SiteMinder in the integrated pipeline mode.
Customer has developed a custom HTTP Module which is expected to read the HTTP Headers set by SiteMinder e.g. SM_USER, SM_USERDN etc. The application pipeline mode is set to integrated.
However, the custom HTTP Module is unable to read any of the HTTP Headers set by SiteMinder module.
Other observations :
- If the application pool is switched to CLASSIC pipeline mode the custom module is able to read the SiteMinder headers.
- Simple dump header aspx/asp page prints all the SiteMinder headers including SM_USER without any issue.
- SiteMinder HTTP module is set on the top of the list in the view ordered pane in IIS Manager
- Web Server OS: Windows 2008 R2/Windows 2012/ Windows 2012 R2
- Web Server : IIS 7.0/ IIS 7.5/ IIS 8.0/ IIS 8.5
- Application Pool : Integrated Pipeline Mode
After having a closer look at the IIS Failed request tracing it was found that the custom HTTP Module was registered for an event at a stage earlier than “AUTHENTICATE_REQUEST” which is where SiteMinder modules sets most of the HTTP headers.
The following tasks are performed by the HttpApplication class (in the order) while the request is being processed in the integrated pipeline mode.
- Validate the request, which examines the information sent by the browser and determines whether it contains potentially malicious markup. For more information, see ValidateRequest and Script Exploits Overview.
- Perform URL mapping, if any URLs have been configured in the UrlMappingsSection section of the Web.config file.
- Raise the BeginRequest event.
- Raise the AuthenticateRequest event.
- Raise the PostAuthenticateRequest event.
- Raise the AuthorizeRequest event.
- Raise the PostAuthorizeRequest event.
- Raise the ResolveRequestCache event.
- Raise the PostResolveRequestCache event.
- Raise the MapRequestHandler event. An appropriate handler is selected based on the file-name extension of the requested resource. The handler can be a native-code module such as the IIS 7.0 StaticFileModule or a managed-code module such as the PageHandlerFactory class (which handles .aspx files).
- Raise the PostMapRequestHandler event.
- Raise the AcquireRequestState event.
- Raise the PostAcquireRequestState event.
- Raise the PreRequestHandlerExecute event.
- Call the ProcessRequest method (or the asynchronous version IHttpAsyncHandler.BeginProcessRequest) of the appropriate IHttpHandler class for the request. For example, if the request is for a page, the current page instance handles the request.
- Raise the PostRequestHandlerExecute event.
- Raise the ReleaseRequestState event.
- Raise the PostReleaseRequestState event.
- Perform response filtering if the Filter property is defined.
- Raise the UpdateRequestCache event.
- Raise the PostUpdateRequestCache event.
- Raise the LogRequest event.
- Raise the PostLogRequest event.
- Raise the EndRequest event.
- Raise the PreSendRequestHeaders event.
- Raise the PreSendRequestContent event.
So obviously, for any custom module to be able to read the HTTP headers set by SiteMinder module in the AUTHENTICATE_REQUEST phase, it has to be registered either at the AUTHENTICATE_REQUEST or any events after it e.g POST_AUTHENTICATE_REQUEST
Modify custom HTTP Module to register and read HTTP request headers set by SiteMinder at the event equal or after AUTHENTICATE_REQUEST.
Note : If there are two Modules subscribed to the same event in the request life-cycle (e.g AUTHENTICATE_REQUEST)..it is still possible to configure the order of the execution of the SiteMinder module by altering the RequestPriority. This has been covered in our bookshelf itself: