secure rest api on microservices vws2016

26
Secure REST API on Microservices Nguyễn Minh Quý Head of Technology at Bizweb Bizweb.vn

Upload: quy-nguyen-minh

Post on 21-Jan-2017

78 views

Category:

Technology


4 download

TRANSCRIPT

Page 1: Secure rest api on microservices  vws2016

Secure REST API on Microservices

Nguyễn Minh QuýHead of Technology at BizwebBizweb.vn

Page 2: Secure rest api on microservices  vws2016
Page 3: Secure rest api on microservices  vws2016

Bizweb Rest API Security

Page 4: Secure rest api on microservices  vws2016

Private AppsWeb Apps Mobile Apps ERP SystemsPublic Apps

BizwebAPIs

Page 5: Secure rest api on microservices  vws2016

Authentication and Authorization for Microservices

1. Centralized authen/author 2. authen/author on each microservices

Token Validation Gateway

MicroservicesMicroservices

Token Validation

API GatewayToken Relay

Microservices Token

Validation

Microservices Token

ValidationMicroservices Microservices

Page 6: Secure rest api on microservices  vws2016

Private AppsMobile Apps Public AppsWeb Apps ERP Systems

BizwebAPIs

1st Party Apps

Page 7: Secure rest api on microservices  vws2016

Client Credentials• Basic Auth + Session Auth• Call between microservices• 1st App: backend, frontend,

theme store, app store …

Page 8: Secure rest api on microservices  vws2016

Private AppsWeb Apps Mobile Apps ERP SystemsPublic Apps

BizwebAPIs

Page 9: Secure rest api on microservices  vws2016

Authorization Code Flow• OAuth 2

• Resource Owner (RO): the user• Client: the web or mobile app• Authorization Service (AS):

OAuth 2.0 server• Resource Server (RS): where

the actual service is stored

Public Apps – 3rd Apps

Page 10: Secure rest api on microservices  vws2016

Private AppsWeb Apps ERP SystemsPublic AppsMobile Apps

BizwebAPIs

Page 11: Secure rest api on microservices  vws2016

xAuth - Mobile• OAuth2• Resource Owner

Password Credentials Grant

(Mobile App)

Page 12: Secure rest api on microservices  vws2016

Web Apps Mobile Apps ERP SystemsPublic AppsPrivate Apps

BizwebAPIs

Page 13: Secure rest api on microservices  vws2016

Basic Auth - Private Apps

• HTTP Authentication• HTTPS

Page 14: Secure rest api on microservices  vws2016

14

Bizweb Authentication & Authorization

Page 15: Secure rest api on microservices  vws2016

Rest API Rate Limit

Page 16: Secure rest api on microservices  vws2016

Rate-Limiting Best Practices• Authenticated • Have a standard, application wide rate limit • Custom limit for each user, application

• Unauthenticated • Based on domain or IP address • Allow limit to be overridden as well

Page 17: Secure rest api on microservices  vws2016

17

Public API Rate Limit Filter• Leaky Bucket algorithm (Fill Rate: 2

request/s, Bucket Size: 40)• Http Header Response:

X-Bizweb-Api-Call-Limit: 16/40• 16: Used requests• 40: Maximum requests

• When an client exceeds : response code 429 - Too Many Requests

Page 18: Secure rest api on microservices  vws2016

API Monitoring

Page 19: Secure rest api on microservices  vws2016

Why Monitor?

Page 20: Secure rest api on microservices  vws2016

Why Monitor?• You need to know if your application is working correctly • Understand what needs to be fixed when something goes wrong• Detect and prevent attacks

Page 21: Secure rest api on microservices  vws2016

API monitoring – Key metrics• Availability• Throughput• Response time• Errors• Notifications

Page 22: Secure rest api on microservices  vws2016

API monitoring

Page 23: Secure rest api on microservices  vws2016

API monitoring

Page 24: Secure rest api on microservices  vws2016
Page 25: Secure rest api on microservices  vws2016

Summary• Using flexible authorization grant for microservices• OAuth 2.0 is a standard, and has a lot of useful features• API Rate limit• All request to your API must be through HTTPS, reject otherwise.• Log all request to your API

Page 26: Secure rest api on microservices  vws2016

Thank you!Q&A