SlideShare uma empresa Scribd logo
1 de 27
HTTPS = HTTP over TLS
• Server Authentication
• Integrity protection
• Encryption
• Client Authentication
Server Root Cert
Computer – Trusted Root
Certification Authorities
Server SSL Cert
Computer – Personal
(Must have a private key.
Usually a .pfx file)
Client Private Cert
Current User – Personal
(Must have a private key.
Usually a .pfx file)
X.509 Certificates
• ITU-T Standard for PKI
• Standard formats for
certificates
• Installed in Windows
Certificate Store
Client Public Cert
Computer – Trusted People
(Only public key required.
Usually a .cer file)
Bind SSL certificate to port / host
name
• IIS
• netsh.exe
• httpconfig.exe
• CN should match DNS name
Connect
Send Certificate
Generate session key and
encrypt with public key
http://www.moserware.com/2009/06/first-few-milliseconds-of-https.html
Status: 401 (Unauthorised)
WWW-Authenticate: Scheme realm=“app"
GET /URL/Resource
Authorization: scheme <credential>
Authorisation: basic dXNlcjpwYXNzd29yZA==
makecert -r -n "CN=DevRoot" -pe -sv DevRoot.pvk -cy authority DevRoot.cer
• -r Create a self signed certificate
• -n <X509name> Certificate subject X500 name (eg: CN=Fred Dews)
• -pe Mark generated private key as exportable
• -sv <pvkFile> Subject's PVK file; To be created if not present
• -cy <certType> Certificate types
Package the certificate and the private key
pvk2pfx.exe -pvk DevRoot.pvk -spc DevRoot.cer -pfx DevRoot.pfx
makecert -iv DevRoot.pvk -ic DevRoot.cer -n "CN=site.local" -pe -sv %1.pvk -sky exchange
site.local.cer -eku 1.3.6.1.5.5.7.3.1
• -iv <pvkFile> Issuer's PVK file
• -ic <file> Issuer's certificate file
• -n <X509name> Certificate subject X500 name (eg: CN=Fred Dews)
• -pe Mark generated private key as exportable
• -sv <pvkFile> Subject's PVK file; To be created if not present
• -sky <keytype> Subject key type
• -eku <oid[<,oid>]> Comma separated enhanced key usage OIDs
Environment Dictionary
Stores all of the state necessary for
processing an HTTP request and
response, as well as any relevant
server state.
IDictionary<string, object>
"owin.RequestMethod" : A string
containing the HTTP request method
of the request (e.g., "GET", "POST").
Application Delegate (AppFunc)
This is a function signature which serves
as the primary interface between all
components in an OWIN application.
Func<IDictionary<string, object>,
Task>;
• Your appApplication
•Web API
•SignalR
•Nancy
•ServiceStack
Middleware
• Microsoft.Owin.Host.SystemWeb
• Microsoft.Owin.Host.HttpListener
• Helios
Server
•IIS/ASP.Net
•OwinHost.exe
•Self Host
•IIS
Host
Microsoft’s OWIN Implementation
http://katanaproject.codeplex.com/
Hosts and Servers Implementation
IIS
Self-Hosting
OwinHost.exe
Convenience Classes
OwinContext
OwinRequest
OwinResponse
AppBuilderUseExtensions
Middleware for Common Features
Authentication
CORS
Web API Web API
Web API
(+ OWIN Adapter)
Self Host Web Host OWIN
WCF ASP.Net
ASP.Net
(+ OWIN Bridge)
Service / Exe IIS IIS
Hosting v1 Hosting v2
Web API
(+ OWIN Adapter)
OWIN
Process/Host
(+ OWIN Bridge)
No System.Web
dependency
Host Web API 2
OWIN
MessageHandler
(global/per-route)
Authentication Filter Authorization Filter
Host/Framework independent concerns,
E.g. authentication
Web API cross-cutting concerns,
E.g. CORS
authorization
Host
OWIN Server
Middleware 1 Middleware 2 ApplicationClient
Windows Authentication
• AD Integrated
• Client and Server are on a domain
• The User is a domain account
<system.web>
<authentication mode="Windows" />
</system.web>
public static IAppBuilder UseWindowsAuthentication(this IAppBuilder app){
object value;
if (app.Properties.TryGetValue("System.Net.HttpListener", out value)){
var listener = value as HttpListener;
if (listener != null){
listener.AuthenticationSchemes =
AuthenticationSchemes.IntegratedWindowsAuthentication;
}
}
return app;
}
Users Clients
Do I trust
this app ?
How can I
securely
communicate ?
API
Who is the user ?
Who is the client ?
What are they
authorised to do ?
Authorisation
Server
access token
Scopes: read, write, delete
Alice
(Resource Owner)
App
(Client)
Web API
(Resource Server)
http://tools.ietf.org/html/rfc6749
Resource Owner Password Credential Flow
• User gives its credentials to the client.
• The client access the auth server on
behalf of the user with the credentials
• Client can optionally authenticate with
the auth server using Basic
authentication scheme.
• Auth server returns an access token –
typically with a short expiry time
Resource Owner Password Credential Flow
• The client then access the Resource
Server using the access token
Native / Browser based clients
• Credential input is not in the client but in the auth server
• No client authentication, client secret not embedded in a
public device
• Client opens a web view to auth server
• Auth server will show a login page and a
consent screen
• Auth server redirects to the callback URL
(# fragment)
• Client extracts the access token and expiry
• Client uses the access token to access the
resource server
Server based clients
Clients can securely store client secret
and client can authenticate with auth
server
• Client opens a web view to auth server
• Auth server will show a login page and a consent screen
• Auth server only sends a authorisation code and access token is not leaked
• Client now directly posts to the auth server, authenticates itself and sends
the authorisation code
• The auth server responds with the access token. The access token is never
leaked to the browser.
• Access token maybe long lived.
• So far auth server and resource server are
in same trusted subsystem
• Allow users to login using Facebook and
then using the Facebook identity to
access the backend services
• Facebook only does authorisation for
their own backend not your backend
Same Origin Policy in Browsers
• AJAX requests to a different host, port or protocol
will fails
• CORS is a W3C standard that allows cross origin
http requests
• The request itself succeeds but the browser
returns an error
• Supported in modern browsers only, IE 10+
CORS support in Web API
• Install-Package
Microsoft.AspNet.WebApi.Cors
• WebApiConfig.cs –
config.EnableCors();
• Controller.cs –
[EnableCors("origin", "headers", "verbs")]
public class MyController : ApiController
{
}
Request Header
Origin: http://cors.local/
Response Header
Access-Control-Allow-Origin: *
Alternative to OAuth for machine to
machine scenario
• Authentication scheme using HMAC
digest of request and response header
• Server and Client shares a secret key for
the hash
• The key is never is not part of the
headers
• Client hashes the header with secret key
• Server hashes the header with same key
and compares the has
• Useful when SSL cannot be used
Request Header
Authorization: Hawk id="dh37fgj492je",
ts="1353832234", nonce="j4h3g2",
mac="werxhqb98rpaxn39848xrunpaw3489r
uxnpa98w4rxn"
Response Header
Server-Authorization: Hawk
mac="YWojrFVgIjgd+RiPacnDwRcL8VtvcMEz
ahVfOpoLxoA=",
hash="yAF3A3y3uzLvNT2m/nVwsifn1+joCqu
0uNWZS8RSv6Y="
With thanks to our sponsors
THANK YOU !

Mais conteúdo relacionado

Mais procurados

Asp.Net Identity
Asp.Net IdentityAsp.Net Identity
Asp.Net IdentityMarwa Ahmad
 
Embracing HTTP in the era of API’s
Embracing HTTP in the era of API’sEmbracing HTTP in the era of API’s
Embracing HTTP in the era of API’sVisug
 
SQL Injection and DoS
SQL Injection and DoSSQL Injection and DoS
SQL Injection and DoSEmil Tan
 
What are JSON Web Tokens and Why Should I Care?
What are JSON Web Tokens and Why Should I Care?What are JSON Web Tokens and Why Should I Care?
What are JSON Web Tokens and Why Should I Care?Derek Edwards
 
V sphere automation_vlaxa_2017
V sphere automation_vlaxa_2017V sphere automation_vlaxa_2017
V sphere automation_vlaxa_2017Vladan Laxa
 
Super Fast Application development with Mura CMS
Super Fast Application development with Mura CMSSuper Fast Application development with Mura CMS
Super Fast Application development with Mura CMSColdFusionConference
 
Dev Ops on AWS with PowerShell (PowerShell Conference Asia 2016)
Dev Ops on AWS with PowerShell (PowerShell Conference Asia 2016)Dev Ops on AWS with PowerShell (PowerShell Conference Asia 2016)
Dev Ops on AWS with PowerShell (PowerShell Conference Asia 2016)Carlos Guillermo Musumeci
 
Ntu workshop : REST, PayPal APIs & Async
Ntu workshop : REST, PayPal APIs & AsyncNtu workshop : REST, PayPal APIs & Async
Ntu workshop : REST, PayPal APIs & AsyncAeshan Wijetunge
 
Externally Testing Modern AD Domains - Arcticcon
Externally Testing Modern AD Domains - ArcticconExternally Testing Modern AD Domains - Arcticcon
Externally Testing Modern AD Domains - ArcticconKarl Fosaaen
 
2009 - NRW Conf: (ASP).NET Membership
2009 - NRW Conf: (ASP).NET Membership2009 - NRW Conf: (ASP).NET Membership
2009 - NRW Conf: (ASP).NET MembershipDaniel Fisher
 
Intro to Coldfusion
Intro to ColdfusionIntro to Coldfusion
Intro to ColdfusionTerry Ryan
 
Hosting a website on IIS Server
Hosting a website on IIS ServerHosting a website on IIS Server
Hosting a website on IIS ServerDinesh Vasamshetty
 
Sherlock Homepage - A detective story about running large web services (VISUG...
Sherlock Homepage - A detective story about running large web services (VISUG...Sherlock Homepage - A detective story about running large web services (VISUG...
Sherlock Homepage - A detective story about running large web services (VISUG...Maarten Balliauw
 
ASP.NET Core 1.0
ASP.NET Core 1.0ASP.NET Core 1.0
ASP.NET Core 1.0Ido Flatow
 
Building an API in Node with HapiJS
Building an API in Node with HapiJSBuilding an API in Node with HapiJS
Building an API in Node with HapiJSLoc Nguyen
 
REST APIs in the context of single-page applications
REST APIs in the context of single-page applicationsREST APIs in the context of single-page applications
REST APIs in the context of single-page applicationsyoranbe
 

Mais procurados (20)

Asp.Net Identity
Asp.Net IdentityAsp.Net Identity
Asp.Net Identity
 
Embracing HTTP in the era of API’s
Embracing HTTP in the era of API’sEmbracing HTTP in the era of API’s
Embracing HTTP in the era of API’s
 
JavaCro'14 - Securing web applications with Spring Security 3 – Fernando Redo...
JavaCro'14 - Securing web applications with Spring Security 3 – Fernando Redo...JavaCro'14 - Securing web applications with Spring Security 3 – Fernando Redo...
JavaCro'14 - Securing web applications with Spring Security 3 – Fernando Redo...
 
IIS7 For Non IIS PFEs
IIS7 For Non IIS PFEsIIS7 For Non IIS PFEs
IIS7 For Non IIS PFEs
 
SQL Injection and DoS
SQL Injection and DoSSQL Injection and DoS
SQL Injection and DoS
 
IIS-Settings
IIS-SettingsIIS-Settings
IIS-Settings
 
What are JSON Web Tokens and Why Should I Care?
What are JSON Web Tokens and Why Should I Care?What are JSON Web Tokens and Why Should I Care?
What are JSON Web Tokens and Why Should I Care?
 
V sphere automation_vlaxa_2017
V sphere automation_vlaxa_2017V sphere automation_vlaxa_2017
V sphere automation_vlaxa_2017
 
Super Fast Application development with Mura CMS
Super Fast Application development with Mura CMSSuper Fast Application development with Mura CMS
Super Fast Application development with Mura CMS
 
Dev Ops on AWS with PowerShell (PowerShell Conference Asia 2016)
Dev Ops on AWS with PowerShell (PowerShell Conference Asia 2016)Dev Ops on AWS with PowerShell (PowerShell Conference Asia 2016)
Dev Ops on AWS with PowerShell (PowerShell Conference Asia 2016)
 
Ntu workshop : REST, PayPal APIs & Async
Ntu workshop : REST, PayPal APIs & AsyncNtu workshop : REST, PayPal APIs & Async
Ntu workshop : REST, PayPal APIs & Async
 
Externally Testing Modern AD Domains - Arcticcon
Externally Testing Modern AD Domains - ArcticconExternally Testing Modern AD Domains - Arcticcon
Externally Testing Modern AD Domains - Arcticcon
 
2009 - NRW Conf: (ASP).NET Membership
2009 - NRW Conf: (ASP).NET Membership2009 - NRW Conf: (ASP).NET Membership
2009 - NRW Conf: (ASP).NET Membership
 
Instant ColdFusion with Vagrant
Instant ColdFusion with VagrantInstant ColdFusion with Vagrant
Instant ColdFusion with Vagrant
 
Intro to Coldfusion
Intro to ColdfusionIntro to Coldfusion
Intro to Coldfusion
 
Hosting a website on IIS Server
Hosting a website on IIS ServerHosting a website on IIS Server
Hosting a website on IIS Server
 
Sherlock Homepage - A detective story about running large web services (VISUG...
Sherlock Homepage - A detective story about running large web services (VISUG...Sherlock Homepage - A detective story about running large web services (VISUG...
Sherlock Homepage - A detective story about running large web services (VISUG...
 
ASP.NET Core 1.0
ASP.NET Core 1.0ASP.NET Core 1.0
ASP.NET Core 1.0
 
Building an API in Node with HapiJS
Building an API in Node with HapiJSBuilding an API in Node with HapiJS
Building an API in Node with HapiJS
 
REST APIs in the context of single-page applications
REST APIs in the context of single-page applicationsREST APIs in the context of single-page applications
REST APIs in the context of single-page applications
 

Semelhante a DDD Melbourne 2014 security in ASP.Net Web API 2

Securing .NET Core, ASP.NET Core applications
Securing .NET Core, ASP.NET Core applicationsSecuring .NET Core, ASP.NET Core applications
Securing .NET Core, ASP.NET Core applicationsNETUserGroupBern
 
DEF CON 24 - workshop - Craig Young - brainwashing embedded systems
DEF CON 24 - workshop - Craig Young - brainwashing embedded systemsDEF CON 24 - workshop - Craig Young - brainwashing embedded systems
DEF CON 24 - workshop - Craig Young - brainwashing embedded systemsFelipe Prado
 
Using Communication and Messaging API in the HTML5 World
Using Communication and Messaging API in the HTML5 WorldUsing Communication and Messaging API in the HTML5 World
Using Communication and Messaging API in the HTML5 WorldGil Fink
 
Application Security in ASP.NET Core
Application Security in ASP.NET CoreApplication Security in ASP.NET Core
Application Security in ASP.NET CoreNETUserGroupBern
 
CNIT 129S: Ch 3: Web Application Technologies
CNIT 129S: Ch 3: Web Application TechnologiesCNIT 129S: Ch 3: Web Application Technologies
CNIT 129S: Ch 3: Web Application TechnologiesSam Bowne
 
CNIT 129S - Ch 3: Web Application Technologies
CNIT 129S - Ch 3: Web Application TechnologiesCNIT 129S - Ch 3: Web Application Technologies
CNIT 129S - Ch 3: Web Application TechnologiesSam Bowne
 
Using communication and messaging API in the HTML5 world - GIl Fink, sparXsys
Using communication and messaging API in the HTML5 world - GIl Fink, sparXsysUsing communication and messaging API in the HTML5 world - GIl Fink, sparXsys
Using communication and messaging API in the HTML5 world - GIl Fink, sparXsysCodemotion Tel Aviv
 
Realtime web experience with signal r
Realtime web experience with signal rRealtime web experience with signal r
Realtime web experience with signal rRan Wahle
 
Securing SharePoint Apps with OAuth
Securing SharePoint Apps with OAuthSecuring SharePoint Apps with OAuth
Securing SharePoint Apps with OAuthKashif Imran
 
Realtime web experience with signalR
Realtime web experience with signalRRealtime web experience with signalR
Realtime web experience with signalRRan Wahle
 
SharePointFest 2013 Washington DC - SPT 103 - SharePoint 2013 Extranets: How ...
SharePointFest 2013 Washington DC - SPT 103 - SharePoint 2013 Extranets: How ...SharePointFest 2013 Washington DC - SPT 103 - SharePoint 2013 Extranets: How ...
SharePointFest 2013 Washington DC - SPT 103 - SharePoint 2013 Extranets: How ...Brian Culver
 
JavaOne 2014 - Securing RESTful Resources with OAuth2
JavaOne 2014 - Securing RESTful Resources with OAuth2JavaOne 2014 - Securing RESTful Resources with OAuth2
JavaOne 2014 - Securing RESTful Resources with OAuth2Rodrigo Cândido da Silva
 
Web API 2 Token Based Authentication
Web API 2 Token Based AuthenticationWeb API 2 Token Based Authentication
Web API 2 Token Based Authenticationjeremysbrown
 
OAuth with AngularJS and WebAPI - SoCal Code Camp 2015
OAuth with AngularJS and WebAPI - SoCal Code Camp 2015OAuth with AngularJS and WebAPI - SoCal Code Camp 2015
OAuth with AngularJS and WebAPI - SoCal Code Camp 2015Stuart
 
Introduction to sitecore identity
Introduction to sitecore identityIntroduction to sitecore identity
Introduction to sitecore identityGopikrishna Gujjula
 
ASP.NET MVC 5 and SignalR 2
ASP.NET MVC 5 and SignalR 2ASP.NET MVC 5 and SignalR 2
ASP.NET MVC 5 and SignalR 2Jaliya Udagedara
 

Semelhante a DDD Melbourne 2014 security in ASP.Net Web API 2 (20)

Securing .NET Core, ASP.NET Core applications
Securing .NET Core, ASP.NET Core applicationsSecuring .NET Core, ASP.NET Core applications
Securing .NET Core, ASP.NET Core applications
 
DEF CON 24 - workshop - Craig Young - brainwashing embedded systems
DEF CON 24 - workshop - Craig Young - brainwashing embedded systemsDEF CON 24 - workshop - Craig Young - brainwashing embedded systems
DEF CON 24 - workshop - Craig Young - brainwashing embedded systems
 
Spa Secure Coding Guide
Spa Secure Coding GuideSpa Secure Coding Guide
Spa Secure Coding Guide
 
Windows 8 Metro apps and the outside world
Windows 8 Metro apps and the outside worldWindows 8 Metro apps and the outside world
Windows 8 Metro apps and the outside world
 
Using Communication and Messaging API in the HTML5 World
Using Communication and Messaging API in the HTML5 WorldUsing Communication and Messaging API in the HTML5 World
Using Communication and Messaging API in the HTML5 World
 
Application Security in ASP.NET Core
Application Security in ASP.NET CoreApplication Security in ASP.NET Core
Application Security in ASP.NET Core
 
CNIT 129S: Ch 3: Web Application Technologies
CNIT 129S: Ch 3: Web Application TechnologiesCNIT 129S: Ch 3: Web Application Technologies
CNIT 129S: Ch 3: Web Application Technologies
 
CNIT 129S - Ch 3: Web Application Technologies
CNIT 129S - Ch 3: Web Application TechnologiesCNIT 129S - Ch 3: Web Application Technologies
CNIT 129S - Ch 3: Web Application Technologies
 
Using communication and messaging API in the HTML5 world - GIl Fink, sparXsys
Using communication and messaging API in the HTML5 world - GIl Fink, sparXsysUsing communication and messaging API in the HTML5 world - GIl Fink, sparXsys
Using communication and messaging API in the HTML5 world - GIl Fink, sparXsys
 
Api security
Api security Api security
Api security
 
Realtime web experience with signal r
Realtime web experience with signal rRealtime web experience with signal r
Realtime web experience with signal r
 
Securing SharePoint Apps with OAuth
Securing SharePoint Apps with OAuthSecuring SharePoint Apps with OAuth
Securing SharePoint Apps with OAuth
 
Realtime web experience with signalR
Realtime web experience with signalRRealtime web experience with signalR
Realtime web experience with signalR
 
Web security
Web securityWeb security
Web security
 
SharePointFest 2013 Washington DC - SPT 103 - SharePoint 2013 Extranets: How ...
SharePointFest 2013 Washington DC - SPT 103 - SharePoint 2013 Extranets: How ...SharePointFest 2013 Washington DC - SPT 103 - SharePoint 2013 Extranets: How ...
SharePointFest 2013 Washington DC - SPT 103 - SharePoint 2013 Extranets: How ...
 
JavaOne 2014 - Securing RESTful Resources with OAuth2
JavaOne 2014 - Securing RESTful Resources with OAuth2JavaOne 2014 - Securing RESTful Resources with OAuth2
JavaOne 2014 - Securing RESTful Resources with OAuth2
 
Web API 2 Token Based Authentication
Web API 2 Token Based AuthenticationWeb API 2 Token Based Authentication
Web API 2 Token Based Authentication
 
OAuth with AngularJS and WebAPI - SoCal Code Camp 2015
OAuth with AngularJS and WebAPI - SoCal Code Camp 2015OAuth with AngularJS and WebAPI - SoCal Code Camp 2015
OAuth with AngularJS and WebAPI - SoCal Code Camp 2015
 
Introduction to sitecore identity
Introduction to sitecore identityIntroduction to sitecore identity
Introduction to sitecore identity
 
ASP.NET MVC 5 and SignalR 2
ASP.NET MVC 5 and SignalR 2ASP.NET MVC 5 and SignalR 2
ASP.NET MVC 5 and SignalR 2
 

Mais de Pratik Khasnabis

Open API (aka Swagger) - DDD by Night May 2020
Open API (aka Swagger) - DDD by Night May 2020Open API (aka Swagger) - DDD by Night May 2020
Open API (aka Swagger) - DDD by Night May 2020Pratik Khasnabis
 
Microsoft Azure fundamentals for AWS practitioners
Microsoft Azure fundamentals for AWS practitionersMicrosoft Azure fundamentals for AWS practitioners
Microsoft Azure fundamentals for AWS practitionersPratik Khasnabis
 
Deploying a website in Azure using ARM templates
Deploying a website in Azure using ARM templatesDeploying a website in Azure using ARM templates
Deploying a website in Azure using ARM templatesPratik Khasnabis
 
Recapping C# 6.0 and A First Look Into C# 7.0
Recapping C# 6.0 and A First Look Into C# 7.0Recapping C# 6.0 and A First Look Into C# 7.0
Recapping C# 6.0 and A First Look Into C# 7.0Pratik Khasnabis
 
Deploy a Website in Azure using ARM Templates
Deploy a Website in Azure using ARM TemplatesDeploy a Website in Azure using ARM Templates
Deploy a Website in Azure using ARM TemplatesPratik Khasnabis
 
Ddd melbourne 2011 C# async ctp
Ddd melbourne 2011  C# async ctpDdd melbourne 2011  C# async ctp
Ddd melbourne 2011 C# async ctpPratik Khasnabis
 

Mais de Pratik Khasnabis (10)

Open API (aka Swagger) - DDD by Night May 2020
Open API (aka Swagger) - DDD by Night May 2020Open API (aka Swagger) - DDD by Night May 2020
Open API (aka Swagger) - DDD by Night May 2020
 
Whats new in .net core 3
Whats new in .net core 3Whats new in .net core 3
Whats new in .net core 3
 
Containers on Windows
Containers on WindowsContainers on Windows
Containers on Windows
 
Microsoft Azure fundamentals for AWS practitioners
Microsoft Azure fundamentals for AWS practitionersMicrosoft Azure fundamentals for AWS practitioners
Microsoft Azure fundamentals for AWS practitioners
 
Deploying a website in Azure using ARM templates
Deploying a website in Azure using ARM templatesDeploying a website in Azure using ARM templates
Deploying a website in Azure using ARM templates
 
What is .Net Standard
What is .Net StandardWhat is .Net Standard
What is .Net Standard
 
Recapping C# 6.0 and A First Look Into C# 7.0
Recapping C# 6.0 and A First Look Into C# 7.0Recapping C# 6.0 and A First Look Into C# 7.0
Recapping C# 6.0 and A First Look Into C# 7.0
 
Deploy a Website in Azure using ARM Templates
Deploy a Website in Azure using ARM TemplatesDeploy a Website in Azure using ARM Templates
Deploy a Website in Azure using ARM Templates
 
Async Programming in C# 5
Async Programming in C# 5Async Programming in C# 5
Async Programming in C# 5
 
Ddd melbourne 2011 C# async ctp
Ddd melbourne 2011  C# async ctpDdd melbourne 2011  C# async ctp
Ddd melbourne 2011 C# async ctp
 

Último

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 

Último (20)

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

DDD Melbourne 2014 security in ASP.Net Web API 2

  • 1.
  • 2.
  • 3. HTTPS = HTTP over TLS • Server Authentication • Integrity protection • Encryption • Client Authentication Server Root Cert Computer – Trusted Root Certification Authorities Server SSL Cert Computer – Personal (Must have a private key. Usually a .pfx file) Client Private Cert Current User – Personal (Must have a private key. Usually a .pfx file) X.509 Certificates • ITU-T Standard for PKI • Standard formats for certificates • Installed in Windows Certificate Store Client Public Cert Computer – Trusted People (Only public key required. Usually a .cer file)
  • 4. Bind SSL certificate to port / host name • IIS • netsh.exe • httpconfig.exe • CN should match DNS name Connect Send Certificate Generate session key and encrypt with public key http://www.moserware.com/2009/06/first-few-milliseconds-of-https.html
  • 5. Status: 401 (Unauthorised) WWW-Authenticate: Scheme realm=“app" GET /URL/Resource Authorization: scheme <credential> Authorisation: basic dXNlcjpwYXNzd29yZA==
  • 6. makecert -r -n "CN=DevRoot" -pe -sv DevRoot.pvk -cy authority DevRoot.cer • -r Create a self signed certificate • -n <X509name> Certificate subject X500 name (eg: CN=Fred Dews) • -pe Mark generated private key as exportable • -sv <pvkFile> Subject's PVK file; To be created if not present • -cy <certType> Certificate types Package the certificate and the private key pvk2pfx.exe -pvk DevRoot.pvk -spc DevRoot.cer -pfx DevRoot.pfx
  • 7. makecert -iv DevRoot.pvk -ic DevRoot.cer -n "CN=site.local" -pe -sv %1.pvk -sky exchange site.local.cer -eku 1.3.6.1.5.5.7.3.1 • -iv <pvkFile> Issuer's PVK file • -ic <file> Issuer's certificate file • -n <X509name> Certificate subject X500 name (eg: CN=Fred Dews) • -pe Mark generated private key as exportable • -sv <pvkFile> Subject's PVK file; To be created if not present • -sky <keytype> Subject key type • -eku <oid[<,oid>]> Comma separated enhanced key usage OIDs
  • 8. Environment Dictionary Stores all of the state necessary for processing an HTTP request and response, as well as any relevant server state. IDictionary<string, object> "owin.RequestMethod" : A string containing the HTTP request method of the request (e.g., "GET", "POST"). Application Delegate (AppFunc) This is a function signature which serves as the primary interface between all components in an OWIN application. Func<IDictionary<string, object>, Task>; • Your appApplication •Web API •SignalR •Nancy •ServiceStack Middleware • Microsoft.Owin.Host.SystemWeb • Microsoft.Owin.Host.HttpListener • Helios Server •IIS/ASP.Net •OwinHost.exe •Self Host •IIS Host
  • 9. Microsoft’s OWIN Implementation http://katanaproject.codeplex.com/ Hosts and Servers Implementation IIS Self-Hosting OwinHost.exe Convenience Classes OwinContext OwinRequest OwinResponse AppBuilderUseExtensions Middleware for Common Features Authentication CORS
  • 10.
  • 11. Web API Web API Web API (+ OWIN Adapter) Self Host Web Host OWIN WCF ASP.Net ASP.Net (+ OWIN Bridge) Service / Exe IIS IIS Hosting v1 Hosting v2 Web API (+ OWIN Adapter) OWIN Process/Host (+ OWIN Bridge) No System.Web dependency
  • 12. Host Web API 2 OWIN MessageHandler (global/per-route) Authentication Filter Authorization Filter Host/Framework independent concerns, E.g. authentication Web API cross-cutting concerns, E.g. CORS authorization Host OWIN Server Middleware 1 Middleware 2 ApplicationClient
  • 13.
  • 14. Windows Authentication • AD Integrated • Client and Server are on a domain • The User is a domain account <system.web> <authentication mode="Windows" /> </system.web> public static IAppBuilder UseWindowsAuthentication(this IAppBuilder app){ object value; if (app.Properties.TryGetValue("System.Net.HttpListener", out value)){ var listener = value as HttpListener; if (listener != null){ listener.AuthenticationSchemes = AuthenticationSchemes.IntegratedWindowsAuthentication; } } return app; }
  • 15. Users Clients Do I trust this app ? How can I securely communicate ? API Who is the user ? Who is the client ? What are they authorised to do ?
  • 16.
  • 17. Authorisation Server access token Scopes: read, write, delete Alice (Resource Owner) App (Client) Web API (Resource Server) http://tools.ietf.org/html/rfc6749
  • 18.
  • 19. Resource Owner Password Credential Flow • User gives its credentials to the client. • The client access the auth server on behalf of the user with the credentials • Client can optionally authenticate with the auth server using Basic authentication scheme. • Auth server returns an access token – typically with a short expiry time
  • 20. Resource Owner Password Credential Flow • The client then access the Resource Server using the access token
  • 21. Native / Browser based clients • Credential input is not in the client but in the auth server • No client authentication, client secret not embedded in a public device • Client opens a web view to auth server • Auth server will show a login page and a consent screen • Auth server redirects to the callback URL (# fragment) • Client extracts the access token and expiry • Client uses the access token to access the resource server
  • 22. Server based clients Clients can securely store client secret and client can authenticate with auth server • Client opens a web view to auth server • Auth server will show a login page and a consent screen • Auth server only sends a authorisation code and access token is not leaked • Client now directly posts to the auth server, authenticates itself and sends the authorisation code • The auth server responds with the access token. The access token is never leaked to the browser. • Access token maybe long lived.
  • 23. • So far auth server and resource server are in same trusted subsystem • Allow users to login using Facebook and then using the Facebook identity to access the backend services • Facebook only does authorisation for their own backend not your backend
  • 24. Same Origin Policy in Browsers • AJAX requests to a different host, port or protocol will fails • CORS is a W3C standard that allows cross origin http requests • The request itself succeeds but the browser returns an error • Supported in modern browsers only, IE 10+ CORS support in Web API • Install-Package Microsoft.AspNet.WebApi.Cors • WebApiConfig.cs – config.EnableCors(); • Controller.cs – [EnableCors("origin", "headers", "verbs")] public class MyController : ApiController { } Request Header Origin: http://cors.local/ Response Header Access-Control-Allow-Origin: *
  • 25. Alternative to OAuth for machine to machine scenario • Authentication scheme using HMAC digest of request and response header • Server and Client shares a secret key for the hash • The key is never is not part of the headers • Client hashes the header with secret key • Server hashes the header with same key and compares the has • Useful when SSL cannot be used Request Header Authorization: Hawk id="dh37fgj492je", ts="1353832234", nonce="j4h3g2", mac="werxhqb98rpaxn39848xrunpaw3489r uxnpa98w4rxn" Response Header Server-Authorization: Hawk mac="YWojrFVgIjgd+RiPacnDwRcL8VtvcMEz ahVfOpoLxoA=", hash="yAF3A3y3uzLvNT2m/nVwsifn1+joCqu 0uNWZS8RSv6Y="
  • 26. With thanks to our sponsors