http-request-plugin
http-request-plugin copied to clipboard
Fix Proxy requiring Authentication usage
Hello there,
This PR intends to fix proxy requiring authentication usage and wrong documentation about it.
I could not find a way to use proxy requiring an authentication with preemptive authentication enabled, even in a simple out-of-this-PR context.
Java is not my main language so there may be a more elegant / efficient way to fix this issue.
Kind regards,
Tested against both authenticated and unauthenticaded Squid
mysquid.conf
auth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/passwords
auth_param basic realm Squid proxy-caching web server
auth_param basic credentialsttl 24 hours
auth_param basic casesensitive off
acl authenticated proxy_auth REQUIRED
http_access allow authenticated
http_access deny all
dns_v4_first on
forwarded_for delete
via off
http_port 3128
Running the Squids
docker run -e TZ=UTC -p 3129:3128 ubuntu/squid:5.2-22.04_beta
docker run -e TZ=UTC -v /path/to/mysquid.conf:/etc/squid/squid.conf -v /path/to/mysquidpasswords:/etc/squid/passwords -p 3128:3128 ubuntu/squid:5.2-22.04_beta
Tests
pipeline {
agent any
stages {
stage('Test') {
steps {
// No proxy
httpRequest url: 'https://httpbin.org/'
httpRequest url: 'https://httpbin.org/basic-auth/user/passwd', authentication: 'httpbin'
// Proxy without authentication
httpRequest url: 'https://httpbin.org/', httpProxy: 'http://127.0.0.1:3129'
httpRequest url: 'https://httpbin.org/basic-auth/user/passwd', authentication: 'httpbin', httpProxy: 'http://127.0.0.1:3129'
// Proxy with authentication
httpRequest url: 'https://httpbin.org/', httpProxy: 'http://127.0.0.1:3128', proxyAuthentication: 'proxy-auth'
httpRequest url: 'https://httpbin.org/basic-auth/user/passwd', authentication: 'httpbin', httpProxy: 'http://127.0.0.1:3128', proxyAuthentication: 'proxy-auth'
}
}
}
}