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.

134 Part III: Building Secure <strong>Web</strong> <strong>Application</strong>sPrincipals <strong>and</strong> IdentitiesRole-based security is implemented with Principal <strong>and</strong> Identity objects. The identity<strong>and</strong> role membership of the authenticated caller is exposed through a Principalobject, which is attached to the current <strong>Web</strong> request. You can retrieve the object byusing the HttpContext.Current.User property. If the caller is not required toauthenticate with the application, for example, because the user is browsing apublicly accessible part of the site, the Principal object represents the anonymousInternet user.There are many types of Principal objects <strong>and</strong> the precise type depends on theauthentication mechanism used by the application. However, all Principal objectsimplement the System.<strong>Security</strong>.Principal.IPrincipal interface <strong>and</strong> they all maintain alist of roles of which the user is a member.Principal objects also contain Identity objects, which include the user’s name,together with flags that indicate the authentication type <strong>and</strong> whether or not the userhas been authenticated. This allows you to distinguish between authenticated <strong>and</strong>anonymous users. There are different types of Identity objects, depending on theauthentication type, although all implement the System.<strong>Security</strong>.Principal.IIdentityinterface.The following table shows the range of possible authentication types <strong>and</strong> thedifferent types of Principal <strong>and</strong> Identity objects that ASP.NET <strong>Web</strong> applications use.Table 6.1 Principal <strong>and</strong> Identity Objects Per Authentication TypeAuthenticationTypePrincipal <strong>and</strong>Identity TypeWindows WindowsPrincipal +WindowsIdentityCommentsVerification of credentials is automatic <strong>and</strong> uses the<strong>Security</strong> Accounts Manager (SAM) or Active Directory.Windows groups are used for roles.Forms GenericPrincipal +FormsIdentityPassport GenericPrincipal +PassportIdentityYou must add code to verify credentials <strong>and</strong> retrieve rolemembership from a user store.Relies on the Microsoft Passport SDK. PassportIdentityprovides access to the passport authentication ticket.PrincipalPermission ObjectsThe PrincipalPermission object represents the identity <strong>and</strong> role that the currentprincipal must have to execute code. PrincipalPermission objects can be useddeclaratively or imperatively in code.

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

Saved successfully!

Ooh no, something went wrong!