Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

The ASP.NET Security Model


The ASP.NET Security Model

The ASP.NET security model is made of a few distinct layers, the first of which is represented by the IIS context. When a client issues a web request, IIS picks it up and attempts to authenticate the caller. If the request comes from a nonrestricted IP address and the page can be viewed, IIS authenticates the caller using any of the predefined authentication mechanisms. Windows Authentication, Digest, and Basic are the three built-in authentication mechanisms supported by IIS. All of them return an identity token representing the caller. A fourth possibility is given by the anonymous access. In this case, the token is entitled to the configured anonymous user—usually IWAM_MACHINE.

If the URL requested is an ASP.NET resource, the control passes to the ASP.NET runtime. What happens next depends on how the ASP.NET security layer is configured. If ASP.NET is set up for Windows authentication, no additional steps are needed and ASP.NET just accepts any security token it receives from IIS. If ASP.NET is configured for Forms authentication, then the user is prompted for credentials using an application-specific HTML form. The user enters a name and password and attempts to login. Credentials are authenticated against a stored list of valid users. The application is free to choose the storage mechanism that best suits, including a SQL Server database or Active Directory services. Finally, if ASP.NET is configured for Passport authentication, then the user is redirected to a Passport web site and authenticated by the Passport service.

In all, ASP.NET supports four (not three) authentication models. The fourth possibility is None, meaning that ASP.NET does not attempt to perform its own authentication and completely relies on the results of the authentication already carried out by IIS. In this case, for example, anonymous users can connect and resources are accessed under the control of the ASP.NET current account. However, setting the ASP.NET authentication mode to the None option does not prevent the application from implementing its own personal authentication layer.

You choose the ASP.NET authentication mechanism using the <authentication> section in the web.config file. By default, the authentication mode is set to Windows. Child subdirectories inherit the authentication mode chosen for the application.

Authentication is only one facet of the security coin; the other face is authorization. Authentication refers to the application’s ability to identify the caller; authorization is the mechanism that verifies whether the authenticated user has the rights to access a given resource.

ASP.NET supports two types of authorization—through an Access Control List (ACL) on the resource and through a list of allowed or denied users and roles. If you use file authorization, the file system guarantees the security. If you use URL authorization, undesired users are automatically rejected. URL authorization, though, says nothing about the rights of the authenticated user to access a given resource. The application is responsible for the security of the resources.

When Forms authentication is selected, the ASP.NET application is free of implementing the authentication and authorization algorithms it likes. In this context, the use of Active Directory makes sense as a way to secure users and resources. Another typical scenario is when SQL Server is employed to store a list of users and the URL authorization is used to grant resources based on application-specific roles.


Dino Esposito is Wintellect's ADO.NET and XML expert, and a trainer and consultant based in Rome, Italy. Dino is a contributing editor to Windows Developer Network and MSDN Magazine, and the author of several books for Microsoft Press including Building Web Solutions with ASP.NET and ADO.NET and Applied XML Programming for .NET. Contact Dino at [email protected].


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.