Posts

Showing posts with the label Oauth2

Microservices with Spring Boot, OAuth2, Docker and Kubernetes

Image
Microservices Architecture The aim is to create a use-case to demonstrate the use of a secured microservices and then containerize it with docker and deploy it with a container orchestration tool like Kubernetes. The entire use-case is sub-divided into various sub-tasks where we try to achieve our goal in a step-by-step manner. At a high level, the sub-tasks include: Create an employee microservice which can act as a Resource server. Create an Authorization server which generates Oauth2 access tokens. Containerize the applications with Docker Deploy application with Kubernetes Swagger setup The source code can be found on GitHub .

Oauth2 Authorization Server

Image
Oauth2 Server The Oauth2 server will be responsible to issue access and refresh tokens based on the following parameters: Client Id Client Secret Username Password The client id- client secret is a unique combination assigned for each resource server that needs to be registered with the oauth2 server. Based on the username and password, the users will be authenticated and a token will be assigned to the user which will also contain the list of roles for a given user. Generate a spring boot project using spring initializer: https://start.spring.io/ with the following dependencies: Spring Data JPA spring-boot-starter-security Spring Web   Add Additional Dependencies:    spring-security-oauth2 spring-security-jwt Final dependency list: < dependency > < groupId > org.springframework.boot </ groupId > < artifactId > spring-boot-starter-da...