How eudycss/jwt-springtboot-psql works
Main Components
a. Client/External System: Represents the users or tools (like Postman) interacting with REST endpoints.
b. API Gateway / HTTP Layer: The endpoints exposed by the application (AuthController, TestController) that handle registration, login, and protected resource access.
c. Security Module: Contains the Spring Security configuration, JWT utilities (AuthTokenFilter, JwtUtils, AuthEntryPointJwt) and service implementations (UserDetailsServiceImpl, UserDetailsImpl). This module manages authentication, processes JWT tokens, and enforces role-based access control.
d. Business Logic & Data Access:
• Controllers that handle input and output.
• The service layer (in this case, even though explicit “service” packages are minimal, the security/services package plays that role).
• Repositories (UserRepository, RoleRepository) to access the underlying database.
• Models (User, Role, ERole) representing data entities.
e. Database: Notice that the README mentions the use of H2 (in-memory for testing) and PostgreSQL for production. Illustrate database interactions accordingly.
f. Configuration: Components like OpenApiConfig and application.properties imply configuration management for API docs and application settings.
Relationships and Interactions
• That the API endpoints invoke Security components to authenticate and authorize requests.
• That once authenticated, controllers interact with repositories to perform CRUD operations on the database (users and roles).
• JWT flow, starting with login requests that result in a JWT token, then subsequent requests containing the token being validated via the JWT utility and filter chain before reaching protected resources.
• Data flow between the authentication endpoints and the security services.
Architectural and Design Patterns
• Layered Architecture: Separate presentation (controllers), business logic (service/security layer), and data access (repositories).
• Security with JWT: Emphasize how the authentication process is decoupled from the core business logic.
• REST API Design: Clear endpoints for authentication and role-based resource access.
Relevant Technologies and Frameworks
• Spring Boot as the application foundation.
• Spring Security for authentication and authorization.
• JWT (JSON Web Tokens) management components.
• H2 and PostgreSQL as the database solutions.
• Maven as the build tool (as seen in pom.xml).