tju-yxq opened a new pull request, #5314:
URL: https://github.com/apache/rocketmq-dashboard/pull/5314

   ### Which Issue(s) This PR Fixes
   
   - Fixes #5313
   
   ### Brief Description
   
   Attributes every issued session to the client it was issued to:
   
   - `rmq_studio_session` gains `client_ip` (VARCHAR 64) and `user_agent` 
(VARCHAR 255); `StudioSessionSchemaMigration` adds both columns at startup to 
databases created before the current schema, mirroring the existing 
`QueryHistorySchemaMigration` pattern (metadata-checked, idempotent, tolerant 
of concurrent instances). Existing rows keep NULL and render as a dash.
   - The login controller forwards the client address and `User-Agent`. Behind 
a reverse proxy the socket address is the proxy's, so the first 
`X-Forwarded-For` hop is preferred when present. The values are observability 
metadata for the session drawer only — never used for authorization — and are 
truncated to the column widths instead of failing the login.
   - `AuthService.login` gains a `(request, clientIp, userAgent)` overload; the 
original signature delegates with nulls so every existing caller and test is 
unchanged.
   - The sessions drawer gains an **Origin** column: the address, with the full 
user agent on hover; legacy rows show a dash.
   - The properties-based (in-memory) auth mode is unchanged (single-user dev 
fallback, no session rows).
   
   ### How Did You Test This Change?
   
   Focused suites on the branch (Windows, Java 21, Node 20; based on 
`rocketmq-studio` at `6a68042f`):
   
   ```
   cd server && mvn 
'-Dtest=StudioSessionSchemaMigrationTest,AuthControllerTest,AuthServiceDatabaseTest,AuthServiceTest,StudioUserControllerTest'
 test
   [INFO] Tests run: 2,  Failures: 0 ... -- in 
...StudioSessionSchemaMigrationTest
   [INFO] Tests run: 11, Failures: 0 ... -- in ...AuthControllerTest
   [INFO] Tests run: 32, Failures: 0 ... -- in ...AuthServiceDatabaseTest
   [INFO] Tests run: 16, Failures: 0 ... -- in ...AuthServiceTest
   [INFO] Tests run: 5,  Failures: 0 ... -- in ...StudioUserControllerTest
   [INFO] BUILD SUCCESS
   ```
   
   New tests: the H2 migration test covers adding both columns to a 
pre-existing table with its rows intact, double-run idempotence, and the 
missing-table skip; the controller tests cover the first-forwarded-hop 
extraction (`X-Forwarded-For: 198.51.100.9, 10.0.0.1` → `198.51.100.9`) and the 
socket-address fallback; the service tests cover attribution persisted on the 
issued session, overlong user agents truncated to 255, and nulls kept for the 
legacy signature. The three existing login controller tests were re-stubbed for 
the new overload.
   
   ```
   cd web && npm test -- UserManagement.test.tsx --run
    Test Files  1 passed (1)
         Tests  12 passed (12)
   ```
   
   The drawer test now also asserts the attributed session's address renders 
and the legacy unattributed row shows a dash.
   
   ```
   cd web && npm run lint
   ✖ 10 problems (0 errors, 10 warnings)   # all pre-existing warnings in files 
this PR does not touch
   ```
   
   ```
   cd web && npx tsc -b --force
   (no output — exit 0)
   ```
   
   ### Checklist
   
   - [x] One coherent change; unrelated modifications are not bundled in
   - [x] Commit subject follows Conventional Commits
   - [x] Tests added or updated for non-trivial changes, test methods named 
`...Test`
   - [x] New UI text has both Chinese and English entries under `web/src/i18n/`
   - [x] Architecture constraints stay green (`mvn test` runs the ArchUnit 
checks)
   - [x] New source files carry the ASF license header
   - [ ] Documentation touched where behaviour changed (README / `docs/` / 
in-app help)
   


-- 
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]

Reply via email to