zhaohai666 opened a new pull request, #456:
URL: https://github.com/apache/rocketmq-dashboard/pull/456
## 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>`
2. Parameter Validation
Throw `BusinessException` with error code 400 when username or password is
null or blank
3. 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`
4. 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`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]