from zero to hero with rest and oauth2 #jjug

38
‹#› © 2016 Pivotal Software, Inc. All rights reserved. From Zero to Hero with REST and OAuth2 Toshiaki Maki (@making) JJUG Night Seminar June 2016 2016-06-27

Upload: toshiaki-maki

Post on 06-Jan-2017

1.259 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved. ‹#›© 2016 Pivotal Software, Inc. All rights reserved.

From Zero to Hero with REST and OAuth2

Toshiaki Maki (@making) JJUG Night Seminar June 2016 2016-06-27

Page 2: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

Who am I ?• Toshiaki Maki (@making)

•Sr. Solutions Architect

•Spring Framework enthusiast

Perfect Java EE

(Coming Soon)

bit.ly/spring-book

Page 3: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

Spring Boot

Page 4: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

Spring Initializr https://start.spring.io/

Page 5: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

Spring Initializr https://start.spring.io/

Page 6: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

Spring Initializr https://start.spring.io/

Page 7: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

Spring Initializr https://start.spring.io/

Page 8: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

Today's topic

Web UI

Resource Server

Resource Server

Resource Server

Page 9: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

Today's topic

Web UI

Resource Server

Resource Server

Resource Server

🔐🔐🔐

Page 10: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

Today's topic

Web UI

Resource Server

Resource Server

Resource Server

🔐🔐🔐

Page 11: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

Today's topic

Web UI

Resource Server

Resource Server

Resource Server

🔐🔐🔐

❓ ❓ • Basic • OAuth2 • Spring Session • SAML

Page 12: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

Today's topic

Web UI

Resource Server

Resource Server

Resource Server

🔐🔐🔐

❓ ❓ • Basic • OAuth2 • Spring Session • SAML

👈

Page 13: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

Today's topic

Authorization Server

Web UI

Resource Server

OAuth2

REST API + Access Token + SSO

Page 14: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

Live Coding!!•Spring Data REST

•Spring Security OAuth2

•@EnableAuthorizationServer

•@EnableResourceServer

•@EnableOAuth2Sso

• JWT

• Zuul Integration

Page 15: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

OAuth2

Page 16: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

OAuth2 - Terminologies •Resource Owner •Client •Authorization Server •Resource Server

Page 17: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

Authorization Server

CUI

Resource Server

Resource Owner Password Credentials (grant_type=password)

Page 18: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

Authorization Server

CUI

Resource Server

username & password

Resource Owner Password Credentials (grant_type=password)

Page 19: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

Authorization Server

CUI

Resource Server

username & password

token

Resource Owner Password Credentials (grant_type=password)

Page 20: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

Authorization Server

CUI

Resource Server

username & password

token

token

Resource Owner Password Credentials (grant_type=password)

Page 21: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

Authorization Server

CUI

Resource Server

username & password

token

token

response

Resource Owner Password Credentials (grant_type=password)

Page 22: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

Authorization Code (grant_type=authorization_code)

Authorization Server

Web UI

Resource Server

Page 23: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

Authorization Code (grant_type=authorization_code)

Authorization Server

Web UI

Resource Server

authorize

Page 24: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

Authorization Code (grant_type=authorization_code)

Authorization Server

Web UI

Resource Server

authorize

redirect

Page 25: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

Authorization Code (grant_type=authorization_code)

Authorization Server

Web UI

Resource Server

authorize

redirect

code

Page 26: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

Authorization Code (grant_type=authorization_code)

Authorization Server

Web UI

Resource Server

authorize

redirect

codecode

Page 27: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

Authorization Code (grant_type=authorization_code)

Authorization Server

Web UI

Resource Server

authorize

redirect

codecode

token

Page 28: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

Authorization Code (grant_type=authorization_code)

Authorization Server

Web UI

Resource Server

authorize

redirect

codecode

token

token

Page 29: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

Authorization Code (grant_type=authorization_code)

Authorization Server

Web UI

Resource Server

authorize

redirect

codecode

token

token

response

Page 30: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

Authorization Server

Web UI

Resource Server

OAuth2

REST API + Access Token

Page 31: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

Authorization Server

Web UI

Resource Server

OAuth2

REST API + Access Token

userinfo

Page 32: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

Authorization Server

Web UI

Resource Server

OAuth2

REST API + Access Token

userinfo

every time

Page 33: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

JWT

Authorization Server

Web UI

Resource Server

OAuth2

REST API + Access Token (JWT)

Page 34: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

JWT

Authorization Server

Web UI

Resource Server

OAuth2

REST API + Access Token (JWT)

token_key

Page 35: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

JWT

Authorization Server

Web UI

Resource Server

OAuth2

REST API + Access Token (JWT)

token_key

at startup

Page 36: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

JWT

Authorization Server

Web UI

Resource Server

OAuth2

REST API + Access Token (JWT)

token_key

at startup

Verify token

Page 37: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

Links• https://github.com/Pivotal-Japan/from-zero-to-hero-with-rest-

and-oauth2

• http://www.slideshare.net/WillTran1/securing-microservices-with-spring-cloud-security

Page 38: From Zero to Hero with REST and OAuth2 #jjug

‹#›© 2016 Pivotal Software, Inc. All rights reserved.

Announce• Josh Long(@starbuxman) comes to Tokyo on July 6th !!

https://jsug.doorkeeper.jp/events/47900