feat(server):swagger support auth for standardAuth mode (#2360)
* feat(server):swagger support auth for standardAuth mode and try to fix arthas odd test
* chore(api): update api version & swagger token auth mode
diff --git a/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/filter/AuthenticationFilter.java b/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/filter/AuthenticationFilter.java
index 464e695..d3da3af 100644
--- a/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/filter/AuthenticationFilter.java
+++ b/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/filter/AuthenticationFilter.java
@@ -72,7 +72,8 @@
private static final List<String> WHITE_API_LIST = ImmutableList.of(
"auth/login",
- "versions"
+ "versions",
+ "openapi.json"
);
private static String whiteIpStatus;
diff --git a/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/server/ApplicationConfig.java b/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/server/ApplicationConfig.java
index d70e6e0..a605101 100644
--- a/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/server/ApplicationConfig.java
+++ b/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/server/ApplicationConfig.java
@@ -44,8 +44,21 @@
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Contact;
import io.swagger.v3.oas.annotations.info.Info;
+import io.swagger.v3.oas.annotations.enums.SecuritySchemeType;
+import io.swagger.v3.oas.annotations.security.SecurityRequirement;
+import io.swagger.v3.oas.annotations.security.SecurityScheme;
import jakarta.ws.rs.ApplicationPath;
+@SecurityScheme(
+ name = "basic",
+ type = SecuritySchemeType.HTTP,
+ scheme = "basic"
+)
+@SecurityScheme(
+ name = "bearer",
+ type = SecuritySchemeType.HTTP,
+ scheme = "bearer"
+)
@ApplicationPath("/")
@OpenAPIDefinition(
info = @Info(
@@ -53,7 +66,8 @@
version = CoreVersion.DEFAULT_VERSION,
description = "All management API for HugeGraph",
contact = @Contact(url = "https://github.com/apache/hugegraph", name = "HugeGraph")
- )
+ ),
+ security = {@SecurityRequirement(name = "basic"), @SecurityRequirement(name = "bearer")}
)
public class ApplicationConfig extends ResourceConfig {
diff --git a/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/version/ApiVersion.java b/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/version/ApiVersion.java
index 969e9a3..8170827 100644
--- a/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/version/ApiVersion.java
+++ b/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/version/ApiVersion.java
@@ -114,12 +114,14 @@
* [0.67] Issue-1065: Support dynamically add/remove graph
* [0.68] Issue-1763: Support adamic-adar & resource-allocation API
* [0.69] Issue-1748: Support Cypher query RESTful API
+ * [0.70] Issue-2242: Optimising adjacency edge queries
+ * [0.71] PR-2286: Support Arthas API & Metric API prometheus format
*/
/**
* The second parameter of Version.of() is for IDE running without JAR
*/
- public static final Version VERSION = Version.of(ApiVersion.class, "0.69");
+ public static final Version VERSION = Version.of(ApiVersion.class, "0.71");
public static void check() {
// Check version of hugegraph-core. Firstly do check from version 0.3
diff --git a/hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/api/ArthasApiTest.java b/hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/api/ArthasApiTest.java
index c73276b..52d0d74 100644
--- a/hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/api/ArthasApiTest.java
+++ b/hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/api/ArthasApiTest.java
@@ -40,10 +40,7 @@
public void testArthasApi() {
String body = "{\n" +
" \"action\": \"exec\",\n" +
- " \"requestId\": \"req112\",\n" +
- " \"consumerId\": \"955dbd1325334a84972b0f3ac19de4f7_2\",\n" +
- " \"command\": \"version\",\n" +
- " \"execTimeout\": \"10000\"\n" +
+ " \"command\": \"version\"\n" +
"}";
RestClient arthasApiClient = new RestClient(ARTHAS_API_BASE_URL, false);
// If the request header contains basic auth,
@@ -52,8 +49,6 @@
Response r = arthasApiClient.post(ARTHAS_API_PATH, body);
String result = assertResponseStatus(200, r);
assertJsonContains(result, "state");
- assertJsonContains(result, "requestId");
- assertJsonContains(result, "sessionId");
assertJsonContains(result, "body");
RestClient arthasApiClientWithAuth = new RestClient(ARTHAS_API_BASE_URL);