You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hugegraph.apache.org by "bitflicker64 (via GitHub)" <gi...@apache.org> on 2026/10/02 11:35:03 UTC
[PR] fix: remove duplicate TokenGenerator from hugegraph-struct [hugegraph]
bitflicker64 opened a new pull request, #3257:
URL: https://github.com/apache/hugegraph/pull/3257
## Purpose of the PR
No linked issue; this removes a duplicate class.
`hugegraph-struct` has its own `org.apache.hugegraph.auth.TokenGenerator`, with the same fully qualified name as the one in `hugegraph-core`. The method bodies are the same, but the config constructor reads `auth.token_secret` through a different `AuthOptions`:
| Copy | Option holder | Default for `auth.token_secret` |
|---|---|---|
| `hugegraph-core` | `org.apache.hugegraph.config.AuthOptions` | `generateRandomBase64Key()`, random per process |
| `hugegraph-struct` | `org.apache.hugegraph.options.AuthOptions` | a fixed string |
`hugegraph-core` depends on `hg-store-common`, which depends on `hugegraph-struct`, so a built Server `lib/` ships both jars and both contain `auth/TokenGenerator.class`. The JVM uses whichever comes first on the classpath. `bin/hugegraph-server.sh` builds the classpath with `find ... 'hugegraph*.jar' | sort`, and `core` sorts before `struct`, so the Server loads the core copy today. Nothing else enforces that order. When the auth graph's config does not set `auth.token_secret`, `HugeConfig.get()` returns the option's own default, so the copy that loads decides the default signing key.

The only other code using this class name is PD's `pd/util/TokenUtil`, which nothing references. PD auth (REST and gRPC) compares a Basic-auth password with `auth.secret-key` in `Authentication.verifySecret()` and does not use `TokenGenerator`.
## Main Changes
- Delete `hugegraph-struct/.../auth/TokenGenerator.java`.
- Delete `AUTH_TOKEN_SECRET` from `hugegraph-struct/.../options/AuthOptions.java`, together with the private `generateRandomBase64Key()` helper that had no callers.
- Delete `hugegraph-pd/hg-pd-service/.../pd/util/TokenUtil.java` (no callers).
- `PDConfig.PUBLISHED_SECRET_KEY` is unchanged.
After this change there is one class named `org.apache.hugegraph.auth.TokenGenerator`, so classpath order no longer matters for it. A Server started with `bin/hugegraph-server.sh` behaves the same as before, because it already loaded the core copy.
Left for follow-ups to keep this diff small:
- struct `options.AuthOptions` has no remaining references. Its other options duplicate keys that core already defines.
- `hugegraph-struct/pom.xml` still declares `jjwt-*` and `jakarta.ws.rs-api`, and no struct source uses them now. Removing them touches the dependency lists.
- struct and core share other class names as well. This PR only handles `TokenGenerator`, because its two copies read different defaults.
## Verifying these changes
- [ ] Trivial rework / code cleanup without any test coverage. (No Need)
- [ ] Already covered by existing tests, such as *(please modify tests here)*.
- [x] Need tests and can be verified as follows:
- Build, JDK 11, on this branch (base `176fb56dd`):
`mvn -pl hugegraph-struct,hugegraph-pd/hg-pd-service,hugegraph-store/hg-store-common,hugegraph-server/hugegraph-core -am -DskipTests install` passes, and so does
`mvn -pl hugegraph-store/hg-store-core,hugegraph-store/hg-store-client,hugegraph-server/hugegraph-hstore,hugegraph-server/hugegraph-api -am -DskipTests test-compile`.
- `mvn -pl hugegraph-pd/hg-pd-service -am -Dtest=AuthenticationTest -Dsurefire.failIfNoSpecifiedTests=false test`: 10 run, 0 failures.
- Which jar the class loads from, with a small probe that calls `Class.forName("org.apache.hugegraph.auth.TokenGenerator", false, ...)` and prints the code source. "Before" uses a Server `lib/` built from `c6853e70c` plus one unrelated query change; the files touched here are identical between that build and `176fb56dd`. "After" uses this branch's jars:
```
BEFORE -cp core,struct TokenGenerator loaded from hugegraph-core-1.7.0.jar
BEFORE -cp struct,core TokenGenerator loaded from hugegraph-struct-1.7.0.jar
AFTER -cp struct,core TokenGenerator loaded from hugegraph-core-1.7.0.jar
AFTER struct jar: 0 entries for auth/TokenGenerator.class
```
- `git grep -n 'TokenUtil'` returns nothing, and `git grep -n 'import org.apache.hugegraph.options.AuthOptions' -- hugegraph-struct` returns nothing.
## Does this PR potentially affect the following parts?
- [ ] Dependencies ([add/update license](https://hugegraph.apache.org/docs/contribution-guidelines/contribute/#321-check-licenses) info & [regenerate_known_dependencies.sh](../install-dist/scripts/dependency/regenerate_known_dependencies.sh))
- [ ] Modify configurations
- [ ] The public API
- [x] Other affects (typed here): removes the struct copy of `auth.TokenGenerator`, the struct `auth.token_secret` option and PD's `TokenUtil`. None of them has a caller in this repository.
- [ ] Nope
## Documentation Status
- [ ] `Doc - TODO`: required documentation is pending; complete it before merging.
- [ ] `Doc - Done`: documentation is included here or linked below.
- [x] `Doc - No Need`: no user-visible documentation is affected.
Documentation files in this PR or paired hugegraph-doc PR:
--
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: remove duplicate TokenGenerator from hugegraph-struct [hugegraph]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #3257:
URL: https://github.com/apache/hugegraph/pull/3257#issuecomment-5951589696
## [Codecov](https://app.codecov.io/gh/apache/hugegraph/pull/3257?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 93.25%. Comparing base ([`176fb56`](https://app.codecov.io/gh/apache/hugegraph/commit/176fb56dd747ef0f60a126cf721aa12d17627c31?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`3513810`](https://app.codecov.io/gh/apache/hugegraph/commit/35138100d6a731b69784377c0293c0639f0ef041?dropdown=coverage&el=desc&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 #3257 +/- ##
=============================================
+ Coverage 41.57% 93.25% +51.68%
+ Complexity 7311 65 -7246
=============================================
Files 793 9 -784
Lines 69106 267 -68839
Branches 9258 22 -9236
=============================================
- Hits 28730 249 -28481
+ Misses 37098 8 -37090
+ Partials 3278 10 -3268
```
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/hugegraph/pull/3257?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: remove duplicate TokenGenerator from hugegraph-struct [hugegraph]
Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin merged PR #3257:
URL: https://github.com/apache/hugegraph/pull/3257
--
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: remove duplicate TokenGenerator from hugegraph-struct [hugegraph]
Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin commented on PR #3257:
URL: https://github.com/apache/hugegraph/pull/3257#issuecomment-5967070716
TokenUtil is retained in this PR while the duplicate Struct TokenGenerator is removed. The follow-up shared-foundation refactor in [hugegraph/hugegraph#260](https://github.com/hugegraph/hugegraph/pull/260) moves the single JWT implementation from Core into hugegraph-common; PD can continue delegating to that shared implementation, with dependency ownership handled as part of that migration.
--
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