Forum Discussion
Application access basic authentication using irule
Hi Kevin / nitass
It worked.. thanks for the guidance and quick response.
But after inserting the iRule, we faced another issue. We were using below iRule for some pool mapping. But after introducing the new rule for authentication, the application screen is not displaying properly. Following is the existing rule.
when HTTP_REQUEST {
------------Attachement related modification------------------------------------event enable all if {[HTTP::uri] contains "OpenElement"} { event HTTP_RESPONSE disable event HTTP_RESPONSE_DATA disable }
------------Attachement related modification------------------------------------ if{[HTTP::header exists "Accept-Encoding"]} { HTTP::header remove "Accept-Encoding" }if {not([HTTP::cookie exists MTAG]) and ([HTTP::cookie exists UTAG]) and ([HTTP::uri] contains "[lindex [split [HTTP::cookie UTAG] ":"] 1].nsf")} {
set mlock [lindex [split [HTTP::cookie UTAG] ":"] 0]log local0. "transferring to the mailbox pool"
} if {([string tolower [HTTP::host]] equals "webmail.dhanbank.com") and ([HTTP::path] equals "/")} { pool REG-POOL log local0. "======START=====" } elseif {[string tolower [HTTP::path]] starts_with "/dlbmail"} { log local0. "Explicit flow PRE-MOD: [HTTP::host]/[HTTP::uri]" set mlock [lindex [split [HTTP::cookie UTAG] ":"] 0] regexp -nocase {/(dlbmail((1|2)(cl)?))/(.*)} [HTTP::uri] match a g h c b log local0. " A G H C B = $a $g $h $c $b " HTTP::header replace "Host" $a.dhanbank.com HTTP::uri /$b log local0. "Explicit flow POST-MOD: [HTTP::host]/[HTTP::uri]" pool DLBMAIL0$g-POOL } elseif {[string tolower [HTTP::host]] equals "webmailarch.dhanbank.com"} { log local0. "ARCHIVE Access PRE-MOD: [HTTP::host]/[HTTP::uri]" set mlock "DLBARCHIVE"
regexp -nocase {/(dlbarchive)/(.*)} [HTTP::uri] match e f log local0. " E F = $e $f"HTTP::header replace "Host" dlbarchive.dhanbank.com
HTTP::uri /$f
log local0. "ARCHIVE Access POST-MOD: [HTTP::host]/[HTTP::uri]"
pool DLBARCHIVE-POOL
} elseif {[HTTP::cookie exists MTAG]} { log local0. "implicit flow PRE-MOD: [HTTP::host]/[HTTP::uri]" if {[HTTP::cookie MTAG] equals "DLBARCHIVE"} { switch [HTTP::host] { "webmailarch.dhanbank.com" { HTTP::header replace "Host" webmailarch.dhanbank.com log local0. "implicit flow POST-MOD mail-ARCHIVE: [HTTP::host]/[HTTP::uri]" pool DLBARCHIVE-POOL } "webmail.dhanbank.com" { set mlock [lindex [split [HTTP::cookie UTAG] ":"] 0] HTTP::header replace "Host" $mlock.dhanbank.com log local0. "implicit flow POST-MOD mail: [HTTP::host]/[HTTP::uri]" pool $mlock-POOL } } } if {[HTTP::cookie MTAG] starts_with "DLBMAIL"} { switch [HTTP::host] { "webmailarch.dhanbank.com" { set mlock DLBARCHIVE HTTP::header replace "Host" webmailarch.dhanbank.com log local0. "implicit flow POST-MOD mail-ARCHIVE: [HTTP::host]/[HTTP::uri]" pool DLBARCHIVE-POOL } "webmail.dhanbank.com" { scan [HTTP::cookie MTAG] DLBMAIL%s a set a [string trimleft $a 0] HTTP::header replace "Host" dlbmail$a.dhanbank.com log local0. "implicit flow POST-MOD mail: [HTTP::host]/[HTTP::uri]" pool [HTTP::cookie MTAG]-POOL } } } } elseif {[string tolower [HTTP::path]] contains "dlbhomepage.nsf"} { set mlock 1 log local0. "Retrieving info from DLB Home page" pool REG-POOL } else { log local0. "original flow : [HTTP::host]/[HTTP::uri]" pool REG-POOL } }
when HTTP_RESPONSE { if {[HTTP::header exists "Location"]} {
if {[HTTP::header "Location"] starts_with "http://webmail.dhanbank.com"} { return }if {[HTTP::header "Location"] starts_with "http://dlbmail"} {
log local0. "Backend server redirection on DLBMAIL pool = [HTTP::header "Location"]"
regsub -nocase {http://(dlbmail(1|2)).dhanbank.com/(.*)} [HTTP::header "Location"] {http://webmail.dhanbank.com/\1/\2}
regexp -nocase {http://(dlbmail(1|2)(cl)?)\.dhanbank\.com/(.*)} [HTTP::header "Location"] match l m o n
HTTP::header replace "Location" "http://webmail.dhanbank.com/$l/$n"
log local0. "Backend server redirection on DLBMAIL pool- POST MOD = [HTTP::header "Location"]"
}
if{([info exists a]) and ( $a ne "")} {
regsub -nocase {^/(?!dlbmail(01|02))(.*)} [HTTP::header "Location"] {/$a/\1}
}
}
if {[HTTP::header "Content-Type"] starts_with "text/"} {
set cl [HTTP::header "Content-Length"]
if {not($cl equals "")} {
HTTP::collect $cl
}
}
}
when HTTP_RESPONSE_DATA { if {[info exists mlock]} { if {$mlock == 1} { regexp -nocase {http://(dlbmail((1|2)(cl)?)).dhanbank.com/([^"]*)} [HTTP::payload] match ml nuc nu uc uri log local0. "Match detected URI = $match" log local0. "Match detected ML= $ml" log local0. "Match detected NU= $nu" log local0. "Match detected URI= $uri" set usr [string range $uri [expr [string last / $uri] +1] [expr [string last "nsf" $uri] -2]]
regsub -nocase -all {http://(dlbmail(1|2)).dhanbank.com/} [HTTP::payload] {http://webmail.dhanbank.com/\1/} set mlock 0HTTP::cookie insert name UTAG value "[string toupper DLBMAIL0$nuc]:$usr" domain .dhanbank.com path "/"
log local0. "Retreival complete and cookie UTAG inserted =[string toupper DLBMAIL0$nuc]:$usr"
}
if {$mlock matches_glob "DLB*"} {
HTTP::cookie insert name MTAG value "$mlock" domain .dhanbank.com path "/"
log local0. "Passing the HANDLE for IMPLICIT Pool selection MTAG = $mlock"
}
}
set pl [HTTP::payload length]
regsub -nocase -all {http://(dlbmail((1|2)(cl)?))\.dhanbank\.com/} [HTTP::payload] {http://webmail.dhanbank.com/\1/} nplw
regsub -nocase -all {dlbarchive\.dhanbank\.com} $nplw {webmailarch.dhanbank.com} nplw
HTTP::payload replace 0 $pl $nplw
HTTP::release
}
Following is the screen shot
Could you please guide me on this too..
Thanks
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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