enabling cloud native security with oauth2 and multi-tenant uaa

89
Enabling Cloud Native Security with Multi-Tenant UAA William Tran, Pivotal

Upload: will-tran

Post on 15-Apr-2017

3.129 views

Category:

Software


3 download

TRANSCRIPT

Page 1: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

Enabling Cloud Native Securitywith Multi-Tenant UAA

William Tran, Pivotal

Page 2: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

Agenda

• Introductions• Why use UAA for Cloud Native

Applications• Advantages of Multi-tenant UAA• How to get started

Page 3: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

Introductions

Page 4: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

About Me

• Spring user since version 2.0 (2007)• Joined Pivotal October 2013• Based in Toronto, Canada• Working on Pivotal CF Services

– Mobile Services API Gateway– Pivotal SSO– Spring Cloud Services

• Committer on UAA

Page 5: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

About UAA

• User Account and Authorization server• Secures all CF components• OAuth2 and OpenID Connect• SCIM API for user management in

internal user database• Integration with SAML 2.0 and LDAP• OAuth2 client registration API

Page 6: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

About OAuth2

• Delegated Authorization• 4 Actors

– The Authorization Server– User– Client– Resource Server

• Clients act on behalf of users– Authorization Code Grant– Resource Owner Password Grant– Implicit Grant

• Clients act on their own– Client Credentials Grant

Page 7: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

OAuth2 In Cloudfoundry

• Apps Manager (PWS or PCF)

Page 8: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

OAuth2 In Cloudfoundry

• Apps Manager– Go to apps.cfdomain in the browser

UAA(login.)

Apps Manager(apps.)

Cloud Controller

(api.)Browser

Page 9: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

OAuth2 In Cloudfoundry

• Apps Manager– Apps manager redirects you to UAA

UAA(login.)

Apps Manager(apps.)

Cloud Controller

(api.)Browser

Not logged in!

Page 10: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

OAuth2 In Cloudfoundry

• Apps Manager– Apps manager redirects you to UAA

UAA(login.)

Apps Manager(apps.)

Cloud Controller

(api.)Browser

Page 11: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

OAuth2 In Cloudfoundry

• Apps Manager– UAA asks for username and password

UAA(login.)

Apps Manager(apps.)

Cloud Controller

(api.)Browser

Please log in

Page 12: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

OAuth2 In Cloudfoundry

• Apps Manager– User logs in

UAA(login.)

Apps Manager(apps.)

Cloud Controller

(api.)Browser

Here is the username and

password

Page 13: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

OAuth2 In Cloudfoundry

• Apps Manager– UAA redirects back to Apps Manager with a

one time code

UAA(login.)

Apps Manager(apps.)

Cloud Controller

(api.)Browser

Here is an authorization

code

Page 14: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

OAuth2 In Cloudfoundry

• Apps Manager– UAA redirects back to Apps Manager with a

one time code

UAA(login.)

Apps Manager(apps.)

Cloud Controller

(api.)Browser

Here is an authorization

code

Page 15: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

OAuth2 In Cloudfoundry

• Apps Manager– Apps Manager gives the code back to UAA

UAA(login.)

Apps Manager(apps.)

Cloud Controller

(api.)Browser

Here is the same authorization code

Page 16: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

OAuth2 In Cloudfoundry

• Apps Manager– UAA exchanges the code for an access

token

UAA(login.)

Apps Manager(apps.)

Cloud Controller

(api.)Browser

The code is the same, here is a token

Page 17: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

OAuth2 In Cloudfoundry

• Apps Manager– Apps manager uses the access token to

access the CC API

UAA(login.)

Apps Manager(apps.)

Cloud Controller

(api.)Browser

/v2/apps -H “Authorization: bearer

eyJhbGci…”

Page 18: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

OAuth2 In Cloudfoundry

• Apps Manager– Apps manager renders the page

UAA(login.)

Apps Manager(apps.)

Cloud Controller

(api.)Browser

Here is the the pretty screen,

finally!

Page 19: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

OAuth2 In Cloudfoundry

• Apps Manager– Authorization Code Grant– Typical of web applications– Apps manager webapp is the client

Page 20: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

OAuth2 In Cloudfoundry

• CF CLI

cf target api.cfdomaincf logincf apps

Page 21: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

OAuth2 In Cloudfoundry

• CF CLI– cf login

UAA(login.)

Cloud Controller

(api.)CF CLI

Here is the username and

password

Page 22: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

OAuth2 In Cloudfoundry

• CF CLI– cf login

UAA(login.)

Cloud Controller

(api.)CF CLI

Here is a token

Page 23: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

OAuth2 In Cloudfoundry

• CF CLI– cf login

UAA(login.)

Cloud Controller

(api.)CF CLI

/v2/apps -H “Authorization: bearer

eyJhbGci…”

Page 24: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

OAuth2 In Cloudfoundry

• CF CLI– Resource Owner Password Grant– Typical of CLI, Mobile Apps, non-browser

user apps– CF CLI is the client

Page 25: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

OAuth2 In Cloudfoundry

• Autoscaling Service (PCF)

my-appAutoscaler

I’m getting very busy!

Page 26: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

OAuth2 In Cloudfoundry

• Autoscaling Service (PCF)

my-appAutoscaler

Don’t worry, I’ll create more instances

Page 27: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

OAuth2 In Cloudfoundry

• Autoscaling Service (PCF)

my-appAutoscalermy-app

Page 28: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

OAuth2 In Cloudfoundry

• Autoscaling Service (PCF)

my-appAutoscalermy-app

my-app

Page 29: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

OAuth2 In Cloudfoundry

• Autoscaling Service (PCF)

UAA(login.)

Cloud Controller

(api.)Autoscaler

Time to check status!

Page 30: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

OAuth2 In Cloudfoundry

• Autoscaling Service (PCF)

UAA(login.)

Cloud Controller

(api.)Autoscaler

Here is my client_id and client_secret

Page 31: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

OAuth2 In Cloudfoundry

• Autoscaling Service (PCF)

UAA(login.)

Cloud Controller

(api.)Autoscaler

Here is a token

Page 32: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

OAuth2 In Cloudfoundry

• Autoscaling Service (PCF)

UAA(login.)

Cloud Controller

(api.)Autoscaler

/v2/apps/1234/stats -H “Authorization: bearer eyJhbGci…”

Page 33: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

OAuth2 In Cloudfoundry

• Autoscaling Service (PCF)

UAA(login.)

Cloud Controller

(api.)Autoscaler

CPU at 80%!

Page 34: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

OAuth2 In Cloudfoundry

• Autoscaling Service (PCF)

UAA(login.)

Cloud Controller

(api.)Autoscaler

PUT /v2/apps/1234 -H “Authorization: bearer eyJhbGci…”

-d ‘{"instances":2}’

Page 35: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

OAuth2 In Cloudfoundry

• Autoscaling Service (PCF)

UAA(login.)

Cloud Controller

(api.)Autoscaler

OK, creating more

instances

Page 36: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

OAuth2 In Cloudfoundry

• Autoscaling Service (PCF)– Client Credentials Grant– Typical of apps that act without a user’s

involvement– Autoscaling Service is the client

Page 37: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

OAuth2 In Cloudfoundry

• The CF platform has many more examples of using OAuth2

• UAA is the key– Manages users– Manages clients– Grants and verifies access tokens

Page 38: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

UAA is the perfect fit forCloud Native Security*

Page 39: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

UAA for Cloud Native Security

• *In CF there’s more to security than just UAA– Network security / security groups– Cross container traffic / trusted workloads– No End to end TLS

• UAA is for application-level security• It works for us, so it’ll work for you*

Page 40: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

So you want to secure your apps

• Example– You want to host your API application on

Cloud Foundry

my-cloudfoundry.cn

Page 41: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

So you want to secure your apps

• Example– You want to host your API application on

Cloud Foundry

my-cloudfoundry.cn

my-api

Page 42: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

So you want to secure your apps

• Example– It will be accessed by a web app hosted on

CF

my-cloudfoundry.cn

my-api

my-webappbrowser

Page 43: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

So you want to secure your apps

• Example– It will be accessed through a mobile app as

well

my-cloudfoundry.cn

my-api

my-webappbrowser

Mobile app

Page 44: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

So you want to secure your apps

• Perfect! Use UAA

my-cloudfoundry.cn

my-api

my-webappbrowser

Mobile app

UAA

Page 45: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

So you want to secure your apps

• Perfect! Use UAA– Client for web app authcode grant

Page 46: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

So you want to secure your apps

• Perfect! Use UAA– Client for web app authcode grant– Client for mobile app password grant

Page 47: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

So you want to secure your apps

• Perfect! Use UAA– Client for web app authcode grant– Client for mobile app password grant– API app token verification JWT signature

Page 48: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

So you want to secure your apps

• Perfect! Use UAA– Client for web app authcode grant– Client for mobile app password grant– API app token verification JWT signature

• API app can validate token on its own

Page 49: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

Who are your end users?

• SpaceDevelopers, OrgManagers– Platform users, no problem

Page 50: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

Who are your end users?

• SpaceDevelopers, OrgManagers– Platform users, no problem

• That sales guy – Not a platform user, PROBLEM

Page 51: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

Who are your end users?

jsmith jsmyth

cf set-space-role \jsmyth the-org the-space SpaceDeveloper

oops

Page 52: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

Who are your end users?

jsmith jsmyth

My app is too slow

Page 53: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

Who are your end users?

jsmith jsmyth

cf login –u jsmyth ...cf scale sales-api –m 10G

I can fix that!

Page 54: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

The Principle of Least Privilege

• You (or the application, process, module, etc) should have the minimum level of access required for performing their job

Page 55: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

The Principle of Least Privilege

• You (or the application, process, module, etc) should have the minimum level of access required for performing their job

• Salesguy should not have been added to the platform UAA

Page 56: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

Solutions?

• Create your own authorization server• Deploy your own UAA

Page 57: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

So you want to secure your products

• Example– You want to build a product that’s packaged

as a CF service

my-cloudfoundry.cn

my-service

Page 58: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

So you want to secure your products

• Example– When apps bind to the service…

my-cloudfoundry.cn

my-service my-app

cf bind-service

Page 59: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

So you want to secure your products

• Example– Create an oauth client

my-cloudfoundry.cn

my-service my-app

UAAPOST

/oauth/client

Page 60: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

So you want to secure your products

• Example– Create an oauth client

my-cloudfoundry.cn

my-service my-app

UAA 201: Created

Page 61: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

my-cloudfoundry.cn

So you want to secure your products

• Example– So that the app to service communication

can be secured by OAuth2 client credentials grant

my-service my-app

UAAThe client_id and client_secret are in

VCAP_SERVICES

Page 62: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

my-cloudfoundry.cn

So you want to secure your products

• Example– So that the app to service communication

can be secured by OAuth2 client credentials grant

my-service my-app

UAAGET /api/foo

-H ‘Authorization: bearer eyJhbGci…’

Page 63: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

So you want to secure your products

• Perfect! Use UAA– App to app communication client

credentials– Token verification JWT signature– Every app gets their own credentials

• Super secure right?

Page 64: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

How do you create clients in UAA?

• POST /oauth/clients– Token must have scope clients.write

• Creating clients with authorities– Eg the app gets a token with my-

service.read scope– Requires clients.write and uaa.admin

• So give your service admin credentials?

Page 65: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

Admin-Level Credentials

my-service

• client_id: my-service• client_secret: 123xyz• authorities: clients.write,

uaa.admin• authorized_grant_types:

client_credentials

Page 66: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

Admin-Level Credentials

my-service

• CLIENT_ID: my-service• CLIENT_SECRET: 123xyz

Page 67: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

Admin-Level Credentials

my-service

• CLIENT_ID: my-service• CLIENT_SECRET: 123xyz

I got root, yo.

Page 68: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

Admin-Level Credentials

my-service

• CLIENT_ID: my-service• CLIENT_SECRET: 123xyz

This job sucks.cf env my-service

Page 69: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

Admin-Level Credentials

$ uaac target uaa.my-cloudfoundry.cn

$ uaac token client get my-service \-s 123xyz

$ uaac client add my-admin-client \–authorities cloud_controller.admin

Page 70: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

Admin-Level Credentials

I got root yo. Lets have some fun.

Page 71: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

The Principle of Least Privilege

• You (or the application, process, module, etc) should have the minimum level of access required for performing their job

Page 72: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

The Principle of Least Privilege

• You (or the application, process, module, etc) should have the minimum level of access required for performing their job

• Giving admin level credentials to applications is dangerous

Page 73: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

Solutions?

• Create your own authorization server• Deploy your own UAA

Page 74: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

How do you deploy your own UAA?

• cf push cloudfoundry-identity-uaa.war• Yaml config• Bootstrap users• Provision DB• Do the above manually, or as part of a

Bosh deployment

Page 75: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

Running your own UAA

• Pros:– Principle of least privilege– You can fork it

• Cons:– Overhead– Manual upgrades– “yak shaving” a bosh release

Page 76: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

Running your own UAA

• Pros:– Principle of least privilege

• Systems secured by your UAA cannot affect systems secured by the platform UAA

Page 77: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

Running your own UAA

• Pros:– Principle of least privilege

Your UAA

Page 78: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

Running your own UAA

• Pros:– Principle of least privilege

Your UAA

Platform UAA

Page 79: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

Running your own UAA

• Pros:– Principle of least privilege

Your UAA

Platform UAAImpossible!

Page 80: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

Running your own UAA

• Pros:– Principle of least privilege– You can fork it

• Cons:– Overhead– Manual upgrades– “yak shaving” a bosh release

Page 81: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

Multitenant UAA

Page 82: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

What is Multitenant UAA

• CF v208 +• The built-in UAA with subdomains• Subdomain maps to Identity Zone• Total segregation between Identity

Zones• API for creating Identity Zones• Existing API stays the same

Page 83: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

Zone administrators

• UAA users with god-like powers in an identity zone

• Requires scope zone.[zone-id].admin • Instead of targeting zone via

subdomain, use X-Identity-Zone-Id header– POST uaa.domain.com/oauth/clients

create a client in the UAA zone– POST uaa.domain.com/oauth/clients -H “X-

Identity-Zone-Id:12345” create a client in the Identity Zone with id 12345

Page 84: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

Multitenant UAA

• Pros:– Principle of least privilege– API calls for creating a new tenant (aka

Identity Zone)– Zone administrators instead of bootstrap

users• Cons:

– Overhead– Manual upgrades– “yak shaving” a bosh release– You can’t fork it

Page 85: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

Let’s Use It

Page 86: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

Multitenant UAA with UAAC

• Setup can be cumbersome– When acting as zone admin with X-Identity-

Zone-Id header, you can only uaac curl• Once you have an admin client in the

zone, uaac works great • Future enhancements

– Creating initial users / clients when the Identity Zone is created

– -z global option to target a zone via header

Page 87: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

Summary

• UAA is great for securing Cloud Native Applications

• Always use the principle of least privilege– Don’t add non-platform users to the

platform– Don’t give out platform admin abilities to

other apps• You can deploy your own UAA

– but multitenant UAA is an API call away

• Tooling needs to catch up– But once you get that admin client set up,

its easy

Page 88: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

Stay In Touch

Page 89: Enabling Cloud Native Security with OAuth2 and Multi-Tenant UAA

Stay in touch

• Me– Twitter: @fivetenwill– github.com/william-tran– [email protected]

• CF Identity PM– Sree Tummidi: [email protected]

• CF Identity Team– Issues: github.com/cloudfoundry/uaa – Discussion: lists.cloudfoundry.org