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.

248 Part III: Building Secure <strong>Web</strong> <strong>Application</strong>s<strong>Web</strong> ServicesBy default, medium-trust policy grants ASP.NET <strong>Web</strong> applications a restricted<strong>Web</strong>Permission. To be able to call <strong>Web</strong> services from your <strong>Web</strong> application, you mustconfigure the originUrl attribute on your application’s element. To call a single <strong>Web</strong> service from a medium trust <strong>Web</strong> application1. Configure the application to run at medium trust.2. Set the originUrl to point to the <strong>Web</strong> service you want to be able to call, as follows:The originUrl value is used in the constructor for a System.Text.RegEx regularexpression class so that in can perform a match on the URLs that are accessible by the<strong>Web</strong> service. This RegEx class is used in conjunction with a <strong>Web</strong>Permission class.The “.*” matches any URL beginning with “http://servername/”.The originUrl attribute is used when ASP.NET policy is evaluated. It gives a value forthe $OriginHost$ substitution parameter. Here is the <strong>Web</strong>Permission definition from<strong>Web</strong>_mediumtrust.config:If you do not specify the <strong>Web</strong> servers accessed by your application, any <strong>Web</strong> servicerequest will fail with a <strong>Security</strong>Exception. To call a <strong>Web</strong> service on the local <strong>Web</strong>server, use the following configuration:If your application needs to access multiple <strong>Web</strong> services on different servers, youneed to customize ASP.NET policy because you can only specify one originUrl on the element in <strong>Web</strong>.config or Machine.config.

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

Saved successfully!

Ooh no, something went wrong!