| |||||||||||||||||||||
ASP.NET AuthorizationASP.NET Web Applications ASP.NET Web Application Security Authorization determines whether an identity should be granted the requested type of access to a given resource. ASP.NET implements authorization through authorization providers, the modules that contain the code to authorize access to a given resource. ASP.NET includes the following authorization modules.
Configuring authorization using the <authorization> sectionTo enable URL authorization for a given directory ( including the application root directory ), you need to set up a configuration file that contains an authorization section for that directory. The general syntax for the authorization section is as follows: <authorization> < [ allow | deny ] [ users ] [ roles ] [ verbs ] /> </authorization> The allow or deny element is required, and either the users or the roles attribute must be specified. Both can be included, but both are not required. The verbs attribute is optional. The allow and deny elements grant and revoke access, respectively. Each element supports three attributes, which are defined in the following table.
In addition to identity names, there are two special identities, as shown in the following table.
To allow John and deny everyone else, one might construct the following configuration section: <authorization> <allow users = "John" /> <deny users = "*" /> </authorization> The following example grants access to <authorization> <allow users = "Mary" /> <allow roles = "Admins" /> <deny users = "John" /> <deny users = "?" /> </authorization> Both users and roles can refer to multiple entities by using a comma-separated list such as in the following: <allow users = "John, Mary, redmond\bar" /> Notice that the domain account [ The following example lets everyone do a GET, but only <authorization> <allow verb = "GET" users = "*" /> <allow verb = "POST" users = "Mary" /> <deny verb = "POST" users = "*" /> </authorization> Rules are applied using the following heuristics:
Notice in the last situation, the request is allowed access even if no rules were matched. This happens so because the default configuration for ASP.NET defines an <allow users = "*"> element, which authorizes all users. By default, this rule is applied last. To prevent this behavior, define a <deny users = "*"> element at the application level. Like all other configuration settings, the access permissions established for a directory also apply to all of its subdirectories, unless explicitly overriden in a child configuration file. Configuring authorization using the <location> elementInstead of defining access permissions in separate directory configuration files, you can also define one or more location elements in a root configuration file to specify the particular files or directories to which authorization settings defined in that location element should apply. The following code example demonstrates how to allow an anonymous user to gain access to the <configuration>
<location path = "Logon.aspx">
<system.web>
<authorization>
<allow users = "?" />
</authorization>
</system.web>
</location>
</configuration>
See AlsoAuthentication <location> Element Hierarchical Configuration Architecture Impersonation |
| ||||||||||||||||||||
Check out related books at Amazon
© 2000-2008 Rey Nuñez All rights reserved.
If you have any question, comment or suggestion
about this site, please send us a note
You can help support aspxtreme