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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
