-
Notifications
You must be signed in to change notification settings - Fork 625
feat: support secure Hubble monitoring targets #3096
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
imbajin
merged 15 commits into
apache:master
from
hugegraph:cdx/hubble-monitoring-pd-secret-redaction
Jul 21, 2026
Merged
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
fd32ab3
fix(pd): redact secret from config logs
imbajin 2ccc4e2
feat(pd): expose store rest address
imbajin 72f902c
fix(server): apply explicit graph limits
imbajin c917bd1
fix(pd): share store rest address utility
imbajin 544c58d
fix(server): accept bearer auth for Gremlin HTTP
imbajin 08297e7
feat(server): support scoped PD auth metadata
imbajin 9e650ff
fix(server): parse HTTP Basic credentials correctly
imbajin eb0a59e
test(server): align scoped target metadata
imbajin 91f6cef
fix(auth): enforce scoped metadata contracts
imbajin 988d016
fix(auth): reject foreign scoped access targets
imbajin 674771b
test(auth): isolate target schema upgrade fixture
imbajin 6ebd15c
fix(auth): enforce graphspace isolation
imbajin 5b082f8
fix(auth): preserve identity and redact bearer tokens
imbajin f3e0cef
fix(auth): tighten scoped access boundaries
imbajin 87fcddc
fix(pd): restore reactor test compilation
imbajin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
...raph-pd/hg-pd-common/src/main/java/org/apache/hugegraph/pd/util/StoreRestAddressUtil.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.hugegraph.pd.util; | ||
|
|
||
| import java.net.URI; | ||
| import java.util.Optional; | ||
|
|
||
| import org.apache.hugegraph.pd.grpc.Metapb; | ||
|
|
||
| public final class StoreRestAddressUtil { | ||
|
|
||
| private static final String REST_PORT_LABEL = "rest.port"; | ||
|
|
||
| private StoreRestAddressUtil() { | ||
| } | ||
|
|
||
| public static String getRestAddress(Metapb.Store store) { | ||
| if (store == null || store.getAddress().isEmpty()) { | ||
| return null; | ||
| } | ||
|
|
||
| Optional<String> label = store.getLabelsList().stream() | ||
| .filter(item -> REST_PORT_LABEL.equals( | ||
| item.getKey())) | ||
| .map(Metapb.StoreLabel::getValue) | ||
| .findFirst(); | ||
| if (!label.isPresent()) { | ||
| return null; | ||
| } | ||
|
|
||
| int port; | ||
| try { | ||
| port = Integer.parseInt(label.get().trim()); | ||
| } catch (NumberFormatException ignored) { | ||
| return null; | ||
| } | ||
| if (port < 1 || port > 65535) { | ||
| return null; | ||
| } | ||
|
|
||
| try { | ||
| String address = store.getAddress().trim(); | ||
| URI uri = address.contains("://") ? URI.create(address) : | ||
| URI.create("http://" + address); | ||
| String host = uri.getHost(); | ||
| if (host == null || host.isEmpty()) { | ||
| return null; | ||
| } | ||
| String hostPart = host.contains(":") && !host.startsWith("[") ? | ||
| "[" + host + "]" : host; | ||
| return hostPart + ":" + port; | ||
| } catch (IllegalArgumentException ignored) { | ||
| return null; | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
hugegraph-pd/hg-pd-test/src/main/java/org/apache/hugegraph/pd/core/PDConfigTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.hugegraph.pd.core; | ||
|
|
||
| import org.apache.hugegraph.pd.config.PDConfig; | ||
| import org.junit.Assert; | ||
| import org.junit.Test; | ||
|
|
||
| public class PDConfigTest { | ||
|
|
||
| @Test | ||
| public void testToStringDoesNotExposeSecretKey() { | ||
| PDConfig config = new PDConfig(); | ||
| config.setClusterId(123L); | ||
| config.setDataPath("pd-test-data"); | ||
| config.setInitialStoreList(""); | ||
| config.setSecretKey("secret-value-that-must-not-appear"); | ||
|
|
||
| String text = config.toString(); | ||
|
|
||
| Assert.assertEquals("secret-value-that-must-not-appear", | ||
| config.getSecretKey()); | ||
| Assert.assertFalse(text.contains("secret-value-that-must-not-appear")); | ||
| Assert.assertFalse(text.contains("secretKey")); | ||
| Assert.assertTrue(text.contains("clusterId=123")); | ||
| Assert.assertTrue(text.contains("dataPath=pd-test-data")); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
...ph-pd/hg-pd-test/src/main/java/org/apache/hugegraph/pd/util/StoreRestAddressUtilTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.hugegraph.pd.util; | ||
|
|
||
| import static org.junit.Assert.assertEquals; | ||
| import static org.junit.Assert.assertNull; | ||
|
|
||
| import org.apache.hugegraph.pd.grpc.Metapb; | ||
| import org.junit.Test; | ||
|
|
||
| public class StoreRestAddressUtilTest { | ||
|
|
||
| @Test | ||
| public void testBuildIPv4RestAddress() { | ||
| Metapb.Store store = store("127.0.0.1:8500", "8520"); | ||
|
|
||
| assertEquals("127.0.0.1:8520", | ||
| StoreRestAddressUtil.getRestAddress(store)); | ||
| } | ||
|
|
||
| @Test | ||
| public void testBuildIPv6RestAddress() { | ||
| Metapb.Store store = store("[2001:db8::1]:8500", "8520"); | ||
|
|
||
| assertEquals("[2001:db8::1]:8520", | ||
| StoreRestAddressUtil.getRestAddress(store)); | ||
| } | ||
|
|
||
| @Test | ||
| public void testBuildRestAddressFromUri() { | ||
| Metapb.Store store = store("http://store.example:8500", "8520"); | ||
|
|
||
| assertEquals("store.example:8520", | ||
| StoreRestAddressUtil.getRestAddress(store)); | ||
| } | ||
|
|
||
| @Test | ||
| public void testRejectMissingOrInvalidRestPort() { | ||
| assertNull(StoreRestAddressUtil.getRestAddress( | ||
| store("127.0.0.1:8500", null))); | ||
| assertNull(StoreRestAddressUtil.getRestAddress( | ||
| store("127.0.0.1:8500", "0"))); | ||
| assertNull(StoreRestAddressUtil.getRestAddress( | ||
| store("127.0.0.1:8500", "65536"))); | ||
| assertNull(StoreRestAddressUtil.getRestAddress( | ||
| store("127.0.0.1:8500", "8520/path"))); | ||
| } | ||
|
|
||
| @Test | ||
| public void testRejectMissingOrMalformedStoreAddress() { | ||
| assertNull(StoreRestAddressUtil.getRestAddress(store("", "8520"))); | ||
| assertNull(StoreRestAddressUtil.getRestAddress( | ||
| store("2001:db8::1:8500", "8520"))); | ||
| } | ||
|
|
||
| private static Metapb.Store store(String address, String restPort) { | ||
| Metapb.Store.Builder builder = Metapb.Store.newBuilder() | ||
| .setAddress(address); | ||
| if (restPort != null) { | ||
| builder.addLabels(Metapb.StoreLabel.newBuilder() | ||
| .setKey("rest.port") | ||
| .setValue(restPort)); | ||
| } | ||
| return builder.build(); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.