Skip to content

Commit

Permalink
Merge pull request #972 from MaxFedotov/orchestrator-client_support_h…
Browse files Browse the repository at this point in the history
…eaders_auth

orchestrator-client add support for headers auth
  • Loading branch information
Shlomi Noach committed Nov 5, 2019
2 parents 9a75f0b + a0295f6 commit e05d957
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion resources/bin/orchestrator-client
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pool=
hostname_flag=
api_path=
basic_auth="${ORCHESTRATOR_AUTH_USER:-}:${ORCHESTRATOR_AUTH_PASSWORD:-}"
headers_auth="${ORCHESTRATOR_AUTH_USER_HEADER}"
binlog=

instance_hostport=
Expand Down Expand Up @@ -89,12 +90,13 @@ for arg in "$@"; do
"-path"|"--path") set -- "$@" "-P" ;;
"-query"|"--query") set -- "$@" "-q" ;;
"-auth"|"--auth") set -- "$@" "-b" ;;
"-headers-auth"|"--headers-auth") set -- "$@" "-e" ;;
"-binlog"|"--binlog") set -- "$@" "-n" ;;
*) set -- "$@" "$arg"
esac
done

while getopts "c:i:d:s:a:D:U:o:r:u:R:t:l:H:P:q:b:n:h" OPTION
while getopts "c:i:d:s:a:D:U:o:r:u:R:t:l:H:P:q:b:e:n:h" OPTION
do
case $OPTION in
h) command="help" ;;
Expand All @@ -114,6 +116,7 @@ do
U) [ ! -z "$OPTARG" ] && orchestrator_api="$OPTARG" ;;
P) api_path="$OPTARG" ;;
b) basic_auth="$OPTARG" ;;
e) headers_auth="$OPTARG" ;;
n) binlog="$OPTARG" ;;
q) query="$OPTARG"
esac
Expand Down Expand Up @@ -151,6 +154,10 @@ function get_curl_auth_params {
requires_auth+=" --disallow-username-in-url"
fi

if [[ -n "${headers_auth}" ]]; then
requires_auth="-H "${headers_auth}""
fi

# Test API access
curl "${requires_auth}" -s --head "${orchestrator_api}" 2>&1 | fgrep -q "$unauthorized_401" && \
echo "$unauthorized_401" && \
Expand Down Expand Up @@ -352,6 +359,8 @@ function prompt_help {
With '-c api', indicate the specific API path you wish to call
-b <username:password>, --auth <username:password>
Specify when orchestrator uses basic HTTP auth.
-e <header:user>, --headers-auth <header:user>
Specify when orchestrator uses headers auth.
-q <query>, --query <query>
Indicate query for 'restart-replica-statements' command
-l <pool name>, --pool <pool name>
Expand Down

0 comments on commit e05d957

Please sign in to comment.