Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security...

60
Rest Services with Play Framework, Adding Security with JWT Seoul

Transcript of Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security...

Page 1: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,

Rest Services with Play Framework,

Adding Security with JWT

Seoul

Page 2: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,

Mercedes Wyss @itrjwyss

CommunityLeaderJDuchessChapterGuatemala,Devs+502

Ex-JUGMemberGuatemalaJavaUsersGroup(GuateJUG)

ChiefTechnologyOfficer(CTO)atProduactivityFullStackDeveloper,Front-endyBack-endwithJava,Mobile

DevelopmentAndroidandiOS

Auth0TechnologiesAmbassador

Page 3: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,

Agenda

• Play Framework • Web Services Restful • JSONs • JWT (Json Web Tokens)

Page 4: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,

Agenda

• Play Framework • Web Services Restful • JSONs • JWT (Json Web Tokens)

Page 5: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,
Page 6: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,

Play Framework

• Makes it easy to build web applications with Java and Scala.

• Is based on a lightweight, stateless, web-friendly architecture.

• Built on Akka, provides predictable and minimal resources consumption (CPU, memory, threads) for

highly-scalable applications.

Page 7: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,
Page 8: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,

Server:1CPU1GBRam

Page 9: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,
Page 10: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,

JavaorScala

Page 11: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,

IsReactive

Page 12: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,

MVCArchitecture

Page 13: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,

AppServer

SinceVersion2.6.x

FewerConfigurations

Page 14: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,

JRebelBehaviorMorecode,Lessdeploys

Page 15: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,

HowstartaPlayproject?WeneedtouseSBT

Createsbtnewplayframework/play-scala-seed.g8sbtnewplayframework/play-java-seed.g8

Deploysbtrun

Page 16: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,

$ sbt new playframework/play-java-seed.g8

This template generates a Play Java project

name [play-java-seed]: OracleCodeSeul organization [com.example]: com.produactivity scala_version [2.12.2]: play_version [2.6.1]:

Template applied in ./oraclecodeseul

$

Page 17: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,

$ cd oraclecodeseul/ Oraclecodeseul $ sbt run

Page 18: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,
Page 19: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,
Page 20: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,

Full Project Structure

Page 21: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,

Simple

Project Structure

Page 22: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,
Page 23: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,
Page 24: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,
Page 25: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,
Page 26: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,
Page 27: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,

Agenda

• PlayFramework• WebServicesRestful• JSONs• JWT(JsonWebTokens)

Page 28: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,
Page 29: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,

WebServices

• HyperTextTransferProtocol(HTTP)• Allowscommunicationbetweenaclientandaserver• Provideastandardmeansofinteroperatingbetweendifferent

softwareapps• Characterizedforinteroperabilityandextensibility• BasedonXML

Page 30: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,

Linda.com(June2017)https://www.lynda.com/Software-Development-tutorials/What-web-service/126131/145941-4.html

Page 31: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,

SOAP

• SimpleObjectAccessProtocol• XML-based• UseWSDLasspecificationdescription(WebServicesDescriptionLanguage)• Needtofollowacommunicationprotocol

Page 32: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,
Page 33: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,
Page 34: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,

Restful

• SoftwareArchitecturebasedonHTTPmethods(Get,Post,Put,Delete,etc)• TypicallyuseJSON,butcanuseXML,Text

Page 35: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,
Page 36: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,

MadhaiyanMuthu(June2017)https://www.slideshare.net/madhaiyanm/web-services-a-practical-approach

Page 37: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,
Page 38: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,

415bytes

Page 39: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,

415bytes

57bytes

Page 40: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,

Difference• Ifwearesendingaxml

of415bytes,wearesending358bytesmore

• Ifwearesendingajson of415bytes,wearesending358bytesless

• Thereis86%ofmoreorlessinformation

Page 41: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,
Page 42: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,
Page 43: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,
Page 44: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,

Agenda

• PlayFramework• WebServicesRestful• JSONs• JWT(JsonWebTokens)

Page 45: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,
Page 46: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,

JSON

• JavaScriptObjectNotation• Isalightweightdata-interchangeformat• Self-describing• Human-reading• IsaProtocol

Page 47: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,

JSONExample

Page 48: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,

JSONScheme

Page 49: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,
Page 50: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,
Page 51: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,
Page 52: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,
Page 53: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,

Agenda

• PlayFramework• WebServicesRestful• JSONs• JWT(JsonWebTokens)

Page 54: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,
Page 55: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,

JWT

Isanopenstandard(RFC7519)thatdefinesacompactandself-containedwayforsecurelytransmittinginformation

betweenpartiesasaJSONobject.

Page 56: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,

Auth0(June2017)https://cdn.auth0.com/content/jwt/jwt-diagram.png

Page 57: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,

JWTStructure

Page 58: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,

JWTStructure

Page 59: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,

JWTStructure

Page 60: Rest Services with Play Framework, Adding Security with JWT€¦ · Play Framework, Adding Security with JWT Seoul. Mercedes Wyss @itrjwyss Community Leader JDuchess Chapter Guatemala,

To End Let’s See the Magic Live

México