Skip to content

[Studio] feat: add login and auth page#456

Open
zhaohai666 wants to merge 1 commit into
apache:rocketmq-studiofrom
zhaohai666:feature/studio-auth
Open

[Studio] feat: add login and auth page#456
zhaohai666 wants to merge 1 commit into
apache:rocketmq-studiofrom
zhaohai666:feature/studio-auth

Conversation

@zhaohai666

Copy link
Copy Markdown

Summary

Add login and authentication module for RocketMQ Studio, providing user login/logout REST API with JWT token support and Spring Security configuration placeholder.

Files Changed

7 files modified, total 427 line insertions

Source Files (5)

File Lines Description
auth/AuthController.java 44 REST controller, provides POST /api/auth/login and POST /api/auth/logout interfaces
auth/AuthService.java 60 Authentication service layer, implements credential verification, mock JWT token generation and admin identity judgment logic
auth/LoginDTO.java 26 Login request DTO, contains username and password fields
auth/LoginVO.java 42 Login response VO, carries token, expiration time and nested user information (username, admin identity flag)
auth/SecurityConfig.java 25 Spring Security configuration class marked with @configuration, reserved placeholder (TODO: complete after introducing related dependencies)

Test Files (2)

File Lines Description
auth/AuthControllerTest.java 115 WebMvcTest for controller layer: verify normal login token return, admin identity identification and logout success logic
auth/AuthServiceTest.java 115 Mockito unit test for service layer: verify valid credential login, admin flag judgment, empty username/password parameter verification and logout logic

Key Design

  1. API Endpoints
  • POST /api/auth/login: Return unified response Result<LoginVO> carrying mock JWT token
  • POST /api/auth/logout: Return unified empty response Result<Void>
  1. Parameter Validation
    Throw BusinessException with error code 400 when username or password is null or blank
  2. Mock Authentication Logic
  • Accept any non-empty username and password combination to generate mock token in format mock-jwt-{UUID}
  • Mark user as admin if username is exactly admin
  1. Unified Response Standard
    Reuse Result<T> wrapper and global BusinessException defined in common module to keep consistent API return format

Dependencies

Depends on PR#1 (feature/studio-common-foundation), relies on the unified response Result and global business exception BusinessException provided by the common foundation module

Test Coverage

  • AuthControllerTest: 3 test cases (normal login, admin user login, logout)
  • AuthServiceTest: 7 test cases (valid login, admin identity judgment, 4 parameter validation error scenarios, logout)

PR Title Rule Reminder

All PR and Issue titles of this project must start with [studio] for community quick filtering and tracking.
Example: [studio] feat: add login and JWT authentication module

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.

1 participant