Slide 1

Slide 1 text

Micro Frontends for Java Microservices June 27, 2023 Matt Raible | @mraible Photo by Pieter van de Sande 
 https://unsplash.com/photos/r6BdUpN_iSk

Slide 2

Slide 2 text

@mraible Hi, I’m Matt Raible Father, Husband, Skier, Mountain Biker, Whitewater Rafter Bus Lover Web Developer and Java Champion Okta Developer Advocate Blogger on raibledesigns.com and developer.okta.com/blog @mraible

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

developer.okta.com

Slide 7

Slide 7 text

developer.auth0.com

Slide 8

Slide 8 text

Agenda A brief history of microservices Microservices with Java Microservices with JHipster Introduction to Micro Frontends Live Demo Securing microservices with OAuth 2.1 Action!

Slide 9

Slide 9 text

Microservices Visionaries

Slide 10

Slide 10 text

“Any organization that designs a system (defined broadly) will produce a design whose structure is a copy of the organization's communication structure.” Conway’s Law Melvin Conway 1967

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

“Do one thing and do it well.”

Slide 13

Slide 13 text

Microservices with Java

Slide 14

Slide 14 text

Spring History of Spring October 2002 - Rod Johnson writes J2EE Design & Development 2004 - Spring 1.0 2006 - Spring 2.0 with better XML 2009 - JavaConfig 2014 - Spring Boot 1.0 2015 - Spring Cloud 1.0 🍃

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

Spring WebFlux!

Slide 18

Slide 18 text

Spring MVC Code @PostMapping("/points") public ResponseEntity createPoints(@Valid @RequestBody Points points) throws URISyntaxException { log.debug("REST request to save Points : {}", points); if (points.getId() != null) { throw new BadRequestAlertException("A new points cannot already have an ID", ENTITY_NAME, "idexists"); } Points result = pointsRepository.save(points); pointsSearchRepository.save(result); return ResponseEntity .created(new URI("/api/points/" + result.getId())) .headers(HeaderUtil.createEntityCreationAlert( applicationName, true, ENTITY_NAME, result.getId().toString())) .body(result); }

Slide 19

Slide 19 text

Spring WebFlux Code @PostMapping("/points") public Mono> createPoints(@Valid @RequestBody Points points) throws URISyntaxException { log.debug("REST request to save Points : {}", points); if (points.getId() != null) { throw new BadRequestAlertException("A new points cannot already have an ID", ENTITY_NAME, "idexists"); } return pointsRepository .save(points) .flatMap(pointsSearchRepository::save) .map( result -> { try { return ResponseEntity .created(new URI("/api/points/" + result.getId())) .headers(HeaderUtil.createEntityCreationAlert( applicationName, true, ENTITY_NAME, result.getId().toString())) .body(result); } catch (URISyntaxException e) { throw new RuntimeException(e); } } ); }

Slide 20

Slide 20 text

https://developer.okta.com/blog/2021/01/20/reactive-java-microservices

Slide 21

Slide 21 text

What is JHipster?

Slide 22

Slide 22 text

Thriving OSS Project Started by Julien Dubois on October 21, 2013 App Generator, Platform, Learning Tool …

Slide 23

Slide 23 text

How to Use JHipster Install JHipster using npm: npm install -g generator-jhipster Create a directory and cd into it: take app Run it! jhipster

Slide 24

Slide 24 text

Monolith, Gateway, or Microservices? Spring MVC or Spring WebFlux? Authentication Type? Database Type? Build Tool? Web Framework? JHipster Options

Slide 25

Slide 25 text

https://start.jhipster.tech

Slide 26

Slide 26 text

https://start.jhipster.tech/jdl-studio

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

JHipster Microservices Architecture

Slide 29

Slide 29 text

JHipster Micro Frontends Architecture

Slide 30

Slide 30 text

⚡Micro Frontends https://martinfowler.com/articles/micro-frontends.html

Slide 31

Slide 31 text

Native Federation https://twitter.com/ManfredSteyer/status/1564312149580582912

Slide 32

Slide 32 text

Why should Java developers care?

Slide 33

Slide 33 text

Demo Create apps with JDL Run apps and e2e tests Run everything with Docker Switch identity providers @oktadev/auth0-micro-frontends- jhipster-example 🤓

Slide 34

Slide 34 text

Secure Microservices with OAuth 2.1 https://oauth.net/2.1

Slide 35

Slide 35 text

Improvements in OAuth 2.1 PKCE is required for all clients using the authorization code flow Redirect URIs must be compared using exact string matching The Implicit grant is omitted from this specification The Resource Owner Password Credentials grant is omitted from this specification Bearer token usage omits the use of bearer tokens in the query string of URIs Refresh tokens for public clients must either be sender-constrained or one-time use

Slide 36

Slide 36 text

yelp.com/callback Back to redirect URI with authorization code Exchange code for access token and ID token accounts.google.com Email ********** Go to authorization server Redirect URI: yelp.com/cb Scope: openid profile Authorization Server yelp.com Connect with Google Resource owner Client accounts.google.com 
 Allow Yelp to access your public profile and contacts? No Yes Request consent from resource owner Hello Matt! accounts.google Get user info 
 with access token /userinfo OAuth 2.1 and OIDC

Slide 37

Slide 37 text

Spring Cloud Gateway

Slide 38

Slide 38 text

Relay an access token in Spring Cloud Gateway spring: cloud: gateway: default-filters: - TokenRelay

Slide 39

Slide 39 text

Reactive Microservices with Spring Cloud Gateway https://developer.okta.com/blog/2019/08/28/reactive-microservices-spring-cloud-gateway

Slide 40

Slide 40 text

https://auth0.com/blog/micro-frontends-for-java-microservices

Slide 41

Slide 41 text

https://developer.okta.com/blog/2021/01/20/reactive-java-microservices

Slide 42

Slide 42 text

https://developer.okta.com/blog/2021/06/01/kubernetes-spring-boot-jhipster

Slide 43

Slide 43 text

https://dev.to/jhipster

Slide 44

Slide 44 text

npm install -g generator-jhipster-kotlin

Slide 45

Slide 45 text

JHipster Official Blueprints https://www.jhipster.tech/modules/official-blueprints

Slide 46

Slide 46 text

https://github.com/jhipster/jhipster-lite

Slide 47

Slide 47 text

What You Learned

Slide 48

Slide 48 text

What’s Next for JHipster? GraalVM Spring Boot 3.1 GraphQL * These are my personal interests.

Slide 49

Slide 49 text

JHipster is Knowledge

Slide 50

Slide 50 text

JHipster ❤ Open Collective https://opencollective.com/generator-jhipster

Slide 51

Slide 51 text

The JHipster Mini-Book 
 Written with Asciidoctor Free download from InfoQ: infoq.com/minibooks/jhipster-mini-book Quick and to the point, 158 pages Developed a real-world app: www.21-points.com Buy for $20 or download for FREE

Slide 52

Slide 52 text

The Angular Mini-Book 
 Written with Asciidoctor Free download from InfoQ: infoq.com/minibooks/angular-mini-book Angular 15 and Spring Boot 3.0 Angular Material, Bootstrap, Kotlin Spring Security and best practices Deploy separate apps and a single artifact

Slide 53

Slide 53 text

Learn More stackoverflow.com Spring Boot spring.io/guides JHipster www.jhipster.tech Auth0 developer.auth0.com

Slide 54

Slide 54 text

developer.auth0.com @oktadev

Slide 55

Slide 55 text

Action: Try JHipster! 🚀 npm i -g generator-jhipster

Slide 56

Slide 56 text

git clone https://github.com/oktadeveloper/okta-spring-web fl ux-react-example.git https://github.com/oktadev/auth0-micro-frontends-jhipster-example Use the Source, Luke!

Slide 57

Slide 57 text

Thanks! Keep in Touch raibledesigns.com @mraible Presentations speakerdeck.com/mraible Code github.com/oktadev developer.okta.com developer.auth0.com

Slide 58

Slide 58 text

developer.okta.com