secure your apis & microservices with oauth & openid connect€¦ · üall api conferences...

48
Secure your APIs & Microservices with OAuth & OpenID Connect Copyright © 2018 Curity AB By Travis Spencer, CEO @travisspencer, @curityio

Upload: others

Post on 12-Jun-2020

20 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

Secure your APIs & Microservices with OAuth &

OpenID Connect

Copyright © 2018 Curity AB

By Travis Spencer, CEO@travisspencer, @curityio

Page 2: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

üAll API ConferencesüAPI CommunityüActive blogosphere

Organizers and founders

Austin API SummitJune 11 – 13 | Austin, Texas

2018 Platform SummitOctober 22 - 24 | Stockholm, Sweden

Page 3: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

API Security == API Keys

• Problem Solved!

@travis / @curityio Copyright © 2018 Curity AB

Page 4: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

API Security != API Keys

• Revocable, non-expiring, bearer access tokens• Symmetric keys• Passwords!

@travis / @curityio Copyright © 2018 Curity AB

Page 5: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

API Security == OAuth

• Problem solved for real this time?

Not that easy! Sorry L@travis / @curityio Copyright © 2018 Curity AB

Page 6: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

Crucial Security Concerns

Enterprise Security API Security Mobile Security

@travis / @curityio Copyright © 2018 Curity AB

Page 7: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

Identity is Central

Mobile Security

EnterpriseSecurity

API Security

MDM MAM

AuthZ

@travis / @curityio Copyright © 2018 Curity AB

Page 8: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

The Neo-security Stack

JSON Identity Suite

OpenID Connect

SCIM

OAuth 2

Provisioning

Identities

Federation

Delegated Access

Authorization

U2FAuthentication

@travis / @curityio Copyright © 2018 Curity AB

Page 9: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

OAuth

• OAuth 2 is the new protocol of protocols• Used as the base of other specifications• OpenID Connect, UMA, HEART, etc.

• Addresses some important requirements• Delegated access• No password sharing• Revocation of access

@travis / @curityio Copyright © 2018 Curity AB

Page 10: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

OAuth Actors

1. Resource Owner (RO)2. Client3. Authorization Server (AS)4. Resource Server (RS) (i.e., API) Get a token

Use a token

@travis / @curityio Copyright © 2018 Curity AB

Page 11: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

Request, Authenticate & Consent

Request Access Login Consent

@travis / @curityio Copyright © 2018 Curity AB

Page 12: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

User is redirected to OAuth server

Code Flow

APIs & microservices

@travis / @curityio Copyright © 2018 Curity AB

Page 13: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

User logs in and delegates access

Code Flow

APIs & microservices

@travis / @curityio Copyright © 2018 Curity AB

Page 14: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

Code Flow

Short-lived access code is issued to client

APIs & microservices

@travis / @curityio Copyright © 2018 Curity AB

Page 15: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

Code Flow

Code is exchanged for an access token

APIs & microservices

@travis / @curityio Copyright © 2018 Curity AB

Page 16: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

Code Flow

Access token can be used to call APIs

APIs & microservices

@travis / @curityio Copyright © 2018 Curity AB

Page 17: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

Scopes

• Like permissions• Scopes specify extent of tokens’ usefulness• Listed on consent UI (if shown)• No standardized scopes

@travis / @curityio Copyright © 2018 Curity AB

Page 18: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

Kinds of Tokens

Like a session

Refresh TokensAccess Tokens

Like a PasswordUsed to secure API calls Used to get new access tokens

@travis / @curityio Copyright © 2018 Curity AB

Page 19: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

Profiles of Tokens

Holder of Key

HoK tokens are like credit cards

Bearer

Bearer tokens are like cash

$

@travis / @curityio Copyright © 2018 Curity AB

Page 20: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

Types of Tokens

• WS-Security & SAML• Custom• Home-grown• Oracle Access Manager• SiteMinder

• CBOR Web Tokens (CWT)• JWT

@travis / @curityio Copyright © 2018 Curity AB

Page 21: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

JWT Type Tokens

• Pronounced like the English word “jot”• Lightweight tokens passed in HTTP headers & query strings• Encoded as JSON• Compact • Encrypted, signed, or neither• Not the only kind of token allowed by OAuth

@travis / @curityio Copyright © 2018 Curity AB

Page 22: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

Passing Tokens

By Value

User attributes are in the token

By Reference

User attributes are referenced by an

identifier

@travis / @curityio Copyright © 2018 Curity AB

Page 23: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

Improper Usage of OAuth

Not for authentication

Not for federation

Not really for authorization

@travis / @curityio Copyright © 2018 Curity AB

Page 24: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

Proper Usage or OAuth

For delegation

@travis / @curityio Copyright © 2018 Curity AB

Page 25: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

OpenID Connect• Next generation federation

protocol • Based on OAuth 2• Made for mobile• Not backward compatible

• Client & API receive tokens• User info endpoint provided for

client to get user data

@travis / @curityio Copyright © 2018 Curity AB

Page 26: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

OpenID Connect Examples

Get user info using access token

OAuth AS / OpenID Provider RP / Client

Browser

Access code

Send code to get access token

Access token & ID token

Check audience restriction of ID token

Request login, providing “openid” scope & user info

scopes

User info

@travis / @curityio Copyright © 2018 Curity AB

Page 27: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

ID Token is for the Client

• Access token is for API• ID token is for client• ID token provides client with info about• Intended client recipient• Username • Credential used to login• Issuer of token• Expiration time

@travis / @curityio Copyright © 2018 Curity AB

Page 28: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

User Info Endpoint

• Token issuance and user discovery endpoint• Authenticate using access token issued by

OpenID Provider• Output depends on requested and

authorized scopes• sub claim must match sub claim in ID token

@travis / @curityio Copyright © 2018 Curity AB

Page 29: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

Applied to Microservices and APIs

@travis / @curityio Copyright © 2018Curity AB

Page 30: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

A Traditional Service

@travis / @curityio Copyright © 2018 Curity AB

Page 31: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

With Traditional Subsystems

ComponentC

ComponentD

ComponentA

ComponentB

@travis / @curityio Copyright © 2018 Curity AB

Page 32: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

… and traditional scalability

@travis / @curityio Copyright © 2018 Curity AB

Page 33: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

But this is not always how we build systems

@travis / @curityio Copyright © 2018 Curity AB

Page 34: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

One Microservice

@travis / @curityio Copyright © 2018 Curity AB

Page 35: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

Many Microservices

@travis / @curityio Copyright © 2018 Curity AB

Page 36: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

Scaling Microservices

@travis / @curityio Copyright © 2018 Curity AB

Page 37: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

Securing Traditional Services

@travis / @curityio Copyright © 2018 Curity AB

Page 38: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

Securing Traditional Services

User repository

@travis / @curityio Copyright © 2018 Curity AB

Page 39: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

So for microservices that would mean…

User repository

@travis / @curityio Copyright © 2018 Curity AB

Page 40: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

Remember our two token passing methods?

By Value

User attributes are in the token

By Reference

User attributes are referenced by an

identifier

@travis / @curityio Copyright © 2018 Curity AB

Page 41: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

By Reference

Contains NO information outside the network

@travis / @curityio Copyright © 2018 Curity AB

Page 42: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

By Value

Contains ALL necessary information

@travis / @curityio Copyright © 2018 Curity AB

Page 43: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

External vs. Internal

By Value

Outside the network

By Reference

Inside the network

APIs &Services

API Firewall /Reverse Proxy

@travis / @curityio Copyright © 2018 Curity AB

Page 44: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

Token Translation

By Value

Inside the network

By Reference

Outside the network

APIs &Services

API Firewall /Reverse Proxy

@travis / @curityio Copyright © 2018 Curity AB

Page 45: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

Demo

@travis / @curityio Copyright © 2018 Curity AB

Page 46: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

Additional Resources

• Blog posts• bit.ly/oauth-deep-dive• bit.ly/4-api-security-defenses• bit.ly/building-secure-api• bit.ly/right-api-armor• https://bit.ly/2qn8Jj4

§ Videos§ bit.ly/oauth-in-depth§ bit.ly/micro-services-security§ bit.ly/building-secure-api-video

§ Whitepaper at our booth§ https://nordicapis.com/api-

insights/security/

@travis / @curityio Copyright © 2018 Curity AB

Page 47: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

Summary

• API security > API keys & OAuth• OAuth 2 fundamentals• Token types• Profiles• Passing tokens

• Building OpenID Connect on OAuth• Using those with microservices & for user-based delegation

@travis / @curityio Copyright © 2018 Curity AB

Page 48: Secure your APIs & Microservices with OAuth & OpenID Connect€¦ · üAll API Conferences üAPI Community üActive blogosphere Organizers and founders Austin API Summit June 11 –

Visit curity.io and stop by our booth

@travis / @curityio Copyright © 2018 Curity AB