Forum Discussion
how to insert Basic Authorization into http header while redirecting
Hi ,
i am trying to insert a common user id and pwd intp "Basic Authorization" of http header and redirect the same to new url. tired HTTP::header insert Authorization cmd but it isnt working as expected. plese help. Thanks.
4 Replies
- nitass
Employee
can you post the irule? and what does "not working" mean indeed?? - VijayG_122615
Nimbostratus
trying to redirect to new SAP PI Adapter url with Authorization .
when HTTP_REQUEST {
Debug off (0) , On (1)
set debug 1
SAP PI 7.3 standard RNIF Adapter uri
set pirnifuri "/MessagingSystem/receive/RNIFAdapter/RNIF"
If Inbound host matches the b2b hosts then redirect
if {[matchclass [http_host] equals pidxb2bhosts] and [HTTP::uri] equals "/RosettaNet" } {
inbound host and uri
if { $debug>=1 } {log local0. "PIDX:Inbound host and uri: [HTTP::host][HTTP::uri]"}
dev Redirect
if { [HTTP::host] starts_with "b2b0031" and [HTTP::uri] equals "/RosettaNet" } {
HTTP::header insert Authorization "Basic WElfQVgwMDFEVjAwOmxpdmU0ZnJlZTE="
set devsappihost [ class match -value dev equals sappihosts]
if { $debug>=1 } {log local0. "Redirecting to dev SAP PI"}
HTTP::redirect "http://$devsappihost$pirnifuri"
}
}
} - nitass
Employee
i understand HTTP::header insert will insert header to request toward pool member (server) but HTTP::redirect sends response back to client telling where the new location is. i mean they work in opposite direction.
- Kevin_Stewart
Employee
Basic authentication is a base64-encoding of the username and password:
ex.
demoAdmin:demoAdmin = ZGVtb0FkbWluOmRlbW9BZG1pbg==
So to set this in a header, just do this:set basicdata [b64encode "demoAdmin:demoAdmin"] HTTP::header insert Authorization "Basic $basicdata"
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
