Secure User Authentication in Squid – A Comprehensive Guide

authenticationkerberosldapSecuritysquid

once upon a time, there was a beautiful warm virtual-jungle in south america, and a squid server lived there. here is an perceptual image of the network:

                 <the Internet>
                        | 
                        | 
           A            |          B
Users <---------> [squid-Server] <---> [LDAP-Server] 

When the Users request access to the Internet, squid ask their name and passport, authenticate them by LDAP and if ldap approved them, then he granted them.

Everyone was happy until some sniffers stole passport in path between users and squid [path A]. This disaster happened because squid used Basic-Authentication method.

The people of jungle gathered to solve the problem. Some bunnies offered using NTLM of method. Snakes prefered Digest-Authentication while Kerberos recommended by trees.

After all, many solution offered by people of jungle and all was confused!
The Lion decided to end the situation. He shouted the rules for solutions:

  • Shall the solution be secure!
  • Shall the solution work for most of browsers and softwares (e.g. download softwares)
  • Shall the solution be simple and do not need other huge subsystem (like Samba server)
  • Shall not the method depend on special domain. (e.g. Active Directory)

Then, a very resonable-comprehensive-clever solution offered by a monkey, making him the new king of the jungle!

can you guess what was the solution?

Tip:
The path between squid and LDAP is protected by the lion, so the solution have not to secure it.

Note: sorry if the story is boring and messy, but most of it is real! =)

               /~\/~\/~\
            /\~/~\/~\/~\/~\
          ((/~\/~\/~\/~\/~\))
        (/~\/~\/~\/~\/~\/~\/~\)
       (////     ~   ~     \\\\)
       (\\\\(   (0) (0)   )////)
       (\\\\(   __\-/__   )////)
        (\\\(     /-\     )///)
         (\\\(  (""""")  )///)
          (\\\(  \^^^/  )///)
           (\\\(       )///)
             (\/~\/~\/~\/)         **
               (\/~\/~\/)        *####*
                |     |           ****
               /| | | |\            \\
            _/  | | | | \_ _________//   Thanks!
           (,,)(,,)_(,,)(,,)--------'

Update:

Massimo explained that the authenticating method between Userssquid and squidLDAP does not have to be same. we can use arbitary method to get authentication information from users and arbitary method to authenticated gathered data.

But there is a problem: the input/output of all types of authenticators is not same. For example:

  • a Basic authenticator should read "username password" pair in a line and reply a OK if user-pass is correct or ERR
  • a Digest authenticator should read a username:realm and reply a hex-encoded of HA(A1) or an ERR.

Althought there is no direct relationship between client-squid method and squid-ldap method, the gathered data from client must be compatible with method used in squid-ldap part.
Therefore, if we change authenticating method in users-side, we maybe should change our authenticator too.

So the problem simplifies to:

  1. In first level, i (the monkey!) am looking for a good authentication method in user-side. Which method do you recommend which is secure and supported by most browsers? i am in confused between NTLM, Kerberos and Digest.

  2. Where i can find an authenticator which supports credentials information of selected method and authenticates through LDAP.

Best Answer

Kerberos is not an option for HTTP authentication. NTLM is not well supported in any browser other than IE. Basic is not secure unless you put it behind HTTPS which AFAIK squid cannot do. So you are left with Digest.