The Security Service is a comprehensive microservice designed to handle authentication and authorization tasks within a microservices architecture. Leveraging Spring Boot 3+, Spring Security 6+, JDK 17, and Maven 3.9+, this service provides robust security features like user registration, authentication via JWT tokens, and token refresh mechanisms.
Below are the architectural diagrams depicting various aspects of the Security Service:
This diagram illustrates the process from user registration to obtaining an authentication token.
Details the token generation process upon user authentication.
Shows the steps involved in validating JWT tokens and granting access to protected resources.
Explains the flow when authentication fails due to various reasons like bad credentials or expired tokens.
The project uses several key dependencies:
-
Spring Boot Starter Security- Provides essential security configurations. -
Spring Boot Starter Web- Supports building web applications including RESTful applications using Spring MVC. -
Spring Cloud Starter Netflix Eureka Client- Enables service discovery with Eureka. -
JJWT(JSON Web Token) for secure and efficient JWT handling.
application.yml configuration:
spring:
application:
name: security-service
server:
port: 8089
spring:
datasource:
url: jdbc:mysql://localhost:3306/microservices
username: springstudent
password: springstudent
driver-class-name: com.mysql.cj.jdbc.Driver
jpa:
show-sql: true
hibernate:
ddl-auto: update
properties:
hibernate:
dialect: org.hibernate.dialect.MySQLDialect
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
instance:
hostname: localhost- POST
/auth/register- Register a new user. - GET
/auth/getToken- Generate a new JWT for authenticated users. - GET
/auth/validateToken- Validate an existing JWT. - GET
/auth/refreshToken- Refresh an expired JWT.



