You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "zhaohai666 (via GitHub)" <gi...@apache.org> on 2026/07/18 05:09:51 UTC

[PR] [Studio] feat: add login and auth page [rocketmq-dashboard]

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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Studio] feat: add login and auth page [rocketmq-dashboard]

Posted by "lizhimins (via GitHub)" <gi...@apache.org>.
lizhimins closed pull request #456: [Studio] feat: add login and auth page
URL: https://github.com/apache/rocketmq-dashboard/pull/456


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Studio] feat: add login and auth page [rocketmq-dashboard]

Posted by "RockteMQ-AI (via GitHub)" <gi...@apache.org>.
RockteMQ-AI commented on code in PR #456:
URL: https://github.com/apache/rocketmq-dashboard/pull/456#discussion_r4001310933


##########
server/src/main/java/com/rocketmq/studio/auth/AuthService.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.rocketmq.studio.auth;
+
+import com.rocketmq.studio.common.exception.BusinessException;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import java.util.UUID;
+
+@Slf4j
+@Service
+public class AuthService {
+
+    public LoginVO login(LoginDTO request) {
+        log.info("Login attempt for user: {}", request.getUsername());
+
+        if (request.getUsername() == null || request.getUsername().isBlank()) {
+            throw new BusinessException(400, "Username is required");
+        }
+        if (request.getPassword() == null || request.getPassword().isBlank()) {
+            throw new BusinessException(400, "Password is required");
+        }

Review Comment:
   **[Warning]** This is mock authentication that accepts any non-empty credentials. For the Studio MVP this is acceptable, but please add a TODO comment marking this as needing real authentication before production deployment. Consider integrating with the existing RocketMQ dashboard ACL system.



##########
server/src/main/java/com/rocketmq/studio/auth/AuthService.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.rocketmq.studio.auth;
+
+import com.rocketmq.studio.common.exception.BusinessException;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import java.util.UUID;
+
+@Slf4j
+@Service
+public class AuthService {
+
+    public LoginVO login(LoginDTO request) {
+        log.info("Login attempt for user: {}", request.getUsername());
+
+        if (request.getUsername() == null || request.getUsername().isBlank()) {
+            throw new BusinessException(400, "Username is required");
+        }
+        if (request.getPassword() == null || request.getPassword().isBlank()) {
+            throw new BusinessException(400, "Password is required");
+        }
+
+        // Mock authentication — accept any non-empty credentials
+        String token = "mock-jwt-" + UUID.randomUUID();

Review Comment:
   **[Info]** The token is a simple UUID prefix. For production, this should be a proper JWT with signature verification. Consider adding a `JwtTokenProvider` abstraction so the implementation can be swapped later.



-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Studio] feat: add login and auth page [rocketmq-dashboard]

Posted by "lizhimins (via GitHub)" <gi...@apache.org>.
lizhimins commented on PR #456:
URL: https://github.com/apache/rocketmq-dashboard/pull/456#issuecomment-5045281170

   Closing as superseded: the login/auth backend (AuthController, AuthService, LoginDTO/VO, SecurityConfig) is already present on the rocketmq-studio branch, introduced by commit 49bc4419 ("feat: implement backend common module and auth"). The files are identical, so this PR is a no-op. Thanks for the contribution!


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org