Skip to content

fix(hubble): use bearer token for authenticated clients - #23

Draft
imbajin wants to merge 1 commit into
masterfrom
cx-hubble-pd-auth-only
Draft

fix(hubble): use bearer token for authenticated clients#23
imbajin wants to merge 1 commit into
masterfrom
cx-hubble-pd-auth-only

Conversation

@imbajin

@imbajin imbajin commented Jul 22, 2026

Copy link
Copy Markdown

Summary

  • send Hubble JWT credentials with the standard Bearer scheme
  • preserve Bearer authentication when reusing request-scoped clients
  • verify the real HugeClient request header sent to the Gremlin endpoint

This PR intentionally excludes all .codex environment changes.

Related PR

Scope audit

Verification

  • JDK 11 Hubble unit suite: 396 tests passed
  • Apache RAT: passed for hubble-be
  • independent review and re-review: no actionable authentication findings
  • local branch image built as local/hugegraph-hubble:hubble-pd

Pending before ready

  • clean-volume four-service Docker E2E requires local BuildKit cache cleanup; no image will be pushed

- 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
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6c84d66a-f7c4-43a3-87e9-481b15329e27

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cx-hubble-pd-auth-only

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 with GraphConnection.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.

Comment on lines +91 to +92
RequestContextHolder.setRequestAttributes(
new ServletRequestAttributes(request));
Comment on lines +45 to +52
server.createContext("/gremlin", exchange -> {
authorization.set(exchange.getRequestHeaders()
.getFirst("Authorization"));
respond(exchange, "{\"requestId\":\"1\"," +
"\"status\":{\"message\":\"\",\"code\":200," +
"\"attributes\":{}}," +
"\"result\":{\"data\":[1],\"meta\":{}}}");
});
Comment on lines +115 to +117
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());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants