Hi.
I´m involved to develop an irule in order to get LTM worked as a basic proxy server for vservers where irule was configured, asking for a username password in the same way you were being authenticated by a proxy server. We are going to use only one username/password, so it is not needed to pass these credentials to a external authentication system and they could be codified into irule code.
Basically I´m trying to verify if Proxy-Authorization header comes into HTTP request. If it is not into HTTP request, a 407 or 401 error is sended to client in order to ask for authentication. If Proxy-Authorization header is present, I try to get string after “Basic”, decode it in Base64 to get “username:password” string, and finally obtain username and password into diferent variables to be compared with my username and password. If comparation is succesful, user is allowed to navigate into the web service. If not, it´s redirected to a sorry page.
Well, it doesn´t work. I don´t know the reason, but I don´t obtain traces into /var/log/ltm file, and browser ask me continously for username and password, even when I´m writing the right username/password. What am I doing wrong? Could you tell me what I have to change or modify in my irule to achieve my objective?
when HTTP_REQUEST {
if { not ([HTTP::header exists "Proxy-Authorization"]) } {
HTTP::respond 407 Proxy-Authenticate "BASIC realm=\"PROXY X\""
} else {
set proxyauth [lindex [split [HTTP::header value "Proxy-Authorization"] " "] 1]
set username [lindex [split [b64decode $proxyauth] ":"] 0 ]
set password [lindex [split [b64decode $proxyauth] ":"] 1 ]
log local0. "PROXY-AUTHORIZATION HEADER IS $proxyauth, USERNAME IS $username AND PASSWORD IS $password"
if {not ($username equals "useraaa" and $password equals "aaauser") } {
HTTP::redirect "http://sorrypage.aaaaa.com"
}
}
}