SlideShare ist ein Scribd-Unternehmen logo
1 von 75
Downloaden Sie, um offline zu lesen
Microservices for the Masses with Spring Boot, JHipster, and OAuth
February 4, 2020
Matt Raible | @mraible
Photo by Magnus Johansson flickr.com/photos/120374925@N06/15138686641
Do you use microservices?
Agenda
1. Introduction to Microservices
2. Microservices with JHipster
3. Deploying to the Cloud
4. Developing Mobile Apps with JHipster
5. JHipster Roadmap
Blogger on raibledesigns.com and

developer.okta.com/blog
Web Developer and Java Champion
Father, Husband, Skier, Mountain
Biker, Whitewater Rafter
Open Source Connoisseur
Hi, I’m Matt Raible!
Bus Lover
Okta Developer Advocate
developer.okta.com
What About You?
Part 1
Introduction to Microservices
History of Microservices
Microservices Architecture Philosophy
Why Microservices?
Demo: A Microservices Architecture with
Spring Boot and Spring Cloud
Microservices Visionaries
“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
“Do one thing and do it well.”
“You shouldn't start with a microservices
architecture. Instead begin with a
monolith, keep it modular, and split it
into microservices once the monolith
becomes a problem.”
Martin Fowler March 2014
start.spring.io
Demo
Using start.spring.io, create:
A service registry
A gateway
A catalog service
Create an endpoint in the catalog service
Create a filtered endpoint in the gateway
Show failover capabilities
Show Spring Security OAuth
https://github.com/oktadeveloper/java-
microservices-examples
Create Java Microservices using start.spring.io
http https://start.spring.io/starter.zip javaVersion==11 
artifactId==discovery-service name==eureka-service 
dependencies==cloud-eureka-server baseDir==discovery-service 
| tar -xzvf -
Enable Eureka Server & Configure application.properties
server.port=8761
eureka.client.register-with-eureka=false
@EnableEurekaServer
Create Car Service
http https://start.spring.io/starter.zip 
artifactId==car-service name==car-service baseDir==car-service 
dependencies==actuator,cloud-eureka,data-jpa,h2,data-
rest,web,devtools,lombok | tar -xzvf -
Enable Discovery & Configure application.properties
server.port=8090
spring.application.name=car-service
@EnableDiscoveryClient
Create API Gateway
http https://start.spring.io/starter.zip 
artifactId==api-gateway name==api-gateway baseDir==api-gateway 
dependencies==cloud-eureka,cloud-feign,data-rest,web,cloud-
hystrix,lombok | tar -xzvf -
Enable Discovery & Configure application.properties
spring.application.name=api-gateway
@EnableDiscoveryClient
Build a REST API in Car Service
@Data
@NoArgsConstructor
@Entity
class Car {
public Car(String name) {
this.name = name;
}
@Id
@GeneratedValue
private Long id;
@NonNull
private String name;
}
Build a REST API in Car Service
@RepositoryRestResource
interface CarRepository extends JpaRepository<Car, Long> {
}
Build a REST API in Car Service
@Bean
ApplicationRunner init(CarRepository repository) {
return args -> {
Stream.of("Ferrari", "Jaguar", "Porsche", "Lamborghini",
"Bugatti", "AMC Gremlin", "Triumph Stag",
"Ford Pinto", "Yugo GV").forEach(name -> {
repository.save(new Car(name));
});
repository.findAll().forEach(System.out::println);
};
}
Consume Cars API in Gateway
@EnableFeignClients
@EnableCircuitBreaker
@EnableDiscoveryClient
@SpringBootApplication
public class ApiGatewayApplication {
public static void main(String[] args) {
SpringApplication.run(ApiGatewayApplication.class, args);
}
}
Consume Cars API in Gateway
@Data
class Car {
private String name;
}
@FeignClient("car-service")
interface CarClient {
@GetMapping("/cars")
@CrossOrigin
Resources<Car> readCars();
}
Consume Cars API in Gateway
@RestController
class CoolCarController {
private final CarClient carClient;
public CoolCarController(CarClient carClient) {
this.carClient = carClient;
}
// code on next slide
}
Consume Cars API in Gateway
private Collection<Car> fallback() {
return new ArrayList<>();
}
@GetMapping("/cool-cars")
@CrossOrigin
@HystrixCommand(fallbackMethod = "fallback")
public Collection<Car> goodCars() {
return carClient.readCars()
.getContent()
.stream()
.filter(this::isCool)
.collect(Collectors.toList());
}
Consume Cars API in Gateway
private boolean isCool(Car car) {
return !car.getName().equals("AMC Gremlin") &&
!car.getName().equals("Triumph Stag") &&
!car.getName().equals("Ford Pinto") &&
!car.getName().equals(“Yugo GV");
}
Start everything with ./mvnw
Access https://localhost:8080/cool-cars
Java Microservices with Spring Boot and Spring Cloud
https://developer.okta.com/blog/2019/05/22/java-microservices-spring-boot-spring-cloud
Microservices with JHipster
What is JHipster?
Installing and Using JHipster
JHipster’s Microservice Features
Progressive Web Applications Overview
Part 2
What is JHipster?
+ =
JHipster jhipster.tech
JHipster is a development platform to generate, develop and deploy 
Spring Boot + Angular/React Web applications and Spring microservices. 
and Vue! ✨
JHipster is Inclusive
https://github.com/jhipster/jhipster-artwork
A powerful workflow to build your
application with Webpack and
Maven/Gradle
JHipster Goals
A sleek, modern, mobile-first
front-end with modern
frameworks
A high-performance and robust
Java stack on the server side with
Spring Boot
A robust microservice architecture
with JHipster Registry, Netflix OSS,
Elastic Stack, and Docker
How to Use JHipster
Install JHipster and Yeoman, using npm:
npm install -g generator-jhipster
Create a directory and cd into it:
mkdir newapp && cd newapp
Run it!
jhipster
Microservices with JHipster
https://www.jhipster.tech/microservices-architecture
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.0 and OIDC
Monolith Examples
JHipster 6 Demo
github.com/mraible/jhipster6-demo
youtu.be/uQqlO3IGpTU
21-Points Health
github.com/mraible/21-points
infoq.com/minibooks/jhipster-mini-book
Progressive Web Apps
Originate from a secure origin, load while offline, and reference a
web app manifest.
Progressive Web Apps
Can be installed on your mobile device, look and act like a native
application, but are distributed through the web.
Progressive Web Apps
Are fast!
Enable PWA in JHipster
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', function() {
navigator.serviceWorker.register('/service-worker.js')
.then(function () {
console.log('Service Worker Registered');
});
});
}
</script>
gateway/src/main/webapp/index.html
Force HTTPS in Spring Boot
gateway/src/main/java/com/okta/developer/gateway/config/SecurityConfiguration.java
@Configuration
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.requiresChannel()
.requestMatchers(r -> r.getHeader("X-Forwarded-Proto") != null)
.requiresSecure();
}
}
https://developer.okta.com/blog/2018/07/30/10-ways-to-secure-spring-boot
“We’ve failed on mobile.”
Alex Russell
https://youtu.be/K1SFnrf4jZo
Demo
Using JHipster, create:
A gateway
A store microservices app
A blog microservices app
Generate entities in apps and on gateway
Convert gateway to be a PWA
Run everything in Docker
https://github.com/oktadeveloper/java-
microservices-examples
JHipster 6.6.0 Lighthouse Report
Part 3
Deploy to the Cloud
Options for Deploying JHipster
Heroku
Cloud Foundry
AWS
Google Cloud
Microsoft Azure
For monoliths:
jhipster heroku
For microservices:
Deploy JHipster Registry
Build and deploy microservice
Build and deploy gateway
http://bit.ly/heroku-jhipster-microservices
For monoliths:
jhipster cloudfoundry
For microservices:
Deploy JHipster Registry
Build and deploy microservice
Build and deploy gateway
https://www.jhipster.tech/cloudfoundry/
Using Elastic Container Service
jhipster aws-containers
Using Elastic Beanstalk
jhipster aws
Boxfuse
boxfuse run -env=prod
http://www.jhipster.tech/aws
http://www.jhipster.tech/boxfuse
mvn package -Pprod jib:dockerBuild
jhipster kubernetes
./kubectl-apply.sh
kubectl get svc gateway
https://developer.okta.com/blog/2017/06/20/
develop-microservices-with-jhipster
Part 4 JHipster Roadmap
What You Learned
What’s Next for JHipster
What You Learned
Microservices with Spring Cloud Config and JHipster
https://developer.okta.com/blog/2019/05/23/java-microservices-spring-cloud-config
JHipster Mobile Apps and Microservices on Pluralsight
pluralsight.com/courses/play-by-play-developing-microservices-mobile-apps-jhipster
What’s Next for JHipster?
Full Reactive with WebFlux
and Spring Cloud Gateway
Spring Boot 2.2
GraphQL and Micro Frontends
The JHipster Mini-Book
Written with Asciidoctor
Free download from InfoQ:
infoq.com/minibooks/jhipster-mini-book
Quick and to the point, 164 pages
Developed a real world app:
www.21-points.com
Buy for $20 or download for FREE
Learn More
stackoverflow.com
Spring Boot
spring.io/guides
JHipster
www.jhipster.tech
Okta APIs
developer.okta.com
developer.okta.com/blog
@oktadev
Reactive Microservices with Spring Cloud Gateway
https://developer.okta.com/blog/2019/08/28/reactive-microservices-spring-cloud-gateway
Action: Try JHipster!
https://developer.okta.com/blog/2019/04/04/java-11-java-12-jhipster-oidc
git clone https://github.com/oktadeveloper/okta-spring-webflux-react-
example.git
https://github.com/oktadeveloper/java-microservices-examples
Use the Source, Luke!
Thanks!
Keep in Touch
raibledesigns.com
@mraible
Presentations
speakerdeck.com/mraible
Code
github.com/oktadeveloper
developer.okta.com
developer.okta.com

Weitere ähnliche Inhalte

Was ist angesagt?

Liferay UI (R)evolution
Liferay UI (R)evolutionLiferay UI (R)evolution
Liferay UI (R)evolution
Zeno Rocha
 

Was ist angesagt? (20)

How to Win at UI Development in the World of Microservices - THAT Conference ...
How to Win at UI Development in the World of Microservices - THAT Conference ...How to Win at UI Development in the World of Microservices - THAT Conference ...
How to Win at UI Development in the World of Microservices - THAT Conference ...
 
Choosing a Java Web Framework
Choosing a Java Web FrameworkChoosing a Java Web Framework
Choosing a Java Web Framework
 
Front End Development for Back End Java Developers - Jfokus 2020
Front End Development for Back End Java Developers - Jfokus 2020Front End Development for Back End Java Developers - Jfokus 2020
Front End Development for Back End Java Developers - Jfokus 2020
 
Micronaut: Changing the Micro Future
Micronaut: Changing the Micro FutureMicronaut: Changing the Micro Future
Micronaut: Changing the Micro Future
 
Bootiful Development with Spring Boot and Angular - Connect.Tech 2017
 Bootiful Development with Spring Boot and Angular - Connect.Tech 2017 Bootiful Development with Spring Boot and Angular - Connect.Tech 2017
Bootiful Development with Spring Boot and Angular - Connect.Tech 2017
 
Choose Your Own Adventure with JHipster & Kubernetes - Denver JUG 2020
Choose Your Own Adventure with JHipster & Kubernetes - Denver JUG 2020Choose Your Own Adventure with JHipster & Kubernetes - Denver JUG 2020
Choose Your Own Adventure with JHipster & Kubernetes - Denver JUG 2020
 
Java REST API Framework Comparison - PWX 2021
Java REST API Framework Comparison - PWX 2021Java REST API Framework Comparison - PWX 2021
Java REST API Framework Comparison - PWX 2021
 
Microservices for the Masses with Spring Boot and JHipster - RWX 2018
Microservices for the Masses with Spring Boot and JHipster - RWX 2018Microservices for the Masses with Spring Boot and JHipster - RWX 2018
Microservices for the Masses with Spring Boot and JHipster - RWX 2018
 
Bootiful Development with Spring Boot and Vue - RWX 2018
Bootiful Development with Spring Boot and Vue - RWX 2018Bootiful Development with Spring Boot and Vue - RWX 2018
Bootiful Development with Spring Boot and Vue - RWX 2018
 
A realtime infrastructure for Android apps: Firebase may be what you need..an...
A realtime infrastructure for Android apps: Firebase may be what you need..an...A realtime infrastructure for Android apps: Firebase may be what you need..an...
A realtime infrastructure for Android apps: Firebase may be what you need..an...
 
Bootiful Development with Spring Boot and React - SpringOne 2017
Bootiful Development with Spring Boot and React - SpringOne 2017Bootiful Development with Spring Boot and React - SpringOne 2017
Bootiful Development with Spring Boot and React - SpringOne 2017
 
Bootiful Development with Spring Boot and Angular - RWX 2018
Bootiful Development with Spring Boot and Angular - RWX 2018Bootiful Development with Spring Boot and Angular - RWX 2018
Bootiful Development with Spring Boot and Angular - RWX 2018
 
Micro frontend: The microservices puzzle extended to frontend
Micro frontend: The microservices puzzle  extended to frontendMicro frontend: The microservices puzzle  extended to frontend
Micro frontend: The microservices puzzle extended to frontend
 
Front End Development for Back End Developers - Devoxx UK 2017
 Front End Development for Back End Developers - Devoxx UK 2017 Front End Development for Back End Developers - Devoxx UK 2017
Front End Development for Back End Developers - Devoxx UK 2017
 
Microservices for the Masses with Spring Boot, JHipster, and JWT - J-Spring 2017
Microservices for the Masses with Spring Boot, JHipster, and JWT - J-Spring 2017Microservices for the Masses with Spring Boot, JHipster, and JWT - J-Spring 2017
Microservices for the Masses with Spring Boot, JHipster, and JWT - J-Spring 2017
 
Bootiful Development with Spring Boot and React - RWX 2017
Bootiful Development with Spring Boot and React - RWX 2017Bootiful Development with Spring Boot and React - RWX 2017
Bootiful Development with Spring Boot and React - RWX 2017
 
Microservices for the Masses with Spring Boot, JHipster, and JWT - Devoxx UK...
 Microservices for the Masses with Spring Boot, JHipster, and JWT - Devoxx UK... Microservices for the Masses with Spring Boot, JHipster, and JWT - Devoxx UK...
Microservices for the Masses with Spring Boot, JHipster, and JWT - Devoxx UK...
 
Liferay UI (R)evolution
Liferay UI (R)evolutionLiferay UI (R)evolution
Liferay UI (R)evolution
 
2013.devcon3 liferay and google authenticator integration rafik_harabi
2013.devcon3 liferay and google authenticator integration rafik_harabi2013.devcon3 liferay and google authenticator integration rafik_harabi
2013.devcon3 liferay and google authenticator integration rafik_harabi
 
Java Microservices with Spring Boot and Spring Cloud - Denver JUG 2019
Java Microservices with Spring Boot and Spring Cloud - Denver JUG 2019Java Microservices with Spring Boot and Spring Cloud - Denver JUG 2019
Java Microservices with Spring Boot and Spring Cloud - Denver JUG 2019
 

Ähnlich wie Microservices for the Masses with Spring Boot, JHipster, and OAuth - Jforum Stockholm 2020

N01 cloud computing_and_gae
N01 cloud computing_and_gaeN01 cloud computing_and_gae
N01 cloud computing_and_gae
Sun-Jin Jang
 
Fixing the mobile web - Internet World Romania
Fixing the mobile web - Internet World RomaniaFixing the mobile web - Internet World Romania
Fixing the mobile web - Internet World Romania
Christian Heilmann
 
Web APIs & Apps - Mozilla
Web APIs & Apps - MozillaWeb APIs & Apps - Mozilla
Web APIs & Apps - Mozilla
Robert Nyman
 

Ähnlich wie Microservices for the Masses with Spring Boot, JHipster, and OAuth - Jforum Stockholm 2020 (20)

Microservices for the Masses with Spring Boot, JHipster, and OAuth - South We...
Microservices for the Masses with Spring Boot, JHipster, and OAuth - South We...Microservices for the Masses with Spring Boot, JHipster, and OAuth - South We...
Microservices for the Masses with Spring Boot, JHipster, and OAuth - South We...
 
Choose Your Own Adventure with JHipster & Kubernetes - Utah JUG 2020
Choose Your Own Adventure with JHipster & Kubernetes - Utah JUG 2020Choose Your Own Adventure with JHipster & Kubernetes - Utah JUG 2020
Choose Your Own Adventure with JHipster & Kubernetes - Utah JUG 2020
 
Microservices for the Masses with Spring Boot and JHipster - Chicago JUG 2018
Microservices for the Masses with Spring Boot and JHipster - Chicago JUG 2018Microservices for the Masses with Spring Boot and JHipster - Chicago JUG 2018
Microservices for the Masses with Spring Boot and JHipster - Chicago JUG 2018
 
Building 12-factor Cloud Native Microservices
Building 12-factor Cloud Native MicroservicesBuilding 12-factor Cloud Native Microservices
Building 12-factor Cloud Native Microservices
 
Spring Cloud Function & Project riff #jsug
Spring Cloud Function & Project riff #jsugSpring Cloud Function & Project riff #jsug
Spring Cloud Function & Project riff #jsug
 
Spring boot microservice metrics monitoring
Spring boot   microservice metrics monitoringSpring boot   microservice metrics monitoring
Spring boot microservice metrics monitoring
 
Spring Boot - Microservice Metrics Monitoring
Spring Boot - Microservice Metrics MonitoringSpring Boot - Microservice Metrics Monitoring
Spring Boot - Microservice Metrics Monitoring
 
N01 cloud computing_and_gae
N01 cloud computing_and_gaeN01 cloud computing_and_gae
N01 cloud computing_and_gae
 
Front end microservices - October 2019
Front end microservices - October 2019Front end microservices - October 2019
Front end microservices - October 2019
 
Front End Development for Back End Developers - vJUG24 2017
Front End Development for Back End Developers - vJUG24 2017Front End Development for Back End Developers - vJUG24 2017
Front End Development for Back End Developers - vJUG24 2017
 
Front End Development for Back End Developers - UberConf 2017
Front End Development for Back End Developers - UberConf 2017Front End Development for Back End Developers - UberConf 2017
Front End Development for Back End Developers - UberConf 2017
 
OGCE Project Overview
OGCE Project OverviewOGCE Project Overview
OGCE Project Overview
 
API Design: Women Who Code (WWCode) DFW
API Design: Women Who Code (WWCode) DFW API Design: Women Who Code (WWCode) DFW
API Design: Women Who Code (WWCode) DFW
 
Spring on PAS - Fabio Marinelli
Spring on PAS - Fabio MarinelliSpring on PAS - Fabio Marinelli
Spring on PAS - Fabio Marinelli
 
Microservices for the Masses with Spring Boot, JHipster and OAuth - GIDS 2019
Microservices for the Masses with Spring Boot, JHipster and OAuth - GIDS 2019Microservices for the Masses with Spring Boot, JHipster and OAuth - GIDS 2019
Microservices for the Masses with Spring Boot, JHipster and OAuth - GIDS 2019
 
Appium workshop technopark trivandrum
Appium workshop technopark trivandrumAppium workshop technopark trivandrum
Appium workshop technopark trivandrum
 
Fixing the mobile web - Internet World Romania
Fixing the mobile web - Internet World RomaniaFixing the mobile web - Internet World Romania
Fixing the mobile web - Internet World Romania
 
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteor
 
Vaadin 7 CN
Vaadin 7 CNVaadin 7 CN
Vaadin 7 CN
 
Web APIs & Apps - Mozilla
Web APIs & Apps - MozillaWeb APIs & Apps - Mozilla
Web APIs & Apps - Mozilla
 

Mehr von Matt Raible

Mehr von Matt Raible (20)

Keep Identities in Sync the SCIMple Way - ApacheCon NA 2022
Keep Identities in Sync the SCIMple Way - ApacheCon NA 2022Keep Identities in Sync the SCIMple Way - ApacheCon NA 2022
Keep Identities in Sync the SCIMple Way - ApacheCon NA 2022
 
Micro Frontends for Java Microservices - Belfast JUG 2022
Micro Frontends for Java Microservices - Belfast JUG 2022Micro Frontends for Java Microservices - Belfast JUG 2022
Micro Frontends for Java Microservices - Belfast JUG 2022
 
Micro Frontends for Java Microservices - Dublin JUG 2022
Micro Frontends for Java Microservices - Dublin JUG 2022Micro Frontends for Java Microservices - Dublin JUG 2022
Micro Frontends for Java Microservices - Dublin JUG 2022
 
Micro Frontends for Java Microservices - Cork JUG 2022
Micro Frontends for Java Microservices - Cork JUG 2022Micro Frontends for Java Microservices - Cork JUG 2022
Micro Frontends for Java Microservices - Cork JUG 2022
 
Comparing Native Java REST API Frameworks - Seattle JUG 2022
Comparing Native Java REST API Frameworks - Seattle JUG 2022Comparing Native Java REST API Frameworks - Seattle JUG 2022
Comparing Native Java REST API Frameworks - Seattle JUG 2022
 
Reactive Java Microservices with Spring Boot and JHipster - Spring I/O 2022
Reactive Java Microservices with Spring Boot and JHipster - Spring I/O 2022Reactive Java Microservices with Spring Boot and JHipster - Spring I/O 2022
Reactive Java Microservices with Spring Boot and JHipster - Spring I/O 2022
 
Comparing Native Java REST API Frameworks - Devoxx France 2022
Comparing Native Java REST API Frameworks - Devoxx France 2022Comparing Native Java REST API Frameworks - Devoxx France 2022
Comparing Native Java REST API Frameworks - Devoxx France 2022
 
Lock That Sh*t Down! Auth Security Patterns for Apps, APIs, and Infra - Devne...
Lock That Sh*t Down! Auth Security Patterns for Apps, APIs, and Infra - Devne...Lock That Sh*t Down! Auth Security Patterns for Apps, APIs, and Infra - Devne...
Lock That Sh*t Down! Auth Security Patterns for Apps, APIs, and Infra - Devne...
 
Native Java with Spring Boot and JHipster - Garden State JUG 2021
Native Java with Spring Boot and JHipster - Garden State JUG 2021Native Java with Spring Boot and JHipster - Garden State JUG 2021
Native Java with Spring Boot and JHipster - Garden State JUG 2021
 
Web App Security for Java Developers - PWX 2021
Web App Security for Java Developers - PWX 2021Web App Security for Java Developers - PWX 2021
Web App Security for Java Developers - PWX 2021
 
Mobile App Development with Ionic, React Native, and JHipster - Connect.Tech ...
Mobile App Development with Ionic, React Native, and JHipster - Connect.Tech ...Mobile App Development with Ionic, React Native, and JHipster - Connect.Tech ...
Mobile App Development with Ionic, React Native, and JHipster - Connect.Tech ...
 
Lock That Shit Down! Auth Security Patterns for Apps, APIs, and Infra - Joker...
Lock That Shit Down! Auth Security Patterns for Apps, APIs, and Infra - Joker...Lock That Shit Down! Auth Security Patterns for Apps, APIs, and Infra - Joker...
Lock That Shit Down! Auth Security Patterns for Apps, APIs, and Infra - Joker...
 
Web App Security for Java Developers - UberConf 2021
Web App Security for Java Developers - UberConf 2021Web App Security for Java Developers - UberConf 2021
Web App Security for Java Developers - UberConf 2021
 
Java REST API Framework Comparison - UberConf 2021
Java REST API Framework Comparison - UberConf 2021Java REST API Framework Comparison - UberConf 2021
Java REST API Framework Comparison - UberConf 2021
 
Native Java with Spring Boot and JHipster - SF JUG 2021
Native Java with Spring Boot and JHipster - SF JUG 2021Native Java with Spring Boot and JHipster - SF JUG 2021
Native Java with Spring Boot and JHipster - SF JUG 2021
 
Lock That Shit Down! Auth Security Patterns for Apps, APIs, and Infra - Sprin...
Lock That Shit Down! Auth Security Patterns for Apps, APIs, and Infra - Sprin...Lock That Shit Down! Auth Security Patterns for Apps, APIs, and Infra - Sprin...
Lock That Shit Down! Auth Security Patterns for Apps, APIs, and Infra - Sprin...
 
Get Hip with JHipster - Colorado Springs Open Source User Group 2021
Get Hip with JHipster - Colorado Springs Open Source User Group 2021Get Hip with JHipster - Colorado Springs Open Source User Group 2021
Get Hip with JHipster - Colorado Springs Open Source User Group 2021
 
JHipster and Okta - JHipster Virtual Meetup December 2020
JHipster and Okta - JHipster Virtual Meetup December 2020JHipster and Okta - JHipster Virtual Meetup December 2020
JHipster and Okta - JHipster Virtual Meetup December 2020
 
Security Patterns for Microservice Architectures - SpringOne 2020
Security Patterns for Microservice Architectures - SpringOne 2020Security Patterns for Microservice Architectures - SpringOne 2020
Security Patterns for Microservice Architectures - SpringOne 2020
 
Security Patterns for Microservice Architectures - ADTMag Microservices & API...
Security Patterns for Microservice Architectures - ADTMag Microservices & API...Security Patterns for Microservice Architectures - ADTMag Microservices & API...
Security Patterns for Microservice Architectures - ADTMag Microservices & API...
 

Kürzlich hochgeladen

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 

Kürzlich hochgeladen (20)

A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 

Microservices for the Masses with Spring Boot, JHipster, and OAuth - Jforum Stockholm 2020

  • 1. Microservices for the Masses with Spring Boot, JHipster, and OAuth February 4, 2020 Matt Raible | @mraible Photo by Magnus Johansson flickr.com/photos/120374925@N06/15138686641
  • 2. Do you use microservices?
  • 3.
  • 4. Agenda 1. Introduction to Microservices 2. Microservices with JHipster 3. Deploying to the Cloud 4. Developing Mobile Apps with JHipster 5. JHipster Roadmap
  • 5. Blogger on raibledesigns.com and developer.okta.com/blog Web Developer and Java Champion Father, Husband, Skier, Mountain Biker, Whitewater Rafter Open Source Connoisseur Hi, I’m Matt Raible! Bus Lover Okta Developer Advocate
  • 6.
  • 7.
  • 8.
  • 11. Part 1 Introduction to Microservices History of Microservices Microservices Architecture Philosophy Why Microservices? Demo: A Microservices Architecture with Spring Boot and Spring Cloud
  • 12.
  • 14.
  • 15. “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
  • 16. “Do one thing and do it well.”
  • 17. “You shouldn't start with a microservices architecture. Instead begin with a monolith, keep it modular, and split it into microservices once the monolith becomes a problem.” Martin Fowler March 2014
  • 18.
  • 20.
  • 21.
  • 22. Demo Using start.spring.io, create: A service registry A gateway A catalog service Create an endpoint in the catalog service Create a filtered endpoint in the gateway Show failover capabilities Show Spring Security OAuth https://github.com/oktadeveloper/java- microservices-examples
  • 23. Create Java Microservices using start.spring.io http https://start.spring.io/starter.zip javaVersion==11 artifactId==discovery-service name==eureka-service dependencies==cloud-eureka-server baseDir==discovery-service | tar -xzvf -
  • 24. Enable Eureka Server & Configure application.properties server.port=8761 eureka.client.register-with-eureka=false @EnableEurekaServer
  • 25. Create Car Service http https://start.spring.io/starter.zip artifactId==car-service name==car-service baseDir==car-service dependencies==actuator,cloud-eureka,data-jpa,h2,data- rest,web,devtools,lombok | tar -xzvf -
  • 26. Enable Discovery & Configure application.properties server.port=8090 spring.application.name=car-service @EnableDiscoveryClient
  • 27. Create API Gateway http https://start.spring.io/starter.zip artifactId==api-gateway name==api-gateway baseDir==api-gateway dependencies==cloud-eureka,cloud-feign,data-rest,web,cloud- hystrix,lombok | tar -xzvf -
  • 28. Enable Discovery & Configure application.properties spring.application.name=api-gateway @EnableDiscoveryClient
  • 29. Build a REST API in Car Service @Data @NoArgsConstructor @Entity class Car { public Car(String name) { this.name = name; } @Id @GeneratedValue private Long id; @NonNull private String name; }
  • 30. Build a REST API in Car Service @RepositoryRestResource interface CarRepository extends JpaRepository<Car, Long> { }
  • 31. Build a REST API in Car Service @Bean ApplicationRunner init(CarRepository repository) { return args -> { Stream.of("Ferrari", "Jaguar", "Porsche", "Lamborghini", "Bugatti", "AMC Gremlin", "Triumph Stag", "Ford Pinto", "Yugo GV").forEach(name -> { repository.save(new Car(name)); }); repository.findAll().forEach(System.out::println); }; }
  • 32. Consume Cars API in Gateway @EnableFeignClients @EnableCircuitBreaker @EnableDiscoveryClient @SpringBootApplication public class ApiGatewayApplication { public static void main(String[] args) { SpringApplication.run(ApiGatewayApplication.class, args); } }
  • 33. Consume Cars API in Gateway @Data class Car { private String name; } @FeignClient("car-service") interface CarClient { @GetMapping("/cars") @CrossOrigin Resources<Car> readCars(); }
  • 34. Consume Cars API in Gateway @RestController class CoolCarController { private final CarClient carClient; public CoolCarController(CarClient carClient) { this.carClient = carClient; } // code on next slide }
  • 35. Consume Cars API in Gateway private Collection<Car> fallback() { return new ArrayList<>(); } @GetMapping("/cool-cars") @CrossOrigin @HystrixCommand(fallbackMethod = "fallback") public Collection<Car> goodCars() { return carClient.readCars() .getContent() .stream() .filter(this::isCool) .collect(Collectors.toList()); }
  • 36. Consume Cars API in Gateway private boolean isCool(Car car) { return !car.getName().equals("AMC Gremlin") && !car.getName().equals("Triumph Stag") && !car.getName().equals("Ford Pinto") && !car.getName().equals(“Yugo GV"); }
  • 39. Java Microservices with Spring Boot and Spring Cloud https://developer.okta.com/blog/2019/05/22/java-microservices-spring-boot-spring-cloud
  • 40. Microservices with JHipster What is JHipster? Installing and Using JHipster JHipster’s Microservice Features Progressive Web Applications Overview Part 2
  • 42. JHipster jhipster.tech JHipster is a development platform to generate, develop and deploy  Spring Boot + Angular/React Web applications and Spring microservices.  and Vue! ✨
  • 44. A powerful workflow to build your application with Webpack and Maven/Gradle JHipster Goals A sleek, modern, mobile-first front-end with modern frameworks A high-performance and robust Java stack on the server side with Spring Boot A robust microservice architecture with JHipster Registry, Netflix OSS, Elastic Stack, and Docker
  • 45. How to Use JHipster Install JHipster and Yeoman, using npm: npm install -g generator-jhipster Create a directory and cd into it: mkdir newapp && cd newapp Run it! jhipster
  • 48. 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.0 and OIDC
  • 49. Monolith Examples JHipster 6 Demo github.com/mraible/jhipster6-demo youtu.be/uQqlO3IGpTU 21-Points Health github.com/mraible/21-points infoq.com/minibooks/jhipster-mini-book
  • 50. Progressive Web Apps Originate from a secure origin, load while offline, and reference a web app manifest.
  • 51. Progressive Web Apps Can be installed on your mobile device, look and act like a native application, but are distributed through the web.
  • 53. Enable PWA in JHipster <script> if ('serviceWorker' in navigator) { window.addEventListener('load', function() { navigator.serviceWorker.register('/service-worker.js') .then(function () { console.log('Service Worker Registered'); }); }); } </script> gateway/src/main/webapp/index.html
  • 54. Force HTTPS in Spring Boot gateway/src/main/java/com/okta/developer/gateway/config/SecurityConfiguration.java @Configuration public class SecurityConfiguration extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { http.requiresChannel() .requestMatchers(r -> r.getHeader("X-Forwarded-Proto") != null) .requiresSecure(); } } https://developer.okta.com/blog/2018/07/30/10-ways-to-secure-spring-boot
  • 55. “We’ve failed on mobile.” Alex Russell https://youtu.be/K1SFnrf4jZo
  • 56. Demo Using JHipster, create: A gateway A store microservices app A blog microservices app Generate entities in apps and on gateway Convert gateway to be a PWA Run everything in Docker https://github.com/oktadeveloper/java- microservices-examples
  • 58. Part 3 Deploy to the Cloud Options for Deploying JHipster Heroku Cloud Foundry AWS Google Cloud Microsoft Azure
  • 59. For monoliths: jhipster heroku For microservices: Deploy JHipster Registry Build and deploy microservice Build and deploy gateway http://bit.ly/heroku-jhipster-microservices
  • 60. For monoliths: jhipster cloudfoundry For microservices: Deploy JHipster Registry Build and deploy microservice Build and deploy gateway https://www.jhipster.tech/cloudfoundry/
  • 61. Using Elastic Container Service jhipster aws-containers Using Elastic Beanstalk jhipster aws Boxfuse boxfuse run -env=prod http://www.jhipster.tech/aws http://www.jhipster.tech/boxfuse
  • 62. mvn package -Pprod jib:dockerBuild jhipster kubernetes ./kubectl-apply.sh kubectl get svc gateway https://developer.okta.com/blog/2017/06/20/ develop-microservices-with-jhipster
  • 63. Part 4 JHipster Roadmap What You Learned What’s Next for JHipster
  • 65. Microservices with Spring Cloud Config and JHipster https://developer.okta.com/blog/2019/05/23/java-microservices-spring-cloud-config
  • 66. JHipster Mobile Apps and Microservices on Pluralsight pluralsight.com/courses/play-by-play-developing-microservices-mobile-apps-jhipster
  • 67. What’s Next for JHipster? Full Reactive with WebFlux and Spring Cloud Gateway Spring Boot 2.2 GraphQL and Micro Frontends
  • 68. The JHipster Mini-Book Written with Asciidoctor Free download from InfoQ: infoq.com/minibooks/jhipster-mini-book Quick and to the point, 164 pages Developed a real world app: www.21-points.com Buy for $20 or download for FREE
  • 71. Reactive Microservices with Spring Cloud Gateway https://developer.okta.com/blog/2019/08/28/reactive-microservices-spring-cloud-gateway