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.

Chapter 9: Using Code Access <strong>Security</strong> with ASP.NET 235Customize PolicyIf your <strong>Web</strong> application contains code that requires more permissions than aregranted by a particular ASP.NET trust level, the easiest option is customizing a policyfile to grant the additional code access security permission to your <strong>Web</strong> application.You can either modify an existing policy file <strong>and</strong> grant additional permissions orcreate a new one based on an existing policy file.Note If you modify one of the built-in policy files, for example, the medium-trust<strong>Web</strong>_mediumtrust.config policy file, this affects all applications that are configured to run withmedium trust. To customize policy for a specific application1. Copy one of the existing policy files to create a new policy file. For example, copythe medium trust policy file <strong>and</strong> create a new policy file such as the following:%windir%\Microsoft.NET\Framework\{version}\CONFIG\web_yourtrust.config2. Add the required permission to the ASP.NET permission set in the policy file or,alternatively, modify an existing permission to grant a less restrictive permission.3. Add a new mapping beneath in Machine.configfor the new trust level file, as follows:. . .4. Configure your application to run with the new trust level by configuring the element in the application’s <strong>Web</strong>.config file, as follows:

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

Saved successfully!

Ooh no, something went wrong!