-
Notifications
You must be signed in to change notification settings - Fork 636
fix(pd): validate REST credentials and return 401 on refusal #3189
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
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
f796637
fix(pd): validate REST credentials and return 401 on refusal
bitflicker64 1e3b616
fix(pd): fail closed when auth.secret-key is absent, wire every client
bitflicker64 5c339c1
fix(pd): ship no REST secret and keep the credential out of argv
bitflicker64 3b39132
fix(pd): unbreak the hstore smoke, decode credentials as UTF-8
bitflicker64 b352e8c
chore(ci): retrigger build-commons after a port-collision flake
bitflicker64 ace8913
test(pd): cover the REST credential check in process
bitflicker64 94b1566
fix(pd): move the auth test where it compiles, close review gaps
bitflicker64 e964b68
fix(pd): generate Hubble's PD credential, abort wait-storage on 401
bitflicker64 94a4a0f
fix(pd): ignore the generator's temp file, correct the 401 docs
bitflicker64 a890122
docs(pd): match the actuator exclusion the interceptor ships
bitflicker64 fdec006
docs(pd): correct why actuator paths stay anonymous
bitflicker64 ffd88d3
docs(pd): correct the same rationale in the shipped conf comments
bitflicker64 10f590a
fix(ci): keep PD's test secret out of the Store launch
bitflicker64 687b90e
fix(pd): harden the cluster-test PD config template
bitflicker64 8344ec9
fix(pd): pin the actuator allowlist for carried-over configs
bitflicker64 470f4a7
fix(docker): stop Compose creating the Hubble config path
bitflicker64 504ab01
fix(server): tidy wait-storage's PD credential handling
bitflicker64 e420f9a
fix(pd): harden the cluster-test PD config template
bitflicker64 edc9518
fix(pd): pin the actuator allowlist for carried-over configs
bitflicker64 25bcb53
fix(docker): stop Compose creating the Hubble config path
bitflicker64 63a54e9
fix(server): tidy wait-storage's PD credential handling
bitflicker64 597d751
Merge master into fix/pd-rest-auth-3188
bitflicker64 61ae6f5
docs(pd): note that the Docker image pins the actuator allowlist
bitflicker64 b98db41
fix(ci): unbreak the Compose render contracts and name failures
bitflicker64 ae2a39a
fix(pd): close the remaining review gaps on the REST credential
bitflicker64 0711045
Merge master into fix/pd-rest-auth-3188
bitflicker64 cf50aa5
fix(server): abort the storage wait only when every PD peer refuses
bitflicker64 23284b7
fix(pd): remove duplicate junit dependency in hg-pd-service pom
imbajin 3075487
fix(pd): handle basic auth scheme case-insensitively and align docs
imbajin ee98ef9
fix(pd): streamline docker README, unwrap markdown lines, and expand …
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| #!/usr/bin/env bash | ||
| # | ||
| # 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. | ||
| # | ||
| # Generate the Hubble properties file a Compose topology mounts, with PD's | ||
| # REST secret written in as operations.pd.password. | ||
| # | ||
| # usage: set-hubble-pd-password.sh <hstore|hstore-ha> [secret] | ||
| # | ||
| # Reads conf/hubble/<name>.properties.example (tracked) and writes | ||
| # conf/hubble/<name>.local.properties (ignored by git), so the secret never | ||
| # lands in a tracked file. The secret defaults to $HG_PD_AUTH_SECRET_KEY. The | ||
| # value never goes through a sed replacement, where & # and backslash are | ||
| # special, and backslashes are doubled for the .properties format. Run this | ||
| # before `docker compose up`: the bind pins create_host_path: false, so a | ||
| # missing target makes Compose refuse to start. | ||
| # | ||
| # The secret must be printable ASCII. PD compares it as UTF-8 bytes | ||
| # (Authentication.verifySecret), while Hubble reads this file through | ||
| # commons-configuration2, whose DEFAULT_ENCODING is ISO-8859-1, so a non-ASCII | ||
| # secret decodes to different bytes on the two sides and gives a permanent 401 | ||
| # with no diagnostic anywhere. The README recipe generates hex, which is safe. | ||
| set -euo pipefail | ||
|
|
||
| name=${1:?usage: $0 <hstore|hstore-ha> [secret]} | ||
| secret=${2:-${HG_PD_AUTH_SECRET_KEY:-}} | ||
| dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/conf/hubble" | ||
| example="${dir}/${name}.properties.example" | ||
| out="${dir}/${name}.local.properties" | ||
|
|
||
| [[ -f "$example" ]] || { echo "no such topology: ${name} (expected ${example})" >&2; exit 1; } | ||
| [[ -n "$secret" ]] || { echo "secret is empty; load .env first (set -a; . ./.env; set +a)" >&2; exit 1; } | ||
| case "$secret" in | ||
| *$'\n'*|*$'\r'*) echo "secret contains a line break, which a .properties value cannot hold" >&2; exit 1 ;; | ||
|
bitflicker64 marked this conversation as resolved.
|
||
| esac | ||
| # LC_ALL=C so the range is ordinal and the walk byte-wise: under the caller's | ||
| # collation a non-ASCII character can sort inside \x20-\x7e and slip through. | ||
| is_printable_ascii() { | ||
| local LC_ALL=C | ||
| case "$1" in | ||
| *[!$'\x20'-$'\x7e']*) return 1 ;; | ||
| esac | ||
| } | ||
| is_printable_ascii "$secret" || { | ||
| echo "secret must be printable ASCII: Hubble reads .properties as ISO-8859-1, PD compares as UTF-8" >&2 | ||
| exit 1 | ||
| } | ||
|
|
||
| escaped=${secret//\\/\\\\} | ||
| # java.util.Properties skips whitespace between the separator and the value, so | ||
| # a secret that starts with a space would reach Hubble shortened while PD and | ||
| # the Server kept the original. A backslash before it keeps that first byte. | ||
| case "$escaped" in | ||
| [$' \t']*) escaped="\\${escaped}" ;; | ||
| esac | ||
| tmp=$(mktemp "${out}.XXXXXX") | ||
| trap 'rm -f "$tmp"' EXIT | ||
| { | ||
| printf '# Generated from %s by set-hubble-pd-password.sh; not tracked by git.\n' "$(basename "$example")" | ||
| grep -v '^operations\.pd\.password=' "$example" || true | ||
| printf 'operations.pd.password=%s\n' "$escaped" | ||
| } > "$tmp" | ||
| # Hubble runs unprivileged and the mount is read-only, so the file must be world-readable | ||
| chmod 644 "$tmp" | ||
| mv "$tmp" "$out" | ||
| trap - EXIT | ||
| echo "wrote ${out}" | ||
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.