fix(hubble): use bearer token for authenticated clients - #23
Conversation
- send JWT credentials through the standard Bearer scheme - preserve token auth when request-scoped clients are reused - cover the actual client-to-Gremlin authorization header
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
This PR updates Hubble’s HugeClient authentication to send JWT credentials using the standard Bearer scheme (including when reusing request-scoped clients) and adds tests to verify the Authorization header sent to Gremlin.
Changes:
- Set
Authorization: Bearer <jwt>when connecting withGraphConnection.token() - Update request-scoped temporary clients to preserve Bearer authentication on reuse
- Add/extend unit tests to validate Bearer usage end-to-end and on reused clients
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/util/HugeClientUtil.java | Applies Bearer auth context when a token is provided in GraphConnection. |
| hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/controller/BaseController.java | Switches reused request-scoped client auth scheme from Basic to Bearer. |
| hugegraph-hubble/hubble-be/src/test/java/org/apache/hugegraph/util/HugeClientUtilTest.java | Adds an HTTP server–backed test that asserts the Gremlin request carries Authorization: Bearer .... |
| hugegraph-hubble/hubble-be/src/test/java/org/apache/hugegraph/unit/BaseControllerGremlinClientTest.java | Adds a test ensuring reused temporary clients set Bearer auth context. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| RequestContextHolder.setRequestAttributes( | ||
| new ServletRequestAttributes(request)); |
| server.createContext("/gremlin", exchange -> { | ||
| authorization.set(exchange.getRequestHeaders() | ||
| .getFirst("Authorization")); | ||
| respond(exchange, "{\"requestId\":\"1\"," + | ||
| "\"status\":{\"message\":\"\",\"code\":200," + | ||
| "\"attributes\":{}}," + | ||
| "\"result\":{\"data\":[1],\"meta\":{}}}"); | ||
| }); |
| if (StringUtils.isNotBlank(connection.getToken())) { | ||
| client.setAuthContext("Bearer " + connection.getToken().trim()); | ||
| } |
| if (request.getAttribute("hugeClient") != null) { | ||
| HugeClient client = (HugeClient) request.getAttribute("hugeClient"); | ||
| client.setAuthContext("Basic " + this.getToken()); | ||
| client.setAuthContext("Bearer " + this.getToken()); |
Summary
This PR intentionally excludes all .codex environment changes.
Related PR
Scope audit
Verification
Pending before ready