Merged
Conversation
Implement foundational authentication features, including user and role management, JWT-based authentication, and role-based security configurations. Add REST endpoints for login, signup, and logout, along with a Dockerized development setup, CI/CD workflows, and logging configurations.
Implement foundational authentication features, including user and role management, JWT-based authentication, and role-based security configurations. Add REST endpoints for login, signup, and logout, along with a Dockerized development setup, CI/CD workflows, and logging configurations.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…oller.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…oller.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…and RedisInsight to specific versions
…ervice # Conflicts: # src/main/java/com/podzilla/auth/service/CustomUserDetailsService.java
…and RedisInsight to specific versions
…rs; update .gitignore to exclude logs and sensitive files
… User and RefreshToken; enhance logout functionality to expire refresh tokens
…serDetails class, update login and registration logic, and configure Redis cache manager
…ailsService, and TokenService
Contributor
There was a problem hiding this comment.
Pull Request Overview
This pull request adds integration tests for various authentication controllers while also updating some service logic and security configurations to use a custom granted authority.
- Updated test files to add end-to-end testing for user registration, login, token refresh, logout, and admin access.
- Modified service and security classes to use CustomGrantedAuthority and to improve error handling for refresh token operations.
Reviewed Changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/test/java/com/podzilla/auth/service/TokenServiceTest.java | Added an import which may be unused |
| src/test/java/com/podzilla/auth/service/AuthenticationServiceTest.java | Updated test behavior for token refresh error handling and authority usage |
| src/test/java/com/podzilla/auth/controller/AuthenticationControllerTest.java | Added integration tests for authentication endpoints |
| src/test/java/com/podzilla/auth/controller/AdminControllerTest.java | Added integration tests for admin endpoints and role assignments |
| src/main/java/com/podzilla/auth/service/CustomUserDetailsService.java | Updated to use CustomGrantedAuthority instead of SimpleGrantedAuthority |
| src/main/java/com/podzilla/auth/service/AuthenticationService.java | Improved refresh token null check and exception handling |
| src/main/java/com/podzilla/auth/security/SecurityConfig.java | Changed role restriction to use hasAuthority("ROLE_ADMIN") |
| src/main/java/com/podzilla/auth/dto/CustomUserDetails.java | Added a JsonDeserialize annotation for authorities |
| src/main/java/com/podzilla/auth/dto/CustomGrantedAuthority.java | New custom granted authority implementation |
Files not reviewed (1)
- src/test/resources/application.properties: Language not supported
…rs, improve CustomUserDetails, and implement caching for user details retrieval
YehiaFarghaly
requested changes
May 2, 2025
…cks and improve exception handling
…cks and improve exception handling
…r in CustomUserDetailsServiceTest
YehiaFarghaly
approved these changes
May 3, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several enhancements and updates to the authentication service, including dependency updates, caching support, improved exception handling, and code refactoring for better maintainability. The changes span across configuration files, new DTOs, exception handling, and service logic.
Configuration and Dependency Updates:
docker-compose.ymlto include specific container names, added Redis and RedisInsight services, and pinned versions forpostgres,grafana/loki,grafana/promtail, andgrafana/grafanaimages. [1] [2] [3] [4]mockito-coreandmockito-junit-jupiterdependencies topom.xmlfor unit testing.Caching Support:
AuthApplicationwith the@EnableCachingannotation.RedisCacheConfigfor Redis-based caching, including a configurable cache manager and TTL settings.JWTAuthenticationFilterto use a cached version ofloadUserByUsername.Security Enhancements:
CustomGrantedAuthorityandCustomUserDetailsDTOs to support custom user details for authentication. [1] [2]GlobalExceptionHandlerforAccessDeniedExceptionandAuthenticationException.SecurityConfigto remove theRestAuthenticationEntryPointand adjustrequestMatchersfor better granularity. [1] [2]Service and Model Improvements:
AuthenticationServiceto validate input fields during registration and handle already-logged-in users during login. [1] [2]RefreshTokenmodel to use Lombok annotations for builder pattern and constructors. [1] [2]Logging and Miscellaneous:
JWTAuthenticationFilter.RestAuthenticationEntryPointclass.