imbajin commented on code in PR #2899: URL: https://github.com/apache/incubator-hugegraph/pull/2899#discussion_r2489974709
########## hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/auth/ManagerAPI.java: ########## @@ -0,0 +1,279 @@ +/* + * Copyright 2017 HugeGraph Authors + * + * 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 org.apache.hugegraph.api.auth; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.hugegraph.api.API; +import org.apache.hugegraph.api.filter.StatusFilter; +import org.apache.hugegraph.auth.AuthManager; +import org.apache.hugegraph.auth.HugeGraphAuthProxy; +import org.apache.hugegraph.auth.HugePermission; +import org.apache.hugegraph.core.GraphManager; +import org.apache.hugegraph.define.Checkable; +import org.apache.hugegraph.util.E; +import org.apache.hugegraph.util.Log; +import org.slf4j.Logger; + +import com.codahale.metrics.annotation.Timed; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.common.collect.ImmutableMap; + +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.inject.Singleton; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.DELETE; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.QueryParam; +import jakarta.ws.rs.core.Context; + +@Path("graphspaces/{graphspace}/auth/managers") +@Singleton +@Tag(name = "ManagerAPI") +public class ManagerAPI extends API { + + private static final Logger LOG = Log.logger(ManagerAPI.class); + + @POST + @Timed + @StatusFilter.Status(StatusFilter.Status.CREATED) + @Consumes(APPLICATION_JSON) + @Produces(APPLICATION_JSON_WITH_CHARSET) Review Comment: **🧹 次要问题: 缺少输入参数验证** 在 `ManagerAPI.createManager` 方法中,应该先验证 `graphSpace` 和 `user` 参数的有效性,然后再进行业务逻辑处理。 **建议:** ```suggestion public String createManager(@Context GraphManager manager, @PathParam("graphspace") String graphSpace, JsonManager jsonManager) { LOG.debug("Create manager: {}", jsonManager); E.checkArgumentNotNull(graphSpace, "Graph space cannot be null"); E.checkArgument(!graphSpace.trim().isEmpty(), "Graph space cannot be empty"); String user = jsonManager.user; HugePermission type = jsonManager.type; // ... rest of the method ``` -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
