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.

332 Part III: Building Secure <strong>Web</strong> <strong>Application</strong>sAuthenticationIf your <strong>Web</strong> service outputs sensitive, restricted data or if it provides restrictedservices, it needs to authenticate callers. A number of authentication schemes areavailable <strong>and</strong> these can be broadly divided into three categories:● Platform level authentication● Message level authentication● <strong>Application</strong> level authenticationPlatform Level AuthenticationIf you are in control of both endpoints <strong>and</strong> both endpoints are in the same or trustingdomains, you can use Windows authentication to authenticate callers.Basic AuthenticationYou can use IIS to configure your <strong>Web</strong> service’s virtual directory for Basicauthentication. With this approach, the consumer must configure the proxy <strong>and</strong>provide credentials in the form of a user name <strong>and</strong> password. The proxy thentransmits them with each <strong>Web</strong> service request through that proxy. The credentials aretransmitted in plaintext <strong>and</strong> therefore you should only use Basic authentication withSSL.The following code fragment shows how a <strong>Web</strong> application can extract Basicauthentication credentials supplied by an end user <strong>and</strong> then use those to invoke adownstream <strong>Web</strong> service configured for Basic authentication in IIS.// Retrieve client's credentials (available with Basic authentication)string pwd = Request.ServerVariables["AUTH_PASSWORD"];string uid = Request.ServerVariables["AUTH_USER"];// Set the credentialsCredentialCache cache = new CredentialCache();cache.Add( new Uri(proxy.Url), // <strong>Web</strong> service URL"Basic",new NetworkCredential(uid, pwd, domain) );proxy.Credentials = cache;Integrated Windows AuthenticationYou can use IIS to configure your <strong>Web</strong> service’s virtual directory for IntegratedWindows authentication, which results either in Kerberos or NTLM authenticationdepending on the client <strong>and</strong> server environment. The advantage of this approach incomparison to Basic authentication is that credentials are not sent over the network,which eliminates the network eavesdropping threat.

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

Saved successfully!

Ooh no, something went wrong!