Search code examples
authenticationsquid

How to configure squid to pass client ip to authenticate program?


I want to use my own authenticate program in Squid like following.

auth_param basic program /usr/bin/python python_script_location
auth_param basic children 20
auth_param basic realm Username and password
auth_param basic credentialsttl 5 hours

But by default the squid only pass the username and password to python_script_location(See example here http://gofedora.com/how-to-write-custom-basic-authentication-plugin-squid-python/).

Is it possible to pass some built-in values as extra arguments? e.g. the client IP, the IP of squid server(My has have multiple outgoing IP addresses, i want to know which IP the client is accessing)


Solution

  • It seems Squid 3.5 will add this new feature: key_extras for auth_param.

    http://www.squid-cache.org/Doc/config/auth_param/

    http://devel.squid-cache.org/customlog/logformat.html

    %la : Local IP address where the request was accepted

    Then we can add the "Local IP address" to the authenticate program command line like following: auth_param digest key_extras "%la"