Forum Discussion
Gerald_Meese
Cirrus
Jan 11, 2018iRule - Combine HTTP::redirect and Basic Auth in HTTP header
Hello,
I'm trying to adapt an iRule that would combine the redirect to a specific URI on the backend server, while sending Basic Authentication in an HTTP header to that backend server :
when HTTP_REQUEST {
set logindata [b64encode "username:password"]
HTTP::redirect "/internalURI"
HTTP::header replace Authorization "Basic $logindata"
}
Both commands work well separately, and I believe I understand where the problem is (the redirect sends a new path to the client while the HTTP header is added into the traffic to the backend) but I can't figure out how to get this to work.
Thanks in advance for your help !
Kind regards,
Gerald
- Stanislas_Piro2
Cumulonimbus
You can try this code:
when HTTP_REQUEST { if {[HTTP::uri] starts_with "/internalURI"} { set logindata [b64encode "username:password"] HTTP::header replace Authorization "Basic $logindata" } else { HTTP::redirect "/internalURI" } }
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