Posts

Showing posts with the label microservice

Securing Spring Boot Microservices with Spring Security

Overview Basically, our microservices are secured this way : The user provides his credentials via a public endpoint If authenticated, the server returns an authentication token (JWT) The JWT is attached to each subsequent request via an HTTP header: Authorization:Bearer TOKEN You can find the source code at https://github.com/vedrax-admin/spring-microservices User Microservice This microservice uses a MySQL database. We begin by creating the Account table: Below is a script to insert some dummy data: The Account entity will be created using JPA: The account repository: User Principal We create a class named UserPrincipal which implements UserDetails . In order to be accessible by all microservices, this class is located in our shared module. JWT Token Service This service is responsible for creating expiring JWT. We can also parse a JWT for getting the UserPrincipal . We use the io.jsonwebtoken dependency for that. Account Service...

How to Deploy Microservices on Google Cloud

Today, I'll show you how you can deploy a multi module project on GAE using Maven. Because the EAR file is not allowed, we basically wrap our microservices inside a parent module (pom). Parent Module The parent module has its packaging tag set to  pom . All shared configuration will be placed inside the parent pom.xml via dependencyManagement or pluginManagement . As you probably know Maven provides the notion of aggregation by declaring submodules explicitly in the parent pom.xml. In the above configuration, I've declared 3 submodules (war). You can create the parent project with the following cmd: mvn archetype:generate -DgroupId=com.vedrax -DartifactId=parent-project PS: I'll soon register an archetype to generate the configuration as presented above with the required submodules. Submodules You can in the parent's directory run the following cmd: mvn archetype:generate -DgroupId=com.vedrax -DartifactId=company-service mvn archety...