Forum Discussion
External Posting to APM with dynamic URL
- Sep 16, 2019
Hi Sajid,
In fact we have to decoded payload using "[URI::decode [HTTP::payload]]"
Payload:
is=txtURL=https%3A%2F%2Ftrnapp01.example.com%3A443%2Fappmanager%2Fabc&username=user123&password=%40password123
decoded raw:
is=txtURL=https://trnapp01.example.com:443/appmanager/abc&username=user123&password=@password123
now we have to set the right regex in your irule:
when HTTP_REQUEST_DATA { set payload [URI::decode [HTTP::payload]] set username [URI::query "?[HTTP::payload]" username] set password [URI::query [URI::decode "?[HTTP::payload]"] password] regexp {^.*txtURL=([^&]+).*$} $payload -> gotURL log local0. "Username: $username - password : $password - gotURL: $gotURL" HTTP::release }
keep me in touch.
regards
Hi Sajid,
I work as follows. when I write an Irule I do it at the simplest I validate that it works. and afterwards I optimize it.
In order to retrieve URL, I used “regexp”, Because I noticed that you post a form auth. So that’s mean that I have to retrieve information needed in Post Data.
How “regexp” work:
So first of you have to retrieve all payload (Post Data):
set payload [HTTP::payload]
In this payload you have to extract URL or other information (In our case URL)
So we can use “regexp” function, it allow us to retrieve a specific string of characters
regexp {^.*name=\"txtURL\" value=\"([^\"]+).*$} $payload -> posturl
^ and $: match the begin/end of the payload
.*: matches any character
() : between parentheses is what we want to recover and put in the variable “posturl”
([^\"]+): means recover all the characters until “
$payload: payload where my regex applies
\: Since “ is used in the regular expressions I am obliged to the despecialized like this \”
Hope it’s clear.
Form more info check this:
http://www.tcl.tk/man/tcl8.4/TclCmd/regexp.htm
so if you have an Control service you can modify your Irule adding this line:
set payload [HTTP::payload]
regexp {^.*name=\"txtURL\" value=\"([^\"]+).*$} $payload -> posturl
regards
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