An HTTPModule for IIS to allow the username of the currently authenticated user to be passed to a downstream server when IIS is running as a reverse proxy of URL rewriter
Clone the project, open in Visual Studio and build using the normal Visual Studio building process
To install this module in II7 (in pipeline mode) or above:
- Copy UsernamePassingModule.dll from output directory (debug/bin or release/bin) to the bin directory of the IIS site you're wanting to pass a username from
- Add a Web.config, or update your existing Web.config in the root of your site, so it contains a
system.WebServerelement, containing a modules element, with an add entry for the UsernamePassingModule, similar to:
<configuration>
<system.webServer>
<modules>
<add name="Username" type="UsernamePassingModule.UsernamePassingModule"/>
</modules>
</system.webServer>
</configuration>
It is possible to pass additional parameters to this module using a custom config setion:
- If your Web.xml does not already contain a
configSectionselement then add one as a sub-element of the rootconfigurationelement of your Web.xml - Add a
sectionelement to thisconfigSectionselement, with a parameter namednameand with the value ofusernamePassingModule, and with a second attributed namedtypeand with a value ofSystem.Configuration.NameValueSectionHandler - Add a
usernamePassingModuleelement to the rootconfigurationelement - Add an
addelement as a child of theusernamePaddingModuleelement for each configuration element you want to pass, e.g. to configure the name used in the HTTP header add anaddelement with a paremeter namedkeyand with the value ofheaderName, and a second parameter with the namevalueand the value set to the name you want the header sent under. This value must be valid for an HTTP header name: containing only Alphanumeric characters, potentially seperated by hyphens.
To setup the module to pass the username header under the name 'Authenticated-User', you Web.config needs to look similar to following:
<configuration>
<configSections>
<section name="usernamePassingModule" type="System.Configuration.NameValueSectionHandler" />
</configSections>
<system.webServer>
<modules>
<add name="Username" type="UsernamePassingModule.UsernamePassingModule"/>
</modules>
</system.webServer>
<usernamePassingModule>
<add key="headerName" value="Authenticated-User"/>
</usernamePassingModule>
</configuration>