Analysis on ASP. NET authorization Module

Source: Internet
Author: User

ASP. NET authorization modules include FileAuthorizationModule and UrlAuthorizationModule. They also implemented the IHttpModule interface. These modules can determine which ASP. NET authorization module is used based on the authentication type used:

If Windows authentication is used, the FileAuthorizationModule is used during the authorization check;

If the <authorization/> element is provided in web. config, The UrlAuthorizationModule is used. See the following:

 
 
  1. <authorization> 
  2. <allow roles ="" users=""/> 
  3. <deny users=""/> 
  4. </authorization> 


FileAuthorizationModule:

If you use Windows authentication, the FileAuthorizationModule is used. This module can handle Authorization events and perform access checks on tokens and target resources of requests provided by IIS. In addition, the system ACL (Access Control List) is used ).

For example, if the requested resource is Default. aspx. The current user is xiaoyang. Then the FileAuthorizationModule will perform an access check to see if xiaoyang has access to Default. aspx read permission. If the Windows User Account has the xiaoyang account and has the access permission, the request is successful. Otherwise, the FileAuthorizationModule sets the Reponse. set StatusCode to 401 (unauthorized), and the request ends.

UrlAuthorizationModule:

Unlike the above processing module, no matter what type of authentication is used, you only need to configure the <authorization/> element in web. config, you need to use the UrlAuthorizationModule module. This module is executed as follows during processing:

(1) Compare the username declared in <authorization/> with HttpContext. User. Identity
(2) Compare the role information declared by <authorization/> with HttpContext. User. IsInRole

If it is successful, you can access the corresponding authorized resources. Otherwise, set Reponse. StatusCode to 401 (unauthorized), and the request ends. The above describes the ASP. NET authorization module.

  1. Introduction to ASP. NET Framework
  2. Introduction to ASP. NET Applications
  3. Processing Methods of ASP. NET framework
  4. Analysis on ASP. NET Security Architecture
  5. Overview ASP. net mvc and FubuMVC core framework

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.