11.07.2015 Views

Improving Web Application Security: Threats and - CGISecurity

Improving Web Application Security: Threats and - CGISecurity

Improving Web Application Security: Threats and - CGISecurity

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

284 Part III: Building Secure <strong>Web</strong> <strong>Application</strong>sFor more information about preventing SQL injection, see Chapter 14, “BuildingSecure Data Access.”AuthorizationYou can use authorization to control access to directories, individual <strong>Web</strong> pages, pageclasses, <strong>and</strong> methods. If required, you can also include authorization logic in yourmethod code. When you build authorization into your <strong>Web</strong> pages <strong>and</strong> controls,consider the following recommendations:● Use URL authorization for page <strong>and</strong> directory access control.●●●Use File authorization with Windows authentication.Use principal dem<strong>and</strong>s on classes <strong>and</strong> methods.Use explicit role checks for fine-grained authorization.Use URL Authorization for Page <strong>and</strong> Directory Access ControlFor page-level <strong>and</strong> directory-level access control, use URL authorization, which isconfigured by the element. To restrict access to specific files ordirectories, place the element inside a element.For more information, see “Authorization” in Chapter 19, “Securing Your ASP.NET<strong>Application</strong> <strong>and</strong> <strong>Web</strong> Services.”Use File Authorization with Windows AuthenticationIf ASP.NET is configured for Windows authentication, the FileAuthorizationModulechecks all requests for ASP.NET file types. This includes ASP.NET page files (.aspx),user controls (.ascx), <strong>and</strong> any other file type mapped by IIS to the ASP.NET ISAPIfilter.To configure the FileAuthorizationModule, set the appropriate Windows accesscontrol lists (ACLs) on the ASP.NET files.Use Principal Dem<strong>and</strong>s on Classes <strong>and</strong> MethodsPrincipal permission dem<strong>and</strong>s allow you to make authorization decisions based onthe identity <strong>and</strong> role membership of the caller. The caller’s identity <strong>and</strong> rolemembership is maintained by the principal object that is associated with the current<strong>Web</strong> request (accessed through HttpContext.User). Use declarative security attributesto provide access controls on classes <strong>and</strong> methods, as follows:// Declarative syntax[PrincipalPermission(<strong>Security</strong>Action.Dem<strong>and</strong>,Role=@"DomainName\WindowsGroup")]public void SomeRestrictedMethod(){}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!