Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class ComposerService {

@Transactional
public void createComposer(ComposerCreateDto dto, User user) {
if (user.getId() != 1L) {
if (user.getId() != 5L) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-medium medium

The createComposer method uses a hardcoded user ID (5L) for administrative privilege verification, which is a brittle and insecure way to implement access control. Hardcoding user IDs makes the application's security logic dependent on specific database states and can lead to unauthorized access if ID mappings are inconsistent or misused. It is recommended to implement a Role-Based Access Control (RBAC) system, checking for an 'ADMIN' role or specific permissions instead of a hardcoded user ID. Additionally, the hardcoded 'magic number' 5L should be extracted into a constant for clarity and maintainability. When comparing Long objects, use equals() instead of !=. For better flexibility, consider managing such values in external configuration files (e.g., application.properties) to allow updates without redeployment.

throw new BusinessException(CommonErrorStatus.FORBIDDEN);
}
Composer composer = Composer.builder()
Expand Down
Loading