feat: Support for proxy authentication (#20929)
Appsmith supports running with a HTTP proxy, that can be configured with `HTTP_PROXY` or `HTTPS_PROXY` env variables. Like this: ```sh HTTP_PROXY=http://myproxy:8080 HTTPS_PROXY=http://myproxy:8443 ``` However, this proxy support didn't support authentication. This PR implements that. Now, proxy with authentication can be configured like this: ```sh HTTP_PROXY=http://user:password@myproxy:8080 HTTPS_PROXY=http://user:password@myproxy:8080 ``` This is not syntax or standards invented by Appsmith. This is the standard way proxy is usually configured. Fixes #16330 🍰
This commit is contained in:
parent
b567eed321
commit
5e35c1fdae
|
|
@ -8,13 +8,38 @@ set -o noglob
|
|||
declare -a proxy_args
|
||||
proxy_configured=0
|
||||
|
||||
if [[ ${HTTP_PROXY-} =~ ^http://(.*):([[:digit:]]*)/?$ && ${BASH_REMATCH[2]} != 0 ]]; then
|
||||
proxy_args+=(-Dhttp.proxyHost="${BASH_REMATCH[1]}" -Dhttp.proxyPort="${BASH_REMATCH[2]}")
|
||||
match-proxy-url() {
|
||||
# Examples:
|
||||
# http://proxy.example.com:8080/
|
||||
# http://user:pass@proxyhost:123
|
||||
# http://proxyhost:123
|
||||
[[ $1 =~ ^http://(([^@:]*):([^@]*)?@)?([^@:]*):([0-9]+)/?$ ]]
|
||||
proxy_user="${BASH_REMATCH[2]-}"
|
||||
proxy_pass="${BASH_REMATCH[3]-}"
|
||||
proxy_host="${BASH_REMATCH[4]-}"
|
||||
proxy_port="${BASH_REMATCH[5]-}"
|
||||
[[ -n $proxy_host ]]
|
||||
}
|
||||
|
||||
if match-proxy-url "${HTTP_PROXY-}"; then
|
||||
proxy_args+=(-Dhttp.proxyHost="$proxy_host" -Dhttp.proxyPort="$proxy_port")
|
||||
if [[ -n $proxy_user ]]; then
|
||||
proxy_args+=(-Dhttp.proxyUser="$proxy_user")
|
||||
fi
|
||||
if [[ -n $proxy_pass ]]; then
|
||||
proxy_args+=(-Dhttp.proxyPassword="$proxy_pass")
|
||||
fi
|
||||
proxy_configured=1
|
||||
fi
|
||||
|
||||
if [[ ${HTTPS_PROXY-} =~ ^https?://(.*):([[:digit:]]*)/?$ && ${BASH_REMATCH[2]} != 0 ]]; then
|
||||
proxy_args+=(-Dhttps.proxyHost="${BASH_REMATCH[1]}" -Dhttps.proxyPort="${BASH_REMATCH[2]}")
|
||||
if match-proxy-url "${HTTPS_PROXY-}"; then
|
||||
proxy_args+=(-Dhttps.proxyHost="$proxy_host" -Dhttps.proxyPort="$proxy_port")
|
||||
if [[ -n $proxy_user ]]; then
|
||||
proxy_args+=(-Dhttps.proxyUser="$proxy_user")
|
||||
fi
|
||||
if [[ -n $proxy_pass ]]; then
|
||||
proxy_args+=(-Dhttps.proxyPassword="$proxy_pass")
|
||||
fi
|
||||
proxy_configured=1
|
||||
fi
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user