This is perhaps the easiest authentication helper to configure in Squid, but also the most insecure. The biggest problem with Basic is it transmits username and password in clear text, hence very susceptible to network sniffing or man in the middle type attacks. The only reason I’m writing about it is it’s a valid authentication mechanism in some limited circumstances. Secondly I want to show you how authentication has evolved over the years.
Ultimately you want to Kerberos authentication with your Squid proxy, but before we got there we had basic. And here is how to configure it;
First thing that requires out magic touch is Squid’s configuration. Locate and navigate squid.conf
The first section you’ll come across is for configuring authentication. It’s called;
# OPTIONS FOR AUTHENTICATION
You’ll notice there are many comments in this section explaining all the different options. But let’s jump ahead to what we came here for…
Locate the following lines; note they will be commented out. Enable them by removing the hash character ‘#’
auth_param basic program
auth_param basic children 5
auth_param basic realm Squid proxy-caching web server
auth_param basic credentialsttl 2 hours
If you haven’t noticed already the first parameter auth_param basic program configures the location of an external helper program. This helper program is named pam_auth and on an Ubuntu system is located in the /usr/lib/squid directory. In fact all authentication helpers are located in this directory.
Therefore our first line should look like this;
auth_param basic program /usr/lib/squid/pam_auth
Next we have the children parameter. This configures the specified number of processes to handle incoming authentication reuqests. In above example pam_auth will spawn 5 separate processes to handle all authentication requests. Anywhere between 5-10 helper processes is a good starting point. If Squid runs into trouble, it will tell you in /var/log/squid/cache.log , monitor this file closely.
Then we have a realm parameter. This is a string which is presented to the user when the authentication prompt appears on screen. With Basic authentication this is an arbitrary string value. You can use anything, like; “Welcome to my really cool Proxy Server. Enter your Username and Password”
Lastly we have the credentialsttl parameter which dictates how long Squid caches authentication requests internally. Keep in mind a small value increases Squid load, while a larger value will reduce it. You may need to play with this if you notice your Squid box is really busy.
The last piece to this puzzle is enabling Squid’s authentication ACL. This includes changing two additional parameters. ( ACL & HTTP_ACCESS).
The default ACL bases access or no access on client subnets. ACL LOCALNET SRC 192.168.0.0/24 is an example of one.
To enable authentication, comment out above default ACL and replace with this;
acl authenticatedusers proxy_auth REQUIRED
Lastly enable above access list, named authenticatedusers
http_access allow authenticatedusers
That’s it. Restart Squid service and you should now be prompted for user name and password. You session will be authenticated until you close your browser.