views:

43

answers:

2

Ultimate goal is to provide protection against programming mistakes. I want to make sure that every page in a portion of my web application has a role specified like below. Ideally I would like to programatically check all requests coming in ( think IHttpModule ) and make sure that the page being requested has a role specified.

I can't seem to find how to get programatic access to the allowed roles.

<location path="foo.aspx">
 <system.web>
  <authorization>
   <allow roles="modifier"/>
  </authorization>
 </system.web>
</location>
A: 

make a deny * in the root, so every page is not allowed, until it is explicitly activated....

cRichter
thought about that, but was hoping to give a more useful message. Especially since this is a slightly non-standard configuration requirement.
Zac
you can also parse the web.config and check the aspx files in the folder. or execute your check at the OnBeginRequest event in the global asax.the right thing would be to do this bevore rollout. :-) but you will miss web.config that are placed in subfolders.
cRichter
A: 

Stumbled across this AuthorizationRuleCollection.

From MSDN, I've not tried it as I solved my problem using a tecnique similar to the AuthorizeAttribute in the MVC framework.

System.Configuration.Configuration configuration = WebConfigurationManager.OpenWebConfiguration("/aspnetTest");
AuthorizationSection authorizationSection = (AuthorizationSection)configuration.GetSection("system.web/authorization");
Zac