PD REST Authentication#
The PD (Placement Driver) REST API uses a lightweight internal authentication scheme designed exclusively for service-to-service communication between HugeGraph components (hg, store, hubble, vermeer). It is not intended for external or public-facing access. The codebase itself warns: "DO NOT expose RPC interfaces to external networks" and recommends IP whitelisting and network-level controls as the primary security layer in production .
Key entry points:
| Class | Role |
|---|---|
Authentication | Base logic: decodes Authorization header, checks service name |
RestAuthentication | Spring HandlerInterceptor that applies Authentication to every REST request |
AuthenticationConfigurer | Registers the interceptor and declares the bypass path list |
TokenUtil | Generates and verifies JWT-style tokens using a shared secretKey |
How Auth Works: Service-Name-Only Validation#
Every REST request (except bypass paths, see below) passes through RestAuthentication.preHandle(), which:
- Reads the
Authorizationheader and strips theBasicprefix. - Base64-decodes the value and splits on the first
:to extractnameand password. - Calls
Authentication.authenticate(), which checks whethernameis in the allowed set{"hg", "store", "hubble", "vermeer"}.
The password is never validated. A TODO comment in the source explicitly marks this:
// TODO: password validation is skipped โ only service name is checked against innerModules.
Any caller that sends a valid service name with any password (including an empty string) is granted access. This means the authorization boundary is the network perimeter, not the credential itself.
On auth failure, RestAuthentication writes a JSON error body via API.toJSON(e) and returns false to abort the handler chain โ but it never sets an HTTP status code. The response therefore defaults to 200 OK even when access is denied . This is a known gap: clients relying on HTTP status codes to detect auth refusal will misread a rejection as success.
Interceptor Bypass: Unauthenticated Endpoints#
AuthenticationConfigurer applies the interceptor to /** but excludes three path patterns from auth :
/actuator/*
/v1/health
/v1/prom/targets/*
/v1/health is intentionally unauthenticated so that Docker health checks, Kubernetes liveness probes, and wait-storage.sh can reach it without credentials. However, /v1/health is not quorum-aware โ it returns 200 OK with an empty body as soon as the Spring HTTP listener is up, regardless of Raft state . This means a PD node that has lost its Raft leader will still report healthy, causing downstream services to connect to an inoperable node.
A PR (#3185) is open to address this by adding an unauthenticated /v1/ready endpoint that returns 200 only when RaftEngine.isReady() is true (node active and leader known), and 503 otherwise . AuthenticationConfigurer would also exclude /v1/ready from auth. Kubernetes users are advised to keep liveness probes on /v1/health and point readiness probes at /v1/ready โ using /v1/ready for liveness would restart a PD that merely lost its leader .
/v1/members, which carries full Raft membership information, remains behind auth and cannot be used by kubelet probes .
Token Generation and the Shared Secret#
TokenUtil wraps TokenGenerator (from hugegraph-core) to issue and verify short-lived bearer tokens used for intra-cluster calls:
- Issue:
getToken(String[] info)creates a JWT-style payload keyed onAuthConstant.TOKEN_USER_NAME, signs it with the configuredsecretKey, Base64-encodes the result, and sets expiry to 24 hours (AUTH_TOKEN_EXPIRE = 3600 * 24L * 1000ms) . - Verify:
verify(String token, String[] info)Base64-decodes the token and compares it to the expected value . - Key namespace: token keys in the store are namespaced as
"PD/TOKEN/" + nameviaAuthentication.getTokenKey().
The Pd-Token HTTP header carries this token on requests; RestAuthentication reads it and echoes a refreshed token back via the same header when auth succeeds .
The secretKey must be shared across PD, Server, Store, and Hubble for token verification to work. In Docker deployments, this secret is not explicitly bootstrapped by the entrypoints โ PD's entrypoint configures Raft/gRPC/REST topology only , while Server's entrypoint handles PASSWORD for the admin user but not the PD secretKey . Issue #3133 documents further problems with the entrypoint's grep/sed-based config mutation, including the PASSWORD being visible in ps output and config rewriting that diverges from how HugeConfig parses the same file .
Known Issues and Operational Guidance#
| Issue | Status | Reference |
|---|---|---|
| Password is never validated โ service name alone grants access | Open (TODO in code) | |
Auth refusal returns 200 OK with a JSON error body instead of 401/403 | Open | |
/v1/health has no Raft quorum awareness | Fix in PR #3185 (open) | |
Docker entrypoint auth bootstrap uses grep/sed that diverges from HugeConfig parsing; PASSWORD visible in ps | Open (issue #3133) |
Operational notes:
- Network isolation is the real security boundary. PD REST authentication relies on service names, not passwords. VPC isolation and firewall rules are required in production .
- Do not gate critical automation on
/v1/healthalone. Until PR #3185 merges, a PD that lost its Raft leader still returns200. Use/v1/members(requires auth) or the Prometheus metrics endpoint (/actuator/prometheus) as supplementary signals โ noting that the existinghg_upgauge is hardcoded to1andhg_termsis a partition-term counter, neither of which reflects quorum state . - Prometheus targets path is also unauthenticated.
/v1/prom/targets/*is excluded from the interceptor alongside/v1/healthand/actuator/*.