Skip to content

feat: Add Admin user role and category authorization #34

Merged
rogargon merged 5 commits into
mainfrom
Admin
Oct 26, 2025
Merged

feat: Add Admin user role and category authorization #34
rogargon merged 5 commits into
mainfrom
Admin

Conversation

@gilito11

Copy link
Copy Markdown
Contributor

Summary

  • Implement Admin user entity with ROLE_ADMIN authority
  • Add AdminRepository and AdminEventHandler for admin user management
  • Create CategoryEventHandler to enforce admin-only access for category creation
  • Update DBInitialization to create default admin user (username: admin, password: password)
  • Update Category feature tests to use admin authentication
  • Re-enable authorization test to verify non-admin users cannot create categories

Changes

  • New files:

    • src/main/java/cat/udl/eps/softarch/demo/domain/Admin.java - Admin entity extending User
    • src/main/java/cat/udl/eps/softarch/demo/repository/AdminRepository.java - Admin repository
    • src/main/java/cat/udl/eps/softarch/demo/handler/AdminEventHandler.java - Password encoding handler
    • src/main/java/cat/udl/eps/softarch/demo/handler/CategoryEventHandler.java - Authorization enforcement
  • Modified files:

    • src/main/java/cat/udl/eps/softarch/demo/config/DBInitialization.java - Added admin user initialization
    • src/test/resources/features/Category.feature - Updated scenarios to use admin login

Test plan

  • Category creation scenarios use admin authentication
  • Non-admin users receive 403 when attempting to create categories
  • Admin user is created on application startup
  • All validation scenarios still work correctly

@francesc-contreras-tech

Copy link
Copy Markdown
Collaborator

Hello @gilito11, please check the reason why CI/CD have failed.

image

@rogargon rogargon merged commit df39c95 into main Oct 26, 2025
1 check passed
@rogargon rogargon linked an issue Oct 26, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Admin's Entity

3 participants