RE: Protecting Web Files from Direct Access

From: William McIlroy (WilliamMcIlroy_at_discussions.microsoft.com)
Date: 02/20/05


Date: Sat, 19 Feb 2005 23:33:03 -0800

Since nobody answered my query, I'll answer it myself. ASP.NET offers
built-in security of a kind. Actually, it offers several kinds, one of which
is useful for deployment on the Internet and the others less so useful. That
kind is attached to the moniker "Forms Authentication." When turned on,
Forms Authentication automatically redirects users who access pages on your
site to a Logon page where they enter a username and password. Code you
write determines whether the combination passes muster. If not, the page
redisplays. The user is free to try again. Otherwise the code behind
creates an authentication token, otherwise known as a "cookie" (we all know
about cookies, not the Oreo variety). Then the code behind uses information
that was passed to it to direct the browser to return to the page that the
user originally requested. Upon reaching that page the token exists and the
user is permitted to view the page. This all works super-swell as long as
every one of the pages has the filename extension ASPX. Pages that have the
filename extension HTML are not protected. I challenge anyone to find that
fact clearly expressed in the relevant KB article or in any of the many
relevant books. Right now, I'm trying to figure out how to rewrite an HTML
page so that it performs the function of the HTML whilst being an ASPX page.
It involves HTML "frames" and such things that are possibly foreign to the
ASPX way of doing things. No doubt there is an alternative, but am I
required to rewire the entire extant application simply to get security?
Yes. No. Maybe? Don't know. And so it goes...

"William McIlroy" wrote:

> I am working on a simple yet large web application that renders static HTML
> files per user request. I wrote an ASPX front end that accepts a userid and
> password combination. It acts as a gatekeeper to the application. The user
> cannot get to the index HTML document from the security check except with a
> valid username and password. However, the user can go directly to the index
> document and, hence the application, if he or she guesses its name or the
> name somehow becomes known. The browser advertises the name when
> Response.Redirect changes the web page. Is there some way to prevent users
> from navigating to pages inside the site without first having to identify
> themselves?
>
> I realize IIS offers several methods of security ranging from none, to using
> Windows authentication to Microsoft Passport. Still, it seems public access
> to application files is an all or nothing affair. I don't want even
> authenticated users to navigate directly to any of the application files.
> The ASPX code could write a cookie that every HTML file could check in a
> script. A helpful sample would be nice.
>
> Is there something I can do to the web.config file to enforce my rules?
>
> Any thoughts?
>
>
> --
> William McIlroy
>



Relevant Pages

  • ASP.NET, role-based security and SecurityPermission.ControlPrincipal
    ... I'm trying to figure out a reasonable security policy for my ASP.NET 1.1 ... securing the authentication chain in ASP.NET forms authentication. ... The COM+ application is configured to runas the account described ... I configure the directory that contains .aspx pages to be writeable only ...
    (microsoft.public.dotnet.security)
  • RE: HTML file server side includes plus forms authentication
    ... For the .html hyperlinks generated by your DLL you write an HTTP Handler ... that does an URL rewrite from .html to .aspx. ... > authentication to control access to particular directories/applications. ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: Protecting Web Files from Direct Access
    ... If you want that those files take part in the ASP.NET security infrastructure - you have to make them pass the .NET runtime. ... Forms Authentication automatically redirects users who access pages on your ... every one of the pages has the filename extension ASPX. ... filename extension HTML are not protected. ...
    (microsoft.public.dotnet.security)
  • Re: Forms authentication for HTML files
    ... You could map HTML files in IIS admin to the aspnet handler, ... or, a better way, you could utilize a helper ASPX that takes the html file's ... > Is it possible to protect access to "regular" HTML files mixed in with ASPX ... After implementing forms authentication, I was able to get right to> an HTML page without any problems. ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Forms authentication for HTML files
    ... Is it possible to protect access to "regular" HTML files mixed in with ASPX ... After implementing forms authentication, I was able to get right to ...
    (microsoft.public.dotnet.framework.aspnet.security)