Forum Discussion
iRule - Authorization Bearer / Basic
- Jan 10, 2023
HTTP_REQUEST is in the request which goes to the backend server, HTTP_RESPONSE is for the response from the server to the client. To correct your iRule:
when HTTP_REQUEST { if { [HTTP::header Authorization] contains "Basic" } { log local0.debug "Basic: [HTTP::header Authorization]" HTTP::insert X-HUB-BASIC "[HTTP::header Authorization]" } elseif { [HTTP::header Authorization] contains "Bearer" } { log local0.debug "Bearer: [HTTP::header Authorization]" HTTP::insert X-HUB-Bearer "[HTTP::header Authorization]" } }
Hi! Thanks for the reply!
That insert wouldn't be inside the HTTP_REQUEST, would it?
- PeteWhiteJan 10, 2023Employee
yes, it would. Presumably you want to insert the HTTP header into the request which goes to the backend server.
- AndreiaJan 10, 2023Cirrus
Yes, I want to insert the header inside the request which goes to the backend server. Actually I don't know if it would be in HTTP_RESPONSE or HTTP_RESPONSE_RELEASE.
Would it be something like this?
when HTTP_RESPONSE {
if { [HTTP::header Authorization] contains "Basic" } {
log local0.debug "Basic: [HTTP::header Authorization]"
HTTP::insert X-HUB-BASIC "[HTTP::header Authorization]"
} elseif { [HTTP::header Authorization] contains "Bearer" } {
log local0.debug "Bearer: [HTTP::header Authorization]"
HTTP::insert X-HUB-Bearer "[HTTP::header Authorization]"
}
}- PeteWhiteJan 10, 2023Employee
HTTP_REQUEST is in the request which goes to the backend server, HTTP_RESPONSE is for the response from the server to the client. To correct your iRule:
when HTTP_REQUEST { if { [HTTP::header Authorization] contains "Basic" } { log local0.debug "Basic: [HTTP::header Authorization]" HTTP::insert X-HUB-BASIC "[HTTP::header Authorization]" } elseif { [HTTP::header Authorization] contains "Bearer" } { log local0.debug "Bearer: [HTTP::header Authorization]" HTTP::insert X-HUB-Bearer "[HTTP::header Authorization]" } }
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