Conversation
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 important changes to user authorization logic, exception handling, and data seeding, as well as minor dependency and configuration updates. The most significant updates include refactoring user visibility and access control, improving exception handling for security-related errors, and updating the initial database seed data for the super admin account.
Authorization and Access Control:
UserService: Replaced theenforceSiteBoundaryfunction with a newenforceVisibilityRulesfunction to provide more granular authorization checks, especially for managers and site boundaries. Managers can now only view staff accounts, and users are restricted to their own site unless they are super admins. All relevant service methods now use this new enforcement. [1] [2] [3]findByIdWithRolerepository method now returns anOptional<User>instead of a nullableUser, improving safety and consistency in handling missing users.Exception Handling Improvements:
InvalidCredentialsExceptionandInvalidRefreshTokenExceptionto extend Spring Security’sBadCredentialsExceptionfor better integration with Spring Security’s authentication error handling.AccessDeniedExceptionfor authorization errors and updated the global exception handler to return HTTP 403 Forbidden for access denials, including handling of Spring Security’sAuthorizationDeniedException. [1] [2] [3]Database and Data Seeding:
Repository and Query Updates:
DISTINCTto thefindByIdWithRoleAndSitequery to prevent duplicate results.Configuration and Dependency Updates:
These changes collectively improve the security, maintainability, and clarity of user authorization, error handling, and initial setup.
Closes #13