and claims • Claims based identity • Claims transformation • Claims based authorization • Federation and external authentication • ASP.NET 4.5 OpenID integration • Tooling
token – Windows account of the current process (desktop apps) – Windows account of the current client (server apps) // current process identity WindowsIdentity user = WindowsIdentity.GetCurrent(); WindowsPrincipal p = new WindowsPrincipal(user); Thread.CurrentPrincipal = p;
by your own custom credential store – allows to attach roles to that user var roles = new string[] { "Sales", "Marketing" }; var user = new GenericPrincipal( new GenericIdentity("bob"), roles);
groups, roles – permissions, capabilities – specialized (e.g. Bell LaPadula) • Claim examples – Bob is an administrator – Jim‘s email address is [email protected] – Alice is allowed to add new customers – Dave is allowed to write documents up to ‚confidential‘
someone else public class Claim { public virtual string Type { get; } public virtual string Value { get; } public virtual string Issuer { get; } // rest omitted }
type support • Claims transformation • Claims-based authorization • Session management • Support for federation protocols • Extensions to ASP.NET and WCF
authentication process and application code – to validate incoming identity data – allows adding application specific claims to the principal Authentication Claims Transformation Application Code
every request – might be OK, but might be also expensive • Outcome of claims transformation can be „cached“ in a session Authentication Transformation Application Cache Principal Authentication Application Load cached Principal First Request Subsequest Requests
to preserve a ClaimsPrincipal across round trips – cookies for ASP.NET (SessionAuthenticationHttpModule) – WS-SecureConversation for WCF • Extensible mechanism – session token protection – web farm support – round trip optimization var sessionToken = new SessionSecurityToken( principal, TimeSpan.FromHours(8)); FederatedAuthentication .SessionAuthenticationModule .WriteSessionTokenToCookie(sessionToken);
version 1) – „the old way“ – based on code access security – invoked by the CLR – typically clashes with unit testing – throws a SecurityException – limited to roles – encourages you to mix authorization & business logic [PrincipalPermission(SecurityAction.Demand, Roles = "Marketing"] public ActionResult AddCustomer() { ... }
version 4.5) – same underlying implementation as PrincipalPermission – based on ClaimsAuthorizationManager [ClaimsPrincipalPermission(SecurityAction.Demand, Resource = "Customer", Operation = "Add")] public ActionResult AddCustomer() { ... }
for – loading/parsing authorization policy – mapping operations/resources to required claims • Application code should not check for claims directly public class ClaimAuthZManager : ClaimsAuthorizationManager { public override bool CheckAccess(AuthorizationContext context) { // inspect context and make authorization decision } }
Active Directory Federation Service 2 – IBM Tivoli Federation Manager – Oracle Identity Manager – Ping Federate • .NET 4.5 contains base-classes to build you own STS – be aware you are building critical security infrastructure – http://thinktecture.github.com/Thinktecture.IdentityServer.v2/
4.5 templates make it easy to integrate OpenID logins – Google, LinkedIn, Facebook, LiveID... – no direct claims integration – http://brockallen.com/2012/09/05/integrating-claims-and- oauthwebsecurity/ • Tooling – „Identity & Access“ extension for Visual Studio – Development STS – http://goo.gl/cTChL
– nothing to do for the built-in principals/identities – if you are using custom principals, you should change the base classes – can make gradual use of new features • From WIF – lots of breaking changes from WIF to the 4.5 model – mechanics stay the same – WIF is part of Windows, so it will be available side by side
security model – by changing the base class, all apps are now claims-based – ASP.NET and WCF are specifically aware of this • Three essential concepts – turning security tokens into claims (and vice versa) – claims transformation – claims-based authorization • Token and protocol support – federated and external authentication • Should be transparent in most cases – needs some rework for custom identities – needs some rework for WIF based applications