Appendix D. Code-Access Security

Code-access security, introduced in .NET 1.0, is probably the single differentiating capability-wise aspect of .NET compared with unmanaged code. The core advantage of .NET compared with the unmanaged world of C++ and COM is one of productivity, not capability. With the exception of code-access security, virtually anything that can be done by .NET can be done with unmanaged code. Code-access security is built into the very fabric of .NET, affecting every operation in managed code—something that unmanaged code can never achieve. The first release of WCF offered no support for code-access security. The System.ServiceModel assembly did not allow any partially trusted callers, and by demanding full trust of all its callers, WCF disabled code-access security support. This meant that developers wanting to take advantage of code-access security were very limited in their endeavor. Developers could use permission attributes to restrict the permissions granted to their services, but as discussed next, this came at a nontrivial cost and liability. Developers could manipulate the proxy to enable partially trusted clients to call WCF services (by granting it and asserting full trust, as discussed next), but in so doing, they waived all benefits of code-access security toward the clients. Furthermore, developers had no way of hosting a WCF service in a partial-trust environment.

The second release of WCF introduced rudimentary support for code-access security for some of the HTTP bindings, and only for a limited set of scenarios. For this limited support, WCF had to allow for partially trusted callers to the System.ServiceModel assembly. This change enabled me to write a small framework that provides for comprehensive support for code-access security, enabling partially trusted clients, partially trusted services, and partially trusted hosts, all without compromising the WCF programming model or code-access security. That framework and the approach leading to it are the subjects of this appendix. You will also get to see some advanced WCF and .NET programming techniques along the way.[10]



[10] I first published my technique for supporting CAS in WCF in the articles "Code Access Security in WCF, Part 1" and "Code Access Security in WCF, Part 2" (MSDN Magazine, April and July 2008).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.237.164