Forum Discussion
jack_10574
Nimbostratus
Jul 12, 2014redirection require wth forward to pool
Hi All
i have a requirement , base on the below irule , it will forward users forward to the test_pool after users authentication successful.
Due to i require another action from irule which is...
Kevin_Stewart
Employee
Jul 14, 2014Try this:
when RULE_INIT {
set static::auth_debug 1
}
when HTTP_REQUEST {
if { $static::auth_debug } { log local0. "Request URI = [HTTP::uri]." }
if { [string tolower [HTTP::uri]] equals "/user" } {
HTTP::redirect "http://[HTTP::host]/user/resources.php"
return
} elseif { [HTTP::username] eq "" or [HTTP::password] eq "" } {
Grab username and password from authorization header and compare
if { $static::auth_debug } { log local0. "No username and password in Authorization header or Auth header missing." }
} else {
Grab the authorization header and convert to username and password
if { $static::auth_debug } { log local0. "Username = [HTTP::username] password = [HTTP::password]" }
Next look in the datagroup called LocalUsers for the user. The value is a hex MD5password.Compare the value in the datagroup to the value of HTTP::password to determine if this is valid.
set password [class lookup "[HTTP::username]" LocalUsers]
if { $password eq "" } {
if { $static::auth_debug ==1 } { log local0. "Auth failed for user [HTTP::username] \ and the value in the datagroup was [class lookup [HTTP::username] LocalUsers] "}
} else {
how have action with when user key in www/test/com/user redirect it to https://www.test.com/user/resources.html before it forward to test_pool ?
binary scan [ md5 [HTTP::password]] H* hexhash
if { $static::auth_debug } { log local0. "password MD5 = $hexhash" }
if { $password eq $hexhash } {
pool test_pool
if { $static::auth_debug } { log local0. "Auth succeeded for user [HTTP::username] and the value in the datagroup was [class lookup [HTTP::username] LocalUsers] "}
Exit this event for this iRule to prevent sending a 401 below
return
}
}
}
If we are still in the iRule the auth attempt failed
HTTP::respond 401 content "Error:Authentication Failure" WWW-Authenticate "Basic realm=\"local.loc\""
}
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects