at thinktecture • Focus on – security in distributed applica9ons – iden9ty management – access control – Windows/.NET security – mobile app security • MicrosoO MVP for Developer Security • ASP.NET Web API Advisor • [email protected] • hGp://leastprivilege.com think mobile!
<= 2012 Visual Studio 2013 Visual Studio >= 2014/15 ASP.NET WebForms ASP.NET MVC ASP.NET Web API ASP.NET SignalR (Simple) Membership "One ASP.NET" WebForms & MVC Web API & SignalR OWIN/Katana ASP.NET Iden9ty One ASP.NET OWIN/Katana MVC Web API SignalR ???
ASP.NET) – 12+ year old web framework – Unnamed MicrosoX employee on System.Web: • “We fix one bug and open seven new ones” – Always executes lots of ASP.NET-‐specific code hGps://twiGer.com/aeinbu/status/407816285058514944
HTTP request/response – IDic%onary<string, object> • All .NET primi9ves so no framework dependencies – Standard set of key/value pairs Key Type owin.RequestScheme string owin.RequestMethod string owin.RequestPath string owin.RequestBody Stream owin.RequestHeaders IDic9onary<string, string[]> owin.ResponseStatusCode int owin.ResponseHeaders IDic9onary<string, string[]> owin.ResponseBody Stream
process lifeame • Server hosts HTTP and implements OWIN API • Middleware are linked components that process requests • Applicaaon code targeang a framework (e.g. Web API) Host OWIN Server Some Middleware Some Other Middleware User Agent Applica9on
OWIN implementaaon – hkps://katanaproject.codeplex.com/ • Set of hosts and servers – IIS or self-‐hos9ng • Set of convenience classes – OwinContext, OwinRequest, OwinResponse, etc. – AppBuilderUseExtensions – Authen%ca%onManager • Set of middleware for common features – Authen9ca9on – Hos9ng content (e.g. sta9c files) – CORS
the dreaded ASP.NET (simple) Membership – supports claims – supports external sign-‐ins and account linking – supports two-‐factor authen9ca9on – no dependencies on ASP.NET – more control over user/profile data and persistence – separate nuget package / release cycle • Sall room for improvement – hkp://brockallen.com/2014/02/11/introducing-‐ iden9tyreboot/
support for OAuth2 paGerns – producing & consuming access tokens – as a replacement for cookie-‐based authen9ca9on • More plumbing – authen9ca9on filters – integra9on with Katana authen9ca9on middleware – CORS
Web API prefers to avoid cookie authenacaaon – Prevents XSRF akacks • Special message handler to block host authenacaaon – SuppressDefaultHostAuthen%ca%on • Web API must ask for authenacaaon when needed – HostAuthen%ca%on authen9ca9on filter – Bearer authen9ca9on middleware configured as passive public static void Register(HttpConfiguration config) { config.SuppressDefaultHostAuthentication(); config.Filters.Add(new HostAuthenticationFilter(“Bearer”)); }
OAuth2 authorizaaon server middleware can emit token – Supports the protocols of all OAuth2 flows • OAuth2 bearer token middleware consumes tokens – Similar to cookie middleware User Agent OWIN Host Bearer MW Application Authorization Server MW