You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hugegraph.apache.org by "imbajin (via GitHub)" <gi...@apache.org> on 2026/10/17 04:26:50 UTC
[PR] fix(api): allow anonymous cypher queries [hugegraph]
imbajin opened a new pull request, #3366:
URL: https://github.com/apache/hugegraph/pull/3366
## Purpose of the PR
With Server authentication disabled, both Cypher GET and POST requests still returned 401 unless an Authorization header was supplied. This also prevented Hubble from executing Cypher in anonymous mode. Cypher now follows the Server authentication switch and connects to Gremlin without credentials when authentication is disabled.
## Main Changes
- Use GraphManager authentication mode for both Cypher resource methods.
- Add an anonymous Cypher client that clears credentials from a cloned driver configuration, so a deployment service account is never inherited.
- Keep the existing Basic/Bearer path when authentication is enabled, and document the connection behavior.
## Verifying these changes
- [ ] Trivial rework / code cleanup without any test coverage. (No Need)
- [ ] Already covered by existing tests.
- [x] Need tests and can be verified as follows:
- Focused Cypher client tests cover anonymous configuration isolation and authenticated header handling.
- API module clean compilation and formatter checks; compilation targets Java 17 using a local JDK 21, with the Java-version enforcer skipped.
- Real Server HTTP GET/POST requests with authentication disabled return query results without login or credentials. With authentication enabled on both REST and Gremlin, missing/invalid credentials are rejected, valid Basic/Bearer queries succeed, and a restricted reader cannot read another graph or write data.
- An anonymous Hubble instance generates Cypher through a local model fixture and executes it against the fixed Server; edited write queries are rejected by Hubble.
## Does this PR potentially affect the following parts?
- [ ] Dependencies
- [ ] Modify configurations
- [x] The public API
- [ ] Other affects
- [ ] Nope
## Documentation Status
- [ ] `Doc - TODO`: required documentation is pending.
- [x] `Doc - Done`: documentation is included here.
- [ ] `Doc - No Need`: no user-visible documentation is affected.
Documentation: `docs/cypher-api.md`, Authentication section.
Related Hubble integration: https://github.com/hugegraph/hugegraph-toolchain/pull/75 and https://github.com/apache/hugegraph-toolchain/pull/824.
Org counterpart: https://github.com/hugegraph/hugegraph/pull/321.
--
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: issues-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [PR] fix(api): allow anonymous cypher queries [hugegraph]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #3366:
URL: https://github.com/apache/hugegraph/pull/3366#issuecomment-6229786812
## [Codecov](https://app.codecov.io/gh/apache/hugegraph/pull/3366?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `23.07692%` with `10 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 42.17%. Comparing base ([`92af2f8`](https://app.codecov.io/gh/apache/hugegraph/commit/92af2f89c320c3e6fa7c10765a061f3edadea319?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`650dee6`](https://app.codecov.io/gh/apache/hugegraph/commit/650dee6d5412b6d5f4f606ce62f2de41e0de0f7b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 27 commits behind head on master.
| [Files with missing lines](https://app.codecov.io/gh/apache/hugegraph/pull/3366?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [.../org/apache/hugegraph/api/cypher/CypherClient.java](https://app.codecov.io/gh/apache/hugegraph/pull/3366?src=pr&el=tree&filepath=hugegraph-server%2Fhugegraph-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fhugegraph%2Fapi%2Fcypher%2FCypherClient.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aHVnZWdyYXBoLXNlcnZlci9odWdlZ3JhcGgtYXBpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9odWdlZ3JhcGgvYXBpL2N5cGhlci9DeXBoZXJDbGllbnQuamF2YQ==) | 0.00% | [6 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/hugegraph/pull/3366?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...ava/org/apache/hugegraph/api/cypher/CypherAPI.java](https://app.codecov.io/gh/apache/hugegraph/pull/3366?src=pr&el=tree&filepath=hugegraph-server%2Fhugegraph-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fhugegraph%2Fapi%2Fcypher%2FCypherAPI.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aHVnZWdyYXBoLXNlcnZlci9odWdlZ3JhcGgtYXBpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9odWdlZ3JhcGgvYXBpL2N5cGhlci9DeXBoZXJBUEkuamF2YQ==) | 60.00% | [1 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/hugegraph/pull/3366?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...org/apache/hugegraph/api/cypher/CypherManager.java](https://app.codecov.io/gh/apache/hugegraph/pull/3366?src=pr&el=tree&filepath=hugegraph-server%2Fhugegraph-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fhugegraph%2Fapi%2Fcypher%2FCypherManager.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aHVnZWdyYXBoLXNlcnZlci9odWdlZ3JhcGgtYXBpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9odWdlZ3JhcGgvYXBpL2N5cGhlci9DeXBoZXJNYW5hZ2VyLmphdmE=) | 0.00% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/hugegraph/pull/3366?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #3366 +/- ##
=============================================
- Coverage 54.31% 42.17% -12.14%
+ Complexity 2250 2 -2248
=============================================
Files 770 507 -263
Lines 67952 48882 -19070
Branches 9213 7071 -2142
=============================================
- Hits 36905 20615 -16290
+ Misses 27470 25863 -1607
+ Partials 3577 2404 -1173
```
| [Flag](https://app.codecov.io/gh/apache/hugegraph/pull/3366/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [server_rocksdb](https://app.codecov.io/gh/apache/hugegraph/pull/3366/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `42.17% <23.07%> (?)` | |
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/hugegraph/pull/3366?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
</details>
--
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: issues-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [PR] fix(api): allow anonymous cypher queries [hugegraph]
Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin merged PR #3366:
URL: https://github.com/apache/hugegraph/pull/3366
--
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: issues-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [PR] fix(api): allow anonymous cypher queries [hugegraph]
Posted by "bitflicker64 (via GitHub)" <gi...@apache.org>.
bitflicker64 commented on code in PR #3366:
URL: https://github.com/apache/hugegraph/pull/3366#discussion_r4301465283
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/cypher/CypherAPI.java:
##########
@@ -176,10 +179,14 @@ private CypherModel queryByCypher(HttpHeaders headers, String graphspace,
aliases.put("graph", graphInfo);
aliases.put("g", "__g_" + graphInfo);
- return this.client(headers).submitQuery(cypher, aliases, parameters);
+ return this.client(manager, headers).submitQuery(cypher, aliases, parameters);
}
- private CypherClient client(HttpHeaders headers) {
+ private CypherClient client(GraphManager manager, HttpHeaders headers) {
+ if (!manager.requireAuthentication()) {
Review Comment:
Minor: When REST auth is off, this returns the anonymous client before reading the Authorization header, so caller credentials are no longer forwarded to Gremlin. GremlinAPI still forwards the header in the same mode (GremlinAPI.java:67 and :81).
Setup: rest-server.properties has no auth.authenticator, while gremlin-server.yaml has the StandardAuthenticator block. Before this PR, Cypher with a valid Basic header worked there. Now the header is ignored, the Gremlin handshake sends no credentials and the query fails, while Gremlin GET/POST with the same header still works. No shipped script produces this setup, so this is not blocking.
Please use the anonymous client only when no Authorization header is sent, or state in docs/cypher-api.md that this mixed setup is unsupported.
--
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: issues-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org