Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d4e77ac
fix(docker): make auth bootstrap safe for mounted and upgraded configs
Adarsh-Me Sep 3, 2026
564e08b
fix(docker): close review gaps in auth bootstrap alignment
Adarsh-Me Sep 11, 2026
548391f
fix(docker): close review gaps in auth bootstrap parsing and rewrite
Adarsh0087 Sep 12, 2026
ff07e3f
fix(docker): keep the config inode when rewriting properties
Adarsh-Me Sep 13, 2026
77543d4
fix(docker): refuse one-sided auth bootstrap and pre-create tmp 0600
Sep 16, 2026
6c0751d
fix(docker): close the remaining auth bootstrap review gaps
Adarsh-Me Sep 22, 2026
843f588
test(docker): cover the rollback branch where restoring also fails
Adarsh-Me Sep 22, 2026
71d9ad1
fix(docker): decide authentication by side, not by class
Adarsh-Me Sep 23, 2026
7a35508
fix(docker): read properties and yaml the way the server does
Adarsh-Me Sep 23, 2026
698a6ae
fix(docker): let enable-auth.sh answer what the entrypoint asks
Adarsh-Me Sep 23, 2026
857a211
fix(docker): read the authenticator value the server actually reads
Adarsh-Me Sep 24, 2026
2e7ed31
fix(docker): answer the config questions the guards cannot resolve
Adarsh-Me Sep 24, 2026
d456d43
fix(docker): fail closed on layouts the guards resolved too optimisti…
Adarsh-Me Sep 24, 2026
5208f7c
fix(docker): read the yaml shapes the scanner still answered wrongly
Adarsh-Me Sep 25, 2026
87aec28
fix(docker): refuse to arm REST when the yaml names no authenticator
Adarsh-Me Sep 25, 2026
76058c6
fix(docker): reject an unusable AUTHENTICATOR_CLASS before writing it
Adarsh-Me Sep 26, 2026
642d3d2
fix(docker): read a flow collection that a child value leaves open
Adarsh-Me Sep 27, 2026
8d52034
fix(docker): answer yamlscan with what Settings.read() actually loads
Adarsh-Me Sep 27, 2026
5ac1e88
fix(docker): read a BOM, a node property and a CR as SnakeYAML does
Adarsh-Me Sep 28, 2026
eb07eb5
fix(docker): state get's real exit status, and drop the has mode noth…
Adarsh-Me Sep 28, 2026
bd1b888
fix(docker): read every value the script decides on before the first …
Adarsh-Me Sep 29, 2026
4d762f6
fix(docker): refuse a config the run cannot write, and do not call it…
Adarsh-Me Sep 29, 2026
5150e07
fix(docker): collapse a properties key the older image left defined t…
Adarsh-Me Oct 26, 2026
cf1f9a8
fix(docker): refuse duplicate authenticator definitions that disagree
Adarsh-Me Nov 4, 2026
91491bc
fix(docker): ship auth readers consistently
imbajin Nov 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ administrator must rotate it through the user API. This fix provides no automati
recovery when no administrator identity is usable; preserve the existing data and
arrange account recovery before upgrading.

When upgrading a mounted configuration, check `auth.authenticator` in
`conf/rest-server.properties` and `authentication.authenticator` in
`conf/gremlin-server.yaml` together. If the startup log reports conflicting
definitions, back up both files, keep the intended REST definition, and remove
any extra `authentication` mapping appended to the Gremlin file by an older
image. If you run `bin/enable-auth.sh` separately, use the YAML reader supplied
with the same Server distribution. When an existing Gremlin class cannot be
verified, configure the intended REST class explicitly before restarting.

For the verification commands below, load `.env` into your current shell and set the password:

```bash
Expand Down
1 change: 1 addition & 0 deletions hugegraph-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ RUN sed -i "s/^restserver.url.*$/restserver.url=http:\/\/0.0.0.0:8080/g" ./conf/
COPY --chown=${HG_UID}:${HG_GID} hugegraph-server/hugegraph-dist/docker/scripts/remote-connect.groovy ./scripts
COPY --chown=${HG_UID}:${HG_GID} hugegraph-server/hugegraph-dist/docker/scripts/detect-storage.groovy ./scripts
COPY --chown=${HG_UID}:${HG_GID} --chmod=755 hugegraph-server/hugegraph-dist/docker/docker-entrypoint.sh .
# Both auth configuration readers are included in the release bin/ directory.

EXPOSE 8080
VOLUME /hugegraph-server
Expand Down
1 change: 1 addition & 0 deletions hugegraph-server/Dockerfile-hstore
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ RUN cd /hugegraph-server/conf/graphs \
COPY --chown=${HG_UID}:${HG_GID} hugegraph-server/hugegraph-dist/docker/scripts/remote-connect.groovy ./scripts
#COPY hugegraph-server/hugegraph-dist/docker/scripts/detect-storage.groovy ./scripts
COPY --chown=${HG_UID}:${HG_GID} --chmod=755 hugegraph-server/hugegraph-dist/docker/docker-entrypoint.sh .
# Both auth configuration readers are included in the release bin/ directory.

EXPOSE 8080
VOLUME /hugegraph-server
Expand Down
138 changes: 138 additions & 0 deletions hugegraph-server/hugegraph-dist/docker/docker-entrypoint-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,28 @@
#
set -euo pipefail

# CI runs this harness under a backend matrix: server-ci.yml exports BACKEND for
# the rocksdb leg, which is the only leg that reaches these tests. The
# entrypoint maps BACKEND to HG_SERVER_BACKEND and then overwrites whatever a
# fixture writes into hugegraph.properties, so a case that decides on the
# on-disk backend -- the escaped-hstore assertion below -- would be answered by
# the matrix value rather than by the file it is checking, and would fail in CI
# while passing locally. Clear the inherited backend/pd environment so the
# harness is hermetic; cases that mean to drive the entrypoint from the
# environment set it on their own invocation (see the hstore mapping test). The
# production precedence (environment beats file) is left exactly as it is.
unset BACKEND HG_SERVER_BACKEND PD_PEERS HG_SERVER_PD_PEERS

SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
TEST_HOME=$(mktemp -d "${TMPDIR:-/tmp}/hugegraph-entrypoint-test.XXXXXX")
trap 'rm -rf "${TEST_HOME}"' EXIT

mkdir -p "${TEST_HOME}/bin" "${TEST_HOME}/conf/graphs" "${TEST_HOME}/docker"
cp "${SCRIPT_DIR}/docker-entrypoint.sh" "${TEST_HOME}/docker-entrypoint.sh"
# props.awk is packaged in the release bin/; the image gets it from there, and
# the entrypoint accepts it beside itself so this harness can stage either.
cp "${SCRIPT_DIR}/../src/assembly/static/bin/props.awk" "${TEST_HOME}/props.awk"
cp "${SCRIPT_DIR}/../src/assembly/static/bin/yamlscan.awk" "${TEST_HOME}/bin/yamlscan.awk"
touch "${TEST_HOME}/docker/init_complete"

cat > "${TEST_HOME}/conf/rest-server.properties" <<'EOF'
Expand Down Expand Up @@ -62,6 +78,7 @@ printf 'called\n' >> ./docker/enable-auth-calls
EOF
cat > "${TEST_HOME}/bin/wait-partition.sh" <<'EOF'
#!/usr/bin/env bash
printf 'called\n' >> ./docker/wait-partition-calls
exit 0
EOF
cat > "${TEST_HOME}/bin/wait-storage.sh" <<'EOF'
Expand Down Expand Up @@ -257,6 +274,36 @@ reused_trailing_space_secret=$(sed -n 's/^auth\.token_secret=//p' \
[[ "${trailing_space_secret}" == \
'SecretEnds\u00200123456789abcdefABCDE\u0020' ]]
[[ "${reused_trailing_space_secret}" == "${trailing_space_secret}" ]]
grep -Fqx 'auth.admin_pa=pa' \
"${TEST_HOME}/conf/rest-server.properties"
# The secret above ends in a space, and commons-configuration trims a physical
# line before it asks whether that line continues: the `\ ` the encoder used to
# write survives the trim as a lone trailing backslash, which pulls the property
# under it into the password -- that is how a file that plainly carried
# auth.admin_pa next to it would reach the server as one long secret. \u0020
# leaves the trimmer nothing to take.
grep -Fqx 'auth.token_secret=SecretEnds\u00200123456789abcdefABCDE\u0020' \
"${TEST_HOME}/conf/rest-server.properties" || {
echo "a trailing space must not be written as a backslash-space" >&2
sed -n 's/^auth\.token_secret=/written: [&]/p' \
"${TEST_HOME}/conf/rest-server.properties" >&2
exit 1
}
# Round trip: the secret comes back with both spaces it started with, and the
# property written under it is still its own property.
props_read() {
PROPS_MODE=get PROPS_DECODED=1 PROPS_KEY="$1" \
PROPS_FILE="${TEST_HOME}/conf/rest-server.properties" \
awk -f "${TEST_HOME}/props.awk" /dev/null
}
[[ "$(props_read auth.token_secret)" == 'SecretEnds 0123456789abcdefABCDE ' ]] || {
echo "auth.token_secret lost its spaces: [$(props_read auth.token_secret)]" >&2
exit 1
}
[[ "$(props_read auth.admin_pa)" == "pa" ]] || {
echo "auth.admin_pa is not its own property any more: [$(props_read auth.admin_pa)]" >&2
exit 1
}
grep -Fqx 'auth.admin_pa=pa' \
"${TEST_HOME}/conf/rest-server.properties"

Expand Down Expand Up @@ -561,5 +608,96 @@ for invalid_k8s_flag in 1 0 enabled "t rue" "tr ue"; do
"${TEST_HOME}/conf/graphs/hugegraph.properties"
done

# A mounted rest-server.properties that already carries auth.authenticator,
# with no matching yaml mapping and no PASSWORD given, used to start without a
# word: the parity check ran only inside the PASSWORD branch, so nothing ever
# compared the two sides and the server came up with REST enforcing and Gremlin
# on AllowAllAuthenticator. The check now runs on every start, and a refusal
# has to come before anything touches the backend.
printf '%s\n' 'host: 8182' > "${TEST_HOME}/conf/gremlin-server.yaml"
grep -qx 'auth.authenticator=org.apache.hugegraph.auth.StandardAuthenticator' \
"${TEST_HOME}/conf/rest-server.properties" ||
printf '%s\n' \
'auth.authenticator=org.apache.hugegraph.auth.StandardAuthenticator' \
>> "${TEST_HOME}/conf/rest-server.properties"
rm -f "${TEST_HOME}/docker/init_complete"
before_calls="$(wc -l < "${TEST_HOME}/docker/init-store-calls")"
before_auth="$(wc -l < "${TEST_HOME}/docker/enable-auth-calls")"
status=0
(
cd "${TEST_HOME}"
bash ./docker-entrypoint.sh
) || status=$?
if (( status == 0 )); then
echo "entrypoint must refuse a mounted REST-only authenticator with no PASSWORD" >&2
exit 1
fi
if [[ "$(wc -l < "${TEST_HOME}/docker/init-store-calls")" != "${before_calls}" ]]; then
echo "the refusal must happen before init-store runs" >&2
exit 1
fi
if [[ "$(wc -l < "${TEST_HOME}/docker/enable-auth-calls")" != "${before_auth}" ]]; then
echo "a refused start must not run enable-auth.sh" >&2
exit 1
fi

# The same start is accepted once both sides agree, so the check above is a
# parity decision and not a blanket refusal to run without PASSWORD.
printf '%s\n' \
'authentication: {' \
' authenticator: org.apache.hugegraph.auth.StandardAuthenticator,' \
' config: {tokens: conf/rest-server.properties}' \
'}' > "${TEST_HOME}/conf/gremlin-server.yaml"
rm -f "${TEST_HOME}/docker/init_complete"
(
cd "${TEST_HOME}"
bash ./docker-entrypoint.sh
)

# ── The stabilization check follows the backend the JVM actually loaded ──
# ACTUAL_BACKEND is compared against a literal, so it has to be the decoded
# value. A mounted hugegraph.properties may spell the word with a unicode
# escape for the s, which java.util.Properties hands the server as hstore;
# reading the on-disk escaping instead compared something else to hstore,
# skipped wait-partition.sh, and let startup continue before the partitions
# were assigned. bs is the backslash, taken from its code point rather than
# written here: printf '%c' 92 hands back the digit 9, which would have built a
# fixture holding a different word than the one being decoded.
bs=$(awk 'BEGIN { printf "%c", 92 }')
if [[ "${#bs}" != 1 || "$(printf '%d' "'${bs}")" != 92 ]]; then
echo "this host did not yield a backslash for code point 92" >&2
exit 1
fi
touch "${TEST_HOME}/docker/init_complete"
rm -f "${TEST_HOME}/docker/wait-partition-calls"
printf '%s\n' "backend=h${bs}u0073tore" 'pd.peers=pd:8686' \
> "${TEST_HOME}/conf/graphs/hugegraph.properties"
if [[ "$(head -n 1 "${TEST_HOME}/conf/graphs/hugegraph.properties")" != \
"backend=h${bs}u0073tore" ]]; then
echo "the fixture has to hold the escaped bytes, not the decoded word" >&2
exit 1
fi
(
cd "${TEST_HOME}"
bash ./docker-entrypoint.sh

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

⚠️ [P2] Isolate this config-driven invocation from the CI backend environment. Server CI exports BACKEND=rocksdb; the entrypoint maps it to HG_SERVER_BACKEND and overwrites this fixture's escaped hstore, so the assertion at line 436 fails. This reproduces with BACKEND=rocksdb and passes when BACKEND and HG_SERVER_BACKEND are unset. Clear inherited backend variables for these config-driven cases rather than changing production environment precedence.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in 5940fa5. The harness now unsets inherited BACKEND/HG_SERVER_BACKEND/PD_PEERS/HG_SERVER_PD_PEERS at the top, so the escaped hstore fixture decides the stabilization check instead of the CI matrix value. Production env precedence is unchanged; env-driven cases set it per invocation. Reproduced: the test failed under BACKEND=rocksdb before, passes after.

)
if [[ ! -s "${TEST_HOME}/docker/wait-partition-calls" ]]; then
echo "an escaped hstore backend must still reach wait-partition.sh" >&2
exit 1
fi
# The other half: this is a read that follows the server, not a switch that
# simply always waits.
rm -f "${TEST_HOME}/docker/wait-partition-calls"
printf '%s\n' 'backend=rocksdb' 'pd.peers=pd:8686' \
> "${TEST_HOME}/conf/graphs/hugegraph.properties"
(
cd "${TEST_HOME}"
bash ./docker-entrypoint.sh
)
if [[ -e "${TEST_HOME}/docker/wait-partition-calls" ]]; then
echo "wait-partition.sh ran for a rocksdb backend" >&2
exit 1
fi

echo "PASS: Docker entrypoint configures HStore discovery and authentication"
bash "${SCRIPT_DIR}/test/test-docker-entrypoint-process.sh"
Loading
Loading