473,624 Members | 2,264 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Insert into instead of add to the HttpModules pipeline

Hi,

We are writing a Web SSO service for all of our websites through Forms
Authentication. We also want to provide our websites with the ability to
protect different parts of their website and redirect to different
registration pages. We are also required to centrally audit authorization
failures to a database only the Web SSO people can see.

We are using .NET 2.0 but need solutions that will use the same code run on
our clients either under 2.0 or 1.1.

We are hoping that sometime in the future ADFS 2+ or another vendor will
provide this functionality but in the meantime the show must go on.
Therefore, our solution is to balance business requirements with simplicity.

The current approach for authorization is to have an HttpModule listen for
Response status 401 on EndRequest. Then we can do some calls to get the
registration page and do the audit.

We are looking for an effecient way for our consuming web apps to hook up
our module.

In .NET 1.1 it looks pretty straight forward. We would have each consuming
web app modify their web.config as follows:
<httpModules>
<remove name="FormsAuth entication" />
<add name="WebSSOAut horization"
type="WebSSOAut horizationModul e, MyApp11"/>
<add name="FormsAuth entication"
type="System.We b.Security.Form sAuthentication Module" />
</httpModules>
In .NET 2.0, this does not appear to be the case. This is what we need to do
to get it to work in a consuming .NET 2.0 web app's web.config:
<httpModules>
<clear />
<add name="OutputCac he" type="System.We b.Caching.Outpu tCacheModule" />
<add name="Session" type="System.We b.SessionState. SessionStateMod ule" />
<add name="WindowsAu thentication"
type="System.We b.Security.Wind owsAuthenticati onModule" />
<add name="WebSSOAut horization" type="WebSSOAut horizationModul e"/>
<add name="FormsAuth entication"
type="System.We b.Security.Form sAuthentication Module" />
<add name="PassportA uthentication"
type="System.We b.Security.Pass portAuthenticat ionModule" />
<add name="RoleManag er" type="System.We b.Security.Role ManagerModule" />
<add name="UrlAuthor ization"
type="System.We b.Security.UrlA uthorizationMod ule" />
<add name="FileAutho rization"
type="System.We b.Security.File AuthorizationMo dule" />
<add name="Anonymous Identification"
type="System.We b.Security.Anon ymousIdentifica tionModule" />
<add name="Profile" type="System.We b.Profile.Profi leModule" />
<add name="ErrorHand lerModule"
type="System.We b.Mobile.ErrorH andlerModule, System.Web.Mobi le,
Version=2.0.0.0 , Culture=neutral , PublicKeyToken= b03f5f7f11d50a3 a" />
<add name="ServiceMo del"
type="System.Se rviceModel.Acti vation.HttpModu le, System.ServiceM odel,
Version=3.0.0.0 , Culture=neutral , PublicKeyToken= b77a5c561934e08 9" />
</httpModules>

Hardcopying this down into each client's web.config during development is
just not practical. No one has any ideo over time what will be installed on
the web servers and modify the server's httpModules list.

Ideally, the client could just add our handler and then our handler could
reorder itself in the modules list at runtime on its Init so it fires before
FormsAuthentica tion. Is this possible?

If not, then would a solution be to put our Module into the server's
web.config? I think that part of that solution would have to be us defining a
configSection so that only the apps that want that module to fire would have
to explicitly turn it on (just like .NET was designed with <authenticati on
mode="Forms">).

Thanks.
Mar 9 '07 #1
3 2126
Hello Noremac,

From your description, I understand you've developed a custom httpmodule
for providing SSO service in your ASP.NET web applications, you used to use
some simple configuration settings in application web.config file to
register your custom module, however, you found that you need much more
cofiguration elements in ASP.NET 2.0 application's web.config. So you're
wondering whether there is any more elegant means to do this, correct?

Based on my research, ASP.NET 2.0 has added many new built-in httpmodules,
and the "RoleManage r" module is a new module which also related to forms
authentication and authorization. You can try reordering all the following
modules(put after your custom module) in application's web.config file to
see whether it helps:

"FormsAuthentic ation"
"RoleManage r"
"UrlAuthorizati on"
Also, in .NET 2.0, it provide a set of configuration API that can help us
manage the application(or machine level) configuration in code. For
example, here is a test page which use web configuration API to insert a
custom httpModule before the "FormsAuthentic ation" module:

=============== =
public partial class _Default : System.Web.UI.P age
{
protected void Page_Load(objec t sender, EventArgs e)
{
Response.Write( "<br/>current user: " + Environment.Use rName);

}
protected void btnButton_Click (object sender, EventArgs e)
{
Configuration config =
WebConfiguratio nManager.OpenWe bConfiguration( Request.Applica tionPath);

HttpModulesSect ion section =
config.SectionG roups["system.web "].Sections["httpModule s"] as
HttpModulesSect ion;

if (section != null)
{
Response.Write( "<br/>section: " + section);

ConfigurationEl ement[] modules = new
ConfigurationEl ement[section.Modules .Count];
section.Modules .CopyTo(modules , 0);

List<Configurat ionElementnewmo dules = new
List<Configurat ionElement>();

foreach (ConfigurationE lement elm in modules)
{
Response.Write( "<br/>" +
elm.ElementInfo rmation.Propert ies["name"].Value);

if (elm.ElementInf ormation.Proper ties["name"].Value.Equals(
"FormsAuthentic ation"))
{
Response.Write( "<br/>insert my module here");
HttpModuleActio n mymodule = new
HttpModuleActio n("mymodule", "simpleModule") ;

newmodules.Add( mymodule);

}

newmodules.Add( elm);
}
section.Modules .Clear();
foreach (ConfigurationE lement elm in newmodules)
{
Response.Write( "<br/>new module: " +
elm.ElementInfo rmation.Propert ies["name"].Value);
section.Modules .Add((HttpModul eAction)elm);
}

config.Save(Con figurationSaveM ode.Modified);

}

}
}
=============== =========

Here are some MSDN reference introducing the new web configuration API:

http://msdn2.microsoft.com/en-us/lib...60(vs.80).aspx

http://msdn2.microsoft.com/en-us/library/ms178687.aspx

Hope this helps some.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

=============== =============== =============== =====

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 12 '07 #2
Those are both good suggestions. Just reordering those three modules seem to
work. Re-writing the config file at runtime seems mighty tempting but I tried
to put it into an "Init" HttpModule and I got errors saving the config file
even with ASPNET having read/write.

It looks like the solution with the most elegance (i.e. less client-app
change) is to insert this handler in the machine's web.config and let each
app turn it on through a definition in their own web.config. I plan on adding
a config section to my HttpModule.

For 1.1, I think we may as well be consistent and add it into the
machine.config. Although I will have to figure out naming, etc since the code
needs to be compiled in both 1.1 and 2.0.

As always, thanks again for your help.

"Steven Cheng[MSFT]" wrote:
Hello Noremac,

From your description, I understand you've developed a custom httpmodule
for providing SSO service in your ASP.NET web applications, you used to use
some simple configuration settings in application web.config file to
register your custom module, however, you found that you need much more
cofiguration elements in ASP.NET 2.0 application's web.config. So you're
wondering whether there is any more elegant means to do this, correct?

Based on my research, ASP.NET 2.0 has added many new built-in httpmodules,
and the "RoleManage r" module is a new module which also related to forms
authentication and authorization. You can try reordering all the following
modules(put after your custom module) in application's web.config file to
see whether it helps:

"FormsAuthentic ation"
"RoleManage r"
"UrlAuthorizati on"
Also, in .NET 2.0, it provide a set of configuration API that can help us
manage the application(or machine level) configuration in code. For
example, here is a test page which use web configuration API to insert a
custom httpModule before the "FormsAuthentic ation" module:

=============== =
public partial class _Default : System.Web.UI.P age
{
protected void Page_Load(objec t sender, EventArgs e)
{
Response.Write( "<br/>current user: " + Environment.Use rName);

}
protected void btnButton_Click (object sender, EventArgs e)
{
Configuration config =
WebConfiguratio nManager.OpenWe bConfiguration( Request.Applica tionPath);

HttpModulesSect ion section =
config.SectionG roups["system.web "].Sections["httpModule s"] as
HttpModulesSect ion;

if (section != null)
{
Response.Write( "<br/>section: " + section);

ConfigurationEl ement[] modules = new
ConfigurationEl ement[section.Modules .Count];
section.Modules .CopyTo(modules , 0);

List<Configurat ionElementnewmo dules = new
List<Configurat ionElement>();

foreach (ConfigurationE lement elm in modules)
{
Response.Write( "<br/>" +
elm.ElementInfo rmation.Propert ies["name"].Value);

if (elm.ElementInf ormation.Proper ties["name"].Value.Equals(
"FormsAuthentic ation"))
{
Response.Write( "<br/>insert my module here");
HttpModuleActio n mymodule = new
HttpModuleActio n("mymodule", "simpleModule") ;

newmodules.Add( mymodule);

}

newmodules.Add( elm);
}
section.Modules .Clear();
foreach (ConfigurationE lement elm in newmodules)
{
Response.Write( "<br/>new module: " +
elm.ElementInfo rmation.Propert ies["name"].Value);
section.Modules .Add((HttpModul eAction)elm);
}

config.Save(Con figurationSaveM ode.Modified);

}

}
}
=============== =========

Here are some MSDN reference introducing the new web configuration API:

http://msdn2.microsoft.com/en-us/lib...60(vs.80).aspx

http://msdn2.microsoft.com/en-us/library/ms178687.aspx

Hope this helps some.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

=============== =============== =============== =====

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 13 '07 #3
Thanks for your reply Noremac,

I think your further consideration is comprehensive. If you have any
further questions or anything we can help later, please feel free to post
here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
Mar 14 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1902
by: Microsoft | last post by:
Hi All. We currently use the Microsoft Commerce Server pipeline component to run the workflow for our application, however this is very limited when it comes to ASP.NET and has no programmable interface so that we can make a web interface to changing the workflow. With the pipeline editor you can add components and vb script files and then execute the component, I think this uses iDispatch so that an object is passed to the pipeline and...
1
1145
by: Craig Neuwirt | last post by:
I have 2 HttpModules in my app. I use CallContext to set some thread specific info. Recently, I ran into a problem in which it appeared that the 2 HttpModules were executed in multiple threads. Is this possible in the HTTP Pipeline. I realize that using CallContext is not recommended, but is it forbidden? thanks, craig
11
1550
by: Markus Kling | last post by:
Hi, I have a web application that has two sub-applications. The root application defines two httpModules which shall not be loaded for the subapplications. I tried to achieve this by adding <httpmodules> <clear /> </httpmodules>
0
1167
by: tshad | last post by:
I noticed in my Http modules that all the BeginRequests are handled for each Module before the EndRequests is handled (at least that seems to be the case). I have 2 HttpModules each with BeginRequests and EndRequests. <httpModules> <add type="NFission.WebControls.ScrollKeeperModule,NFission.WebControls.ScrollKeeper" name="ScollKeeperModule" />
1
3289
by: Anonieko | last post by:
Global.asax? Use HttpModules Instead! In a previous post, I talked about HttpHandlers - an underused but incredibly useful feature of ASP.NET. Today I want to talk about HttpModules, which are probably more common than HttpHandlers, but could still stand to be advertised a bit more. HttpModules are incredibly easy to explain, so this will hopefully be a short-ish post. Simply put, HttpModules are portable versions of the global.asax....
1
1920
by: Asela Gunawardena | last post by:
Hi all, we have a webservice as a seperate virtual directory placed under a Web Site named GRSCS in IIS. Both are .NET applications and uses MS application blocks as the data layer. Recently an http module was included in the root site which is GRSCS and the webservice has not functioned ever since. the service starts working when u comment the httpmodule section in the web.config file of the main (root application) which is GRSCS. Is...
1
3195
by: Samuel R. Neff | last post by:
We have a problem with Web.config inheritance in two of our applications. We have an old app which is poorly written and must be in the root of the server. We have a newer app which runs from a virtual directory. The apps are not related. Old app web.config has: <httpModules> <add name="a" type="foo.a, foo" /> <add name="b" type="bar.b, bar" />
6
10960
by: eighthman11 | last post by:
Hi everyone: Using Sql Server SQL 8 I'm trying to INSERT records into a "can software package" batch table. I have a work-table that mimics the batch table. After manipulating the records in the work-file I want to INSERT them into the batch table. The problem is the batch table in the can software has a trigger on the batch table which is going to force me to INSERT one record at a
5
2434
by: =?Utf-8?B?TUNN?= | last post by:
What do the following httpModules do? UrlAuthorization FileAuthorization ServiceModel ErrorHandlerModule ScriptModule
0
8233
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8170
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8675
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8619
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8334
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8474
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7158
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6108
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4078
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.