mirror of
https://github.com/HariSekhon/DevOps-Bash-tools.git
synced 2025-02-06 11:00:21 +00:00
updated curl_auth.sh paths
This commit is contained in:
parent
310820b8a7
commit
39589660d4
@ -54,4 +54,4 @@ shift || :
|
||||
|
||||
export TOKEN="$APPVEYOR_TOKEN"
|
||||
|
||||
"$srcdir/curl_auth.sh" -sS --fail "https://ci.appveyor.com/api/$url_path" "$@"
|
||||
"$srcdir/../bin/curl_auth.sh" -sS --fail "https://ci.appveyor.com/api/$url_path" "$@"
|
||||
|
@ -161,4 +161,4 @@ url_path="${url_path/:repo/$repo}"
|
||||
url_path="${url_path/<repo>/$repo}"
|
||||
url_path="${url_path/\{repo\}/$repo}"
|
||||
|
||||
"$srcdir/curl_auth.sh" "$url_base/$url_path" "${CURL_OPTS[@]}" "$@"
|
||||
"$srcdir/../bin/curl_auth.sh" "$url_base/$url_path" "${CURL_OPTS[@]}" "$@"
|
||||
|
@ -67,4 +67,4 @@ shift || :
|
||||
# https://docs.cloudera.com/documentation/enterprise/6/6.3/topics/cn_navigator_api_overview.html#api-version-compatility
|
||||
api_version="${CLOUDERA_API_VERSION:-7}"
|
||||
|
||||
"$srcdir/curl_auth.sh" "$CLOUDERA_MANAGER/api/v${api_version}${url_path}" -sS --fail --connect-timeout 5 "$@"
|
||||
"$srcdir/../bin/curl_auth.sh" "$CLOUDERA_MANAGER/api/v${api_version}${url_path}" -sS --fail --connect-timeout 5 "$@"
|
||||
|
@ -69,4 +69,4 @@ shift || :
|
||||
|
||||
api_version="${CLOUDERA_API_VERSION:-10}"
|
||||
|
||||
"$srcdir/curl_auth.sh" "$CLOUDERA_NAVIGATOR/api/v${api_version}${url_path}" -sS --fail --connect-timeout 5 "$@"
|
||||
"$srcdir/../bin/curl_auth.sh" "$CLOUDERA_NAVIGATOR/api/v${api_version}${url_path}" -sS --fail --connect-timeout 5 "$@"
|
||||
|
@ -84,7 +84,7 @@ export TOKEN="$BUILDKITE_TOKEN"
|
||||
BUILDKITE_ORGANIZATION="${BUILDKITE_ORGANIZATION:-${BUILDKITE_USER:-}}"
|
||||
|
||||
if [[ "$url_path" =~ {organization} ]]; then
|
||||
organizations="$("$srcdir/curl_auth.sh" -sS --fail "$url_base/organizations" | jq -r '.[].slug')"
|
||||
organizations="$("$srcdir/../bin/curl_auth.sh" -sS --fail "$url_base/organizations" | jq -r '.[].slug')"
|
||||
num_organizations="$(wc -w <<< "$organizations" | sed 's/[[:space:]]//g')"
|
||||
if [ "$num_organizations" -eq 0 ]; then
|
||||
usage "\$BUILDKITE_ORGANIZATION / \$BUILDKITE_USER not set and could not find any organizations for the \$BUILDKITE_TOKEN"
|
||||
@ -103,4 +103,4 @@ if [[ "$url_path" =~ {pipeline} ]]; then
|
||||
url_path="${url_path//\{pipeline\}/$BUILDKITE_PIPELINE}"
|
||||
fi
|
||||
|
||||
"$srcdir/curl_auth.sh" -sS --fail "$url_base/$url_path" "$@"
|
||||
"$srcdir/../bin/curl_auth.sh" -sS --fail "$url_base/$url_path" "$@"
|
||||
|
@ -69,13 +69,13 @@ fi
|
||||
|
||||
JENKINS_URL="${JENKINS_URL%%/}"
|
||||
|
||||
#crumb="$("$srcdir/curl_auth.sh" -sS --fail "$JENKINS_URL/crumbIssuer/api/json" | jq -r '.crumb')"
|
||||
#crumb="$("$srcdir/../bin/curl_auth.sh" -sS --fail "$JENKINS_URL/crumbIssuer/api/json" | jq -r '.crumb')"
|
||||
|
||||
echo "Validating Jenkinsfiles:"
|
||||
echo
|
||||
while read -r jenkinsfile; do
|
||||
echo -n "$jenkinsfile => "
|
||||
#"$srcdir/curl_auth.sh" "$JENKINS_URL/pipeline-model-converter/validate" -sS --fail -X POST -F "jenkinsfile=<Jenkinsfile" -H "Jenkins-Crumb: $crumb"
|
||||
#"$srcdir/../bin/curl_auth.sh" "$JENKINS_URL/pipeline-model-converter/validate" -sS --fail -X POST -F "jenkinsfile=<Jenkinsfile" -H "Jenkins-Crumb: $crumb"
|
||||
#"$srcdir/jenkins_api.sh" "/pipeline-model-converter/validate" -X POST -F "jenkinsfile=<Jenkinsfile"
|
||||
#"$srcdir/jenkins_api.sh" "/pipeline-model-converter/validate" -X POST -F "jenkinsfile=<$jenkinsfile"
|
||||
# 'export JENKINS_CLI_ARGS=-webSocket' is needed if Jenkins is behind a reverse proxy such as Kubernetes Ingress, otherwise Jenkins CLI hangs
|
||||
|
@ -82,7 +82,7 @@ curl_auth(){
|
||||
shift || :
|
||||
# need opt splitting
|
||||
# shellcheck disable=SC2086
|
||||
"$srcdir/curl_auth.sh" "$base_url/$url_path" -H 'Content-type: application/json' "$@" $curl_options |
|
||||
"$srcdir/../bin/curl_auth.sh" "$base_url/$url_path" -H 'Content-type: application/json' "$@" $curl_options |
|
||||
bugfix_gerrit_api_output
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,7 @@ url_base+="/go/api"
|
||||
|
||||
if [ -n "${GOCD_TOKEN:-}" ]; then
|
||||
export TOKEN="$GOCD_TOKEN"
|
||||
"$srcdir/curl_auth.sh" "$url_base/$url_path" "${CURL_OPTS[@]}" "$@"
|
||||
"$srcdir/../bin/curl_auth.sh" "$url_base/$url_path" "${CURL_OPTS[@]}" "$@"
|
||||
else
|
||||
curl "$url_base/$url_path" "${CURL_OPTS[@]}" "$@"
|
||||
fi
|
||||
|
@ -96,4 +96,4 @@ fi
|
||||
url_path="${url_path//$url_base}"
|
||||
url_path="${url_path##/}"
|
||||
|
||||
"$srcdir/curl_auth.sh" "$url_base/$url_path" "${CURL_OPTS[@]}" "$@"
|
||||
"$srcdir/../bin/curl_auth.sh" "$url_base/$url_path" "${CURL_OPTS[@]}" "$@"
|
||||
|
@ -92,5 +92,5 @@ export CURL_AUTH_HEADER="X-Octopus-ApiKey:"
|
||||
|
||||
url_base="$OCTOPUS_URL/api"
|
||||
|
||||
"$srcdir/curl_auth.sh" "$url_base/$url_path" ${CURL_OPTS:+"${CURL_OPTS[@]}"} "$@" |
|
||||
"$srcdir/../bin/curl_auth.sh" "$url_base/$url_path" ${CURL_OPTS:+"${CURL_OPTS[@]}"} "$@" |
|
||||
jq_debug_pipe_dump
|
||||
|
@ -153,4 +153,4 @@ url_path="${url_path##/}"
|
||||
#url_path="${url_path/<repo>/$repo}"
|
||||
#url_path="${url_path/\{repo\}/$repo}"
|
||||
|
||||
"$srcdir/curl_auth.sh" "$url_base/$url_path" "${CURL_OPTS[@]}" "$@"
|
||||
"$srcdir/../bin/curl_auth.sh" "$url_base/$url_path" "${CURL_OPTS[@]}" "$@"
|
||||
|
@ -167,4 +167,4 @@ url_path="${url_path##/}"
|
||||
|
||||
export TOKEN="$CLOUDFLARE_TOKEN"
|
||||
|
||||
"$srcdir/curl_auth.sh" "$url_base/$url_path" "${CURL_OPTS[@]}" "$@"
|
||||
"$srcdir/../bin/curl_auth.sh" "$url_base/$url_path" "${CURL_OPTS[@]}" "$@"
|
||||
|
@ -54,7 +54,7 @@ export TOKEN="$CLOUDFLARE_TOKEN"
|
||||
#-H "X-Auth-Key: $CLOUDFLARE_TOKEN" \
|
||||
|
||||
output="$(
|
||||
"$srcdir/curl_auth.sh" "https://api.cloudflare.com/client/v4/zones/$zone_id/purge_cache" \
|
||||
"$srcdir/../bin/curl_auth.sh" "https://api.cloudflare.com/client/v4/zones/$zone_id/purge_cache" \
|
||||
-sS -X POST \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-Auth-Email: $CLOUDFLARE_EMAIL" \
|
||||
|
@ -144,4 +144,4 @@ fi
|
||||
# unset to return to default setting for safety to avoid hard to debug changes of behaviour elsewhere
|
||||
shopt -u nocasematch
|
||||
|
||||
"$srcdir/curl_auth.sh" "$url_base/$url_path" "${CURL_OPTS[@]}" "$@"
|
||||
"$srcdir/../bin/curl_auth.sh" "$url_base/$url_path" "${CURL_OPTS[@]}" "$@"
|
||||
|
@ -50,7 +50,7 @@ export USER="$user"
|
||||
export PASSWORD="$CODESHIP_PASSWORD"
|
||||
|
||||
# has to be basic auth, don't allow token to be used as it will result in a 401
|
||||
output="$(NO_TOKEN_AUTH=1 "$srcdir/curl_auth.sh" https://api.codeship.com/v2/auth -X POST "${CURL_OPTS[@]}" "$@")"
|
||||
output="$(NO_TOKEN_AUTH=1 "$srcdir/../bin/curl_auth.sh" https://api.codeship.com/v2/auth -X POST "${CURL_OPTS[@]}" "$@")"
|
||||
|
||||
die_if_error_field "$output"
|
||||
|
||||
|
@ -76,7 +76,7 @@ shift || :
|
||||
if [[ "$url" =~ hub.docker.com ]]; then
|
||||
"$srcdir/dockerhub_api.sh" "$url" "$@"
|
||||
elif [ -n "${PASSWORD:-}" ]; then
|
||||
"$srcdir/curl_auth.sh" "$url" "${CURL_OPTS[@]}" "$@"
|
||||
"$srcdir/../bin/curl_auth.sh" "$url" "${CURL_OPTS[@]}" "$@"
|
||||
else
|
||||
curl "$url" "${CURL_OPTS[@]}" "$@"
|
||||
fi
|
||||
|
@ -93,7 +93,7 @@ if [ -n "${PASSWORD:-}" ]; then
|
||||
# since DockerHub has many different API addresses it's easier to use JWT which isn't limited to a predefined service address
|
||||
JWT=1
|
||||
if [ -n "${JWT:-}" ]; then
|
||||
#output="$("$srcdir/curl_auth.sh" https://hub.docker.com/v2/users/login/ \
|
||||
#output="$("$srcdir/../bin/curl_auth.sh" https://hub.docker.com/v2/users/login/ \
|
||||
output="$(curl https://hub.docker.com/v2/users/login/ \
|
||||
-X POST \
|
||||
"${CURL_OPTS[@]}" \
|
||||
@ -112,7 +112,7 @@ if [ -n "${PASSWORD:-}" ]; then
|
||||
export JWT_TOKEN="$token"
|
||||
else
|
||||
# OAuth2
|
||||
output="$("$srcdir/curl_auth.sh" https://auth.docker.io/token -X GET \
|
||||
output="$("$srcdir/../bin/curl_auth.sh" https://auth.docker.io/token -X GET \
|
||||
-H 'Content-Type: application/x-www-form-urlencoded' \
|
||||
-H 'Www-Authenticate: Bearer realm="https://auth.docker.io/token",service="hub.docker.com"' \
|
||||
-d "grant_type=password&access_type=online&client_id=${0##*}&service=hub.docker.com" # alternative: registry.docker.io
|
||||
@ -125,7 +125,7 @@ if [ -n "${PASSWORD:-}" ]; then
|
||||
if [ -z "$token" ] || [ "$token" = null ]; then
|
||||
die "Authentication failed: $output"
|
||||
fi
|
||||
"$srcdir/curl_auth.sh" "$url_base/$url_path" "${CURL_OPTS[@]}" "$@"
|
||||
"$srcdir/../bin/curl_auth.sh" "$url_base/$url_path" "${CURL_OPTS[@]}" "$@"
|
||||
else
|
||||
# proceed without authentication
|
||||
curl "$url_base/$url_path" "${CURL_OPTS[@]}" "$@"
|
||||
|
@ -90,4 +90,4 @@ export TOKEN="$DRONE_TOKEN"
|
||||
# this works
|
||||
#curl "${CURL_OPTS[@]}" -H @<(cat <<< "Authorization: Bearer $DRONE_TOKEN") "$url_base/$url_path" "$@"
|
||||
|
||||
"$srcdir/curl_auth.sh" "$url_base/$url_path" "${CURL_OPTS[@]}" "$@"
|
||||
"$srcdir/../bin/curl_auth.sh" "$url_base/$url_path" "${CURL_OPTS[@]}" "$@"
|
||||
|
@ -202,4 +202,4 @@ url_path="${url_path/\{repo\}/$repo}"
|
||||
url_path="${url_path/<repo>/$repo}"
|
||||
url_path="${url_path/:repo/$repo}"
|
||||
|
||||
"$srcdir/curl_auth.sh" "$url_base/$url_path" "${CURL_OPTS[@]}" "$@"
|
||||
"$srcdir/../bin/curl_auth.sh" "$url_base/$url_path" "${CURL_OPTS[@]}" "$@"
|
||||
|
@ -99,5 +99,5 @@ export TOKEN="$GITGUARDIAN_TOKEN"
|
||||
|
||||
export CURL_AUTH_HEADER="Authorization: Token"
|
||||
|
||||
"$srcdir/curl_auth.sh" "$url_base/$url_path" ${CURL_OPTS:+"${CURL_OPTS[@]}"} "$@" |
|
||||
"$srcdir/../bin/curl_auth.sh" "$url_base/$url_path" ${CURL_OPTS:+"${CURL_OPTS[@]}"} "$@" |
|
||||
jq_debug_pipe_dump
|
||||
|
@ -150,5 +150,5 @@ url_path="${url_path/:repo/$repo}"
|
||||
url_path="${url_path/<repo>/$repo}"
|
||||
#url_path="${url_path/\{repo\}/$repo}"
|
||||
|
||||
"$srcdir/curl_auth.sh" "$url_base/$url_path" ${CURL_OPTS:+"${CURL_OPTS[@]}"} "$@" |
|
||||
"$srcdir/../bin/curl_auth.sh" "$url_base/$url_path" ${CURL_OPTS:+"${CURL_OPTS[@]}"} "$@" |
|
||||
jq_debug_pipe_dump
|
||||
|
@ -210,4 +210,4 @@ export TOKEN="$GITLAB_TOKEN"
|
||||
# can also leave out to use OAuth compliant header "Authorization: Bearer <token>"
|
||||
export CURL_AUTH_HEADER="Private-Token:"
|
||||
|
||||
"$srcdir/curl_auth.sh" "$url_base/$url_path" "${CURL_OPTS[@]}" "$@"
|
||||
"$srcdir/../bin/curl_auth.sh" "$url_base/$url_path" "${CURL_OPTS[@]}" "$@"
|
||||
|
@ -89,8 +89,8 @@ if [ -n "${JENKINS_TOKEN:-}" ]; then
|
||||
export PASSWORD="$JENKINS_TOKEN"
|
||||
else
|
||||
export PASSWORD="${JENKINS_PASSWORD:-${JENKINS_TOKEN:-}}"
|
||||
crumb="$("$srcdir/curl_auth.sh" -sS --fail "$JENKINS_URL/crumbIssuer/api/json" | jq -r '.crumb')"
|
||||
crumb="$("$srcdir/../bin/curl_auth.sh" -sS --fail "$JENKINS_URL/crumbIssuer/api/json" | jq -r '.crumb')"
|
||||
CURL_OPTS+=(-H "Jenkins-Crumb: $crumb")
|
||||
fi
|
||||
|
||||
"$srcdir/curl_auth.sh" "$JENKINS_URL/$url_path" ${CURL_OPTS:+"${CURL_OPTS[@]}"} "$@"
|
||||
"$srcdir/../bin/curl_auth.sh" "$JENKINS_URL/$url_path" ${CURL_OPTS:+"${CURL_OPTS[@]}"} "$@"
|
||||
|
@ -51,5 +51,5 @@ shift || :
|
||||
export TOKEN="$token"
|
||||
|
||||
# XXX: have to use -k to not verify the certificate here because often it is self-signed
|
||||
#"$srcdir/curl_auth.sh" -k "$api_server$path" "$@"
|
||||
"$srcdir/curl_auth.sh" "$api_server$path" "$@"
|
||||
#"$srcdir/../bin/curl_auth.sh" -k "$api_server$path" "$@"
|
||||
"$srcdir/../bin/curl_auth.sh" "$api_server$path" "$@"
|
||||
|
@ -129,7 +129,7 @@ url_path="${url_path##/}"
|
||||
|
||||
export TOKEN="$PINGDOM_TOKEN"
|
||||
|
||||
"$srcdir/curl_auth.sh" "$url_base/$url_path" "${CURL_OPTS[@]}" "$@"
|
||||
"$srcdir/../bin/curl_auth.sh" "$url_base/$url_path" "${CURL_OPTS[@]}" "$@"
|
||||
|
||||
# args: /checks | jq .
|
||||
# args: /checks/<check_id>
|
||||
|
@ -44,4 +44,4 @@ export TOKEN="$SHIPPABLE_TOKEN"
|
||||
# non-standard auth header
|
||||
export CURL_AUTH_HEADER="Authorization: apiToken"
|
||||
|
||||
"$srcdir/curl_auth.sh" -sS --fail "https://api.shippable.com/$url_path" "$@"
|
||||
"$srcdir/../bin/curl_auth.sh" -sS --fail "https://api.shippable.com/$url_path" "$@"
|
||||
|
@ -71,4 +71,4 @@ export TOKEN="$SPOTIFY_ACCESS_TOKEN"
|
||||
|
||||
# the Spotify API is very unreliable and often gets 502 errors
|
||||
# seen 20 x HTTP 500 errors from the API in a row :-/
|
||||
MAX_RETRIES="30" retry 300 "$srcdir/curl_auth.sh" -sSL --fail "$url_base/$url_path" "$@"
|
||||
MAX_RETRIES="30" retry 300 "$srcdir/../bin/curl_auth.sh" -sSL --fail "$url_base/$url_path" "$@"
|
||||
|
@ -97,7 +97,7 @@ scope="$(tr '\n' '+' <<< "$scope" | sed 's/^+//; s/+*$//')"
|
||||
# https://developer.spotify.com/documentation/general/guides/authorization-guide/#client-credentials-flow
|
||||
#
|
||||
if is_blank "${SPOTIFY_PRIVATE:-}"; then
|
||||
output="$(NO_TOKEN_AUTH=1 USERNAME="$SPOTIFY_ID" PASSWORD="$SPOTIFY_SECRET" "$srcdir/curl_auth.sh" -sSL -X 'POST' -d 'grant_type=client_credentials' -d "scope=$scope" https://accounts.spotify.com/api/token "$@")"
|
||||
output="$(NO_TOKEN_AUTH=1 USERNAME="$SPOTIFY_ID" PASSWORD="$SPOTIFY_SECRET" "$srcdir/../bin/curl_auth.sh" -sSL -X 'POST' -d 'grant_type=client_credentials' -d "scope=$scope" https://accounts.spotify.com/api/token "$@")"
|
||||
fi
|
||||
|
||||
# ============================================================================ #
|
||||
@ -172,7 +172,7 @@ EOF
|
||||
#curl -H "Authorization: Basic $basic_auth_token" -d grant_type=authorization_code -d code="$code" -d redirect_uri="$redirect_uri" https://accounts.spotify.com/api/token
|
||||
# curl_auth.sh prevents auth token appearing in process list
|
||||
local output
|
||||
output="$(NO_TOKEN_AUTH=1 USERNAME="$SPOTIFY_ID" PASSWORD="$SPOTIFY_SECRET" "$srcdir/curl_auth.sh" https://accounts.spotify.com/api/token -sSL -d grant_type=authorization_code -d code="$code" -d redirect_uri="$redirect_uri")"
|
||||
output="$(NO_TOKEN_AUTH=1 USERNAME="$SPOTIFY_ID" PASSWORD="$SPOTIFY_SECRET" "$srcdir/../bin/curl_auth.sh" https://accounts.spotify.com/api/token -sSL -d grant_type=authorization_code -d code="$code" -d redirect_uri="$redirect_uri")"
|
||||
|
||||
# output everything that isn't the token to stderr as it's almost certainly user information or errors and we don't want that to be captured by client scripts
|
||||
} >&2
|
||||
|
@ -225,7 +225,7 @@ if [ -n "${TEAMCITY_SUPERUSER_TOKEN:-}" ]; then
|
||||
# XXX: superuser token can only be used with blank user which cannot be used with curl_auth.sh
|
||||
curl -u ":$TEAMCITY_SUPERUSER_TOKEN" "$url_base/$url_path" "${CURL_OPTS[@]}" "$@"
|
||||
else
|
||||
"$srcdir/curl_auth.sh" "$url_base/$url_path" "${CURL_OPTS[@]}" "$@"
|
||||
"$srcdir/../bin/curl_auth.sh" "$url_base/$url_path" "${CURL_OPTS[@]}" "$@"
|
||||
fi
|
||||
#chmod 0600 "$cookie_jar"
|
||||
|
||||
|
@ -82,7 +82,7 @@ teamcity_curl_auth(){
|
||||
# XXX: superuser token can only be used with blank user which cannot be used with curl_auth.sh
|
||||
curl -u ":$TEAMCITY_SUPERUSER_TOKEN" "$url_base/$url_path" "${curl_opts[@]}" "$@"
|
||||
else
|
||||
"$srcdir/curl_auth.sh" "$url_base/$url_path" "${curl_opts[@]}" "$@"
|
||||
"$srcdir/../bin/curl_auth.sh" "$url_base/$url_path" "${curl_opts[@]}" "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -197,7 +197,7 @@ if [[ "$url_path" =~ [\{:]?user(_?id)?\}? ]]; then
|
||||
url_path="${url_path//\{userid\}/$TERRAFORM_USER_ID}"
|
||||
url_path="${url_path//\{user_id\}/$TERRAFORM_USER_ID}"
|
||||
else
|
||||
user_id="$("$srcdir/curl_auth.sh" "${CURL_OPTS[@]}" "$url_base/account/details" | jq -r .data.id)"
|
||||
user_id="$("$srcdir/../bin/curl_auth.sh" "${CURL_OPTS[@]}" "$url_base/account/details" | jq -r .data.id)"
|
||||
url_path="${url_path//:user_id/$user_id}"
|
||||
url_path="${url_path//:userid/$user_id}"
|
||||
url_path="${url_path//:user/$user_id}"
|
||||
@ -207,4 +207,4 @@ if [[ "$url_path" =~ [\{:]?user(_?id)?\}? ]]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
"$srcdir/curl_auth.sh" "$url_base/$url_path" "${CURL_OPTS[@]}" "$@"
|
||||
"$srcdir/../bin/curl_auth.sh" "$url_base/$url_path" "${CURL_OPTS[@]}" "$@"
|
||||
|
@ -135,4 +135,4 @@ url_path="${url_path##/}"
|
||||
|
||||
export CURL_AUTH_HEADER="Authorization: token"
|
||||
|
||||
"$srcdir/curl_auth.sh" "$url_base/$url_path" -H 'Travis-API-Version: 3' "${CURL_OPTS[@]}" "$@"
|
||||
"$srcdir/../bin/curl_auth.sh" "$url_base/$url_path" -H 'Travis-API-Version: 3' "${CURL_OPTS[@]}" "$@"
|
||||
|
Loading…
x
Reference in New Issue
Block a user