59
Prabath Siriwardena

Learn with WSO2 - API Security

  • Upload
    wso2

  • View
    716

  • Download
    2

Embed Size (px)

Citation preview

Page 1: Learn with WSO2 - API Security

Prabath Siriwardena

Page 2: Learn with WSO2 - API Security

•  Exposing  business  functionality  to  the  rest  of  the  world.  •  Private  APIs  vs.  Public  APIs  •  Securing,  Throttling,  Monitoring,  Monetizing  

Page 3: Learn with WSO2 - API Security

•  XML  over  HTTP  •  JSON  over  HTTP  •  SOAP  over  HTTP    

Page 4: Learn with WSO2 - API Security
Page 5: Learn with WSO2 - API Security

•  Basic  Authentication  •  Mutual  Authentication  •  Custom  Authentication  Schemes  (e.g.  AWS)  •  What’s  wrong  ?    

Page 6: Learn with WSO2 - API Security
Page 7: Learn with WSO2 - API Security
Page 8: Learn with WSO2 - API Security
Page 9: Learn with WSO2 - API Security
Page 10: Learn with WSO2 - API Security

Third-­‐party  applications  are  required  to  store  the  resource  owner's  credentials  for  future  use,  typically  a  password  in  clear-­‐

text.  

Page 11: Learn with WSO2 - API Security

Servers  are  required  to  support  password  authentication,  despite  the  security  weaknesses  created  by  passwords.  

Page 12: Learn with WSO2 - API Security

Third-­‐party  applications  gain  overly  broad  access  to  the  resource  owner's  protected  resources,  leaving  resource  owners  without  any  ability  to  restrict  duration  or  access  to  a  limited  

subset  of  resources.  

Page 13: Learn with WSO2 - API Security

Resource  owners  cannot  revoke  access  to  an  individual  third-­‐party  without  revoking  access  to  all  third-­‐parties,  and  must  do  

so  by  changing  their  password.  

Page 14: Learn with WSO2 - API Security

Compromise  of  any  third-­‐party  application  results  in  compromise  of  the  end-­‐user's  password  and  all  of  the  data  

protected  by  that  password.  

Page 15: Learn with WSO2 - API Security
Page 16: Learn with WSO2 - API Security
Page 17: Learn with WSO2 - API Security
Page 18: Learn with WSO2 - API Security
Page 19: Learn with WSO2 - API Security
Page 20: Learn with WSO2 - API Security
Page 21: Learn with WSO2 - API Security

•  Complexity  in  validating  and  generating  signatures.  •  No  clear  separation  between  Resource  Server  and  

Authorization  Server.  •  Browser  based  re-­‐redirections.  •  Not  a  framework  

Page 22: Learn with WSO2 - API Security

•  An  entity  capable  of  granting  access  to  a  protected  resource.    

•  When  the  resource  owner  is  a  person,  it  is  referred  to  as  an  end-­‐user.  

Page 23: Learn with WSO2 - API Security

•  The  server  hosting  the  protected  resources,  capable  of  accepting  and  responding  to  protected  resource  requests  using  access  tokens.  

Page 24: Learn with WSO2 - API Security

•  An  application  making  protected  resource  requests  on  behalf  of  the  resource  owner  and  with  its  authorization  

Page 25: Learn with WSO2 - API Security

•  The  server  issuing  access  tokens  to  the  client  after  successfully  authenticating  the  resource  owner  and  obtaining  authorization  

Page 26: Learn with WSO2 - API Security
Page 27: Learn with WSO2 - API Security

Authorization  Code  

Implicit  

Resource  Owner  Password  Credentials  

Client  Credentials  

Page 28: Learn with WSO2 - API Security

OAuth  Handshake  

Scope  

Page 29: Learn with WSO2 - API Security

OAuth  Handshake  

Scope  

Scope  is  defined  by  the  Authorization  Server.    

Scope  indicates  what  resource  client  wants  access  and  which  actions  he  wants  to  perform  on  that.  

 The  value  of  the  scope  parameter  is  expressed  as  a  list  of  

space-­‐delimited,  case  sensitive  strings.        

The  strings  are  defined  by  the  authorization  server.    

Page 30: Learn with WSO2 - API Security

Confidential  Client  Type    

Web  Application  

OAuth  Handshake  

Page 31: Learn with WSO2 - API Security

Client  Authenticates  to  AuthZ  Server  

BasicAuth   client_id  /  client_secret  

OAuth  Handshake  

Page 32: Learn with WSO2 - API Security

Authorization  Grant  Request  

OAuth  Handshake  

•   response_type  :  REQUIRED.    Value  MUST  be  set  to  "code".  •   client_id  :  REQUIRED.    The  client  identifier.  •   redirect_uri  :  OPTIONAL.    Where  to  be  redirected  by  the  Authorization  Server.  •   scope  :  OPTIONAL.    The  scope  of  the  access  request.  •   state  :  RECOMMENDED.    An  opaque  value  used  by  the  client  to  maintain  state  

between  the  request  and  callback.  

Page 33: Learn with WSO2 - API Security

Authorization  Grant  Response  

OAuth  Handshake  

•   code:  REQUIRED.  The  authorization  code  generated  by  the  authorization  server  •   state  :  REQUIRED  if  the  "state"  parameter  was  present  in  the  client  authorization  

request.  

Page 34: Learn with WSO2 - API Security

Access  Token  Request  

OAuth  Handshake  

•  grant_type  :  REQUIRED.    Value  MUST  be  set  to  "authorization_code".  •  code  :  REQUIRED.    The  authorization  code  received  from  the  Authorization  Server.  •  redirect_uri  :  REQUIRED,  if  the  "redirect_uri"  parameter  was  included  in  the  

authorization    

Page 35: Learn with WSO2 - API Security

Access  Token  Response  

OAuth  Handshake  

•  access_token  :  REQUIRED.    The  access  token  issued  by  the  authorization  server.  •  token_type  :  REQUIRED.    The  type  of  the    token.  Value  is  case  insensitive.  •  expires_in  :  RECOMMENDED.    The  lifetime  in  seconds  of  the  access  token  

Page 36: Learn with WSO2 - API Security

OAuth  Handshake  

Scope  

Page 37: Learn with WSO2 - API Security

Public  Client  Type    

User  Agent  based  Application  

OAuth  Handshake  

Page 38: Learn with WSO2 - API Security

Anonymous  Clients  

OAuth  Handshake  

Page 39: Learn with WSO2 - API Security

OAuth  Handshake  

Authorization  Grant  Request  

•   response_type  :  REQUIRED.    Value  MUST  be  set  to  ”token".  •   client_id  :  REQUIRED.    The  client  identifier.  •   redirect_uri  :  OPTIONAL.    Where  to  be  redirected  by  the  Authorization  Server.  •   scope  :  OPTIONAL.    The  scope  of  the  access  request.  •   state  :  RECOMMENDED.    An  opaque  value  used  by  the  client  to  maintain  state  

between  the  request  and  callback.  

Page 40: Learn with WSO2 - API Security

Access  Token  Response  

OAuth  Handshake  

•  access_token  :  REQUIRED.    The  access  token  issued  by  the  authorization  server.  •  token_type  :  REQUIRED.    The  type  of  the    token.  Value  is  case  insensitive.  •  expires_in  :  RECOMMENDED.    The  lifetime  in  seconds  of  the  access  token  •  scope  :    OPTIONAL,  if  identical  to  the  scope  requested  by  the  client,  otherwise  

REQUIRED.  •  state  :  REQUIRED  if  the  "state"  parameter  was  present  in  the  client  authorization  

request  

Page 41: Learn with WSO2 - API Security

OAuth  Handshake  

Scope  

Page 42: Learn with WSO2 - API Security

Confidential  Client  Type    

OAuth  Handshake  

Page 43: Learn with WSO2 - API Security

BasicAuth  

OAuth  Handshake  

Page 44: Learn with WSO2 - API Security

OAuth  Handshake  

Authorization  Grant  Request  

Since  the  client  authentication  is  used  as  the  authorization  grant,  no  additional  authorization  request  is  needed.  

 

Page 45: Learn with WSO2 - API Security

OAuth  Handshake  

Access  Token  Request  

•  grant_type  :  REQUIRED.    Value  MUST  be  set  to  ”client_credentials".  •  scope:  OPTIONAL.    The  scope  of  the  access  request.  

Note  :  The  client  needs  to  pass  BasicAuth  headers  or  authenticate  to  the  Authorization  Server  in  other  means.    

Page 46: Learn with WSO2 - API Security

Access  Token  Response  

OAuth  Handshake  

•  access_token  :  REQUIRED.    The  access  token  issued  by  the  authorization  server.  •  token_type  :  REQUIRED.    The  type  of  the    token.  Value  is  case  insensitive.  •  expires_in  :  RECOMMENDED.    The  lifetime  in  seconds  of  the  access  token  

Page 47: Learn with WSO2 - API Security

OAuth  Handshake  

Scope  

Page 48: Learn with WSO2 - API Security

Confidential  Client  Type    

OAuth  Handshake  

Page 49: Learn with WSO2 - API Security

BasicAuth  

OAuth  Handshake  

Page 50: Learn with WSO2 - API Security

OAuth  Handshake  

Authorization  Grant  Request  

The  method  through  which  the  client  obtains  the  resource  owner        credentials  is  beyond  the  scope  of  this  specification.    The  client  

     MUST  discard  the  credentials  once  an  access  token  has  been  obtained  

Page 51: Learn with WSO2 - API Security

OAuth  Handshake  

Access  Token  Request  

•  grant_type  :  REQUIRED.    Value  MUST  be  set  to  ”client_credentials".  •  username  :  REQUIRED.    The  resource  owner  username,  encoded  as  UTF-­‐8.  •  password  :  REQUIRED.    The  resource  owner  password,  encoded  as  UTF-­‐8.  •  scope:  OPTIONAL.    The  scope  of  the  access  request.  

Page 52: Learn with WSO2 - API Security

Access  Token  Response  

OAuth  Handshake  

•  access_token  :  REQUIRED.    The  access  token  issued  by  the  authorization  server.  •  token_type  :  REQUIRED.    The  type  of  the    token.  Value  is  case  insensitive.  •  expires_in  :  RECOMMENDED.    The  lifetime  in  seconds  of  the  access  token  

Page 53: Learn with WSO2 - API Security

Runtime  

Page 54: Learn with WSO2 - API Security

Runtime  

Bearer   MAC  

Page 55: Learn with WSO2 - API Security

Runtime  

Bearer   MAC  

Any  party  in  possession  of  a  bearer  token  (a  "bearer")  can  use  it  to  get  access  to  the  associated  resources  (without  demonstrating  possession  of  a  cryptographic  key).  

Bearer  

Page 56: Learn with WSO2 - API Security

Request  with  Bearer  

GET  /resource/1  HTTP/1.1  Host:  example.com  Authorization:  Bearer  “access_token_value”  

Runtime  

http://tools.ietf.org/html/draft-­‐ietf-­‐oauth-­‐v2-­‐bearer-­‐20  

Page 57: Learn with WSO2 - API Security

Runtime  

Bearer   MAC  

HTTP  MAC  access  authentication  scheme  

MAC  

Page 58: Learn with WSO2 - API Security

Request  with  MAC  

GET  /resource/1  HTTP/1.1  Host:  example.com    Authorization:  MAC  id="h480djs93hd8",                                                                                        ts="1336363200”,                                                                                        nonce="274312:dj83hs9s",                                                                                        mac="kDZvddkndxvhGRXZhvuDjEWhGeE="  

Runtime  

http://tools.ietf.org/html/draft-­‐ietf-­‐oauth-­‐v2-­‐http-­‐mac-­‐01  

Page 59: Learn with WSO2 - API Security