ASP.NET Web API Security and Authentication Overview

undefined
WEB-API & MVC5 - Identity & Security
Mait Poska & Andres Käver, IT Kolledž 2014
Transport security
HTTPS == HTTP over TLS
RFC 1818
Tunnels unprotected HTTP and adds
Server authentication
Is it really amazon.com?
Integrity protection
Nobody can change your book order in the middle of
communication
Replay protection
Nobody can take your packet and resend it 500x times
Confidentiality
Encryption – nobody knows what book you are buying
2
Security Architecture
Overview
Hosting
Message handlers
Authentication filter
Authorization filter
Accessing client identity
3
WEB-API Overview
No dependencies on specific host
IIS
Self-host
OWIN & Katana
No ASP.NET system.web
4
Security pipeline
5
OWIN system.web hosting
6
OWIN Middleware
7
Katana Authentication Middleware
8
MessageHandler
Web API, global or per-route
9
Authentication Filter
10
Authorization Filter
Determines if a resource needs authentication
[AllowAnonymous] to skip authorization for an action
Emits the 401 code, if unsuccessful
11
Accessing the Client Identity
RequestContext
HttpRequestMessage – hosting enviroment
ApiController.User is now shortcut to the
request context (used to be
Thread.CurrentPrincipal in WEB Api 1)
Could be null
12
Demo - Pipeline
 
13
Summary
Web API security extensibility is a pipeline
Katana
Authentication filters
Authorization filters
Avoid host (IIS) specific dependencies
HttpRequestMessage.GetRequestContext().Principal
One stop shop for client identity
14
JS/Browser-based clients
Same origin policy
Implicit Browser Authentication
Cross Site Request Forgery (CSRF)
Cross Origin Resource Sharing (CORS)
15
Same Origin Policy
Sandbox
Scripts, communication, implicit browser
authentication
16
Using same-domain for Auth
Web APIs inherit security settings of
web host
Cookies, Win/Basic auth, client certs …
17
CSRF
18
CSRF – Web API 2
19
Web API 2 – demo - FIDDLER
Get http://localhost:3456/api/Values
20
Web API 2 – Register user
Post
http://localhost:3456/api/Account/Register
Request headers
Content-Type: application/json
Request body
{
"Password": “parool”,
"ConfirmPassword": “parool”,
“Email”: “user@akaver.com”
}
21
Web API 2 – Authenticate
Post
http://localhost:3456/Token/
Request headers
Content-Type: application/x-www-form-urlencoded
Request body
grant_type=password&username=user@akaver.com&
password=parool
22
Web API 2 – Authenticate
Bearer token is a particular type of access
token. An access token is a credential
string that authorizes a client to access a
protected resource. (RFC 6749.)
A bearer token is an access token that can
be used by any client. (RFC 6750.)
Bearer tokens must be used with SSL.
23
Web API 2 – Authorized request
Get
http://localhost:3456/api/Values
Request headers
Authorization: Bearer mBKN9H_zaix….
24
CORS
25
 
 
26
THE END
Mait Poska & Andres Käver
27
Classic/Basic authentication
Anti pattern
Client must store the secret or obtain it from the
user (on every request)
Storage in clear text (or reversible encryption)
Server has to validate the secret on every
request
High computational cost – brute force protection
High probability of accidental exposure of
the secret is increased
28
Basic authentication
Base64 encoded credentials on auth
header
GET /service/resource
Authorization: Basic
username:password
29
Slide Note
Embed
Share

Explore the essential elements of ASP.NET Web API security, including HTTPS transport security, authentication filters, access to client identities, and OWIN middleware. Learn about securing your Web API with integrity protection, replay protection, and encryption for confidentiality. Dive into the details of security architectures, message handlers, and the Katana authentication middleware.

  • ASP.NET
  • Web API
  • Security
  • Authentication
  • OWIN Middleware

Uploaded on Oct 06, 2024 | 1 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. WEB-API & MVC5 - Identity & Security ASP.NET ASP.NET MVC MVC Mait Poska & Andres K ver, IT Kolled 2014

  2. Transport security HTTPS == HTTP over TLS RFC 1818 Tunnels unprotected HTTP and adds Server authentication Is it really amazon.com? Integrity protection Nobody can change your book order in the middle of communication Replay protection Nobody can take your packet and resend it 500x times Confidentiality Encryption nobody knows what book you are buying 2

  3. Security Architecture Overview Hosting Message handlers Authentication filter Authorization filter Accessing client identity 3

  4. WEB-API Overview No dependencies on specific host IIS Self-host OWIN & Katana No ASP.NET system.web 4

  5. Security pipeline 5

  6. OWIN system.web hosting 6

  7. OWIN Middleware 7

  8. Katana Authentication Middleware 8

  9. MessageHandler Web API, global or per-route 9

  10. Authentication Filter 10

  11. Authorization Filter Determines if a resource needs authentication [AllowAnonymous] to skip authorization for an action Emits the 401 code, if unsuccessful 11

  12. Accessing the Client Identity RequestContext HttpRequestMessage hosting enviroment ApiController.User is now shortcut to the request context (used to be Thread.CurrentPrincipal in WEB Api 1) Could be null 12

  13. Demo - Pipeline 13

  14. Summary Web API security extensibility is a pipeline Katana Authentication filters Authorization filters Avoid host (IIS) specific dependencies HttpRequestMessage.GetRequestContext().Principal One stop shop for client identity 14

  15. JS/Browser-based clients Same origin policy Implicit Browser Authentication Cross Site Request Forgery (CSRF) Cross Origin Resource Sharing (CORS) 15

  16. Same Origin Policy Sandbox Scripts, communication, implicit browser authentication 16

  17. Using same-domain for Auth Web APIs inherit security settings of web host Cookies, Win/Basic auth, client certs 17

  18. CSRF 18

  19. CSRF Web API 2 19

  20. Web API 2 demo - FIDDLER Get http://localhost:3456/api/Values 20

  21. Web API 2 Register user Post http://localhost:3456/api/Account/Register Request headers Content-Type: application/json Request body { "Password": parool , "ConfirmPassword": parool , Email : user@akaver.com } 21

  22. Web API 2 Authenticate Post http://localhost:3456/Token/ Request headers Content-Type: application/x-www-form-urlencoded Request body grant_type=password&username=user@akaver.com& password=parool 22

  23. Web API 2 Authenticate Bearer token is a particular type of access token. An access token is a credential string that authorizes a client to access a protected resource. (RFC 6749.) A bearer token is an access token that can be used by any client. (RFC 6750.) Bearer tokens must be used with SSL. 23

  24. Web API 2 Authorized request Get http://localhost:3456/api/Values Request headers Authorization: Bearer mBKN9H_zaix . 24

  25. CORS 25

  26. 26

  27. THE END Mait Poska & Andres K ver 27

  28. Classic/Basic authentication Anti pattern Client must store the secret or obtain it from the user (on every request) Storage in clear text (or reversible encryption) Server has to validate the secret on every request High computational cost brute force protection High probability of accidental exposure of the secret is increased 28

  29. Basic authentication Base64 encoded credentials on auth header GET /service/resource Authorization: Basic username:password 29

More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#