Forum Discussion

praque_135655's avatar
praque_135655
Icon for Nimbostratus rankNimbostratus
Nov 06, 2013

Using irule get the name and value from HTML body

Hi All,

 

I want to retrieve the following name and value from HTTP::Payload.

 

Please advise how to retrieve the values

 

 

7 Replies

  • input type="hidden" name="SAMLResponse" value="PFJlc3BvbnNlIERlc3RpbmF0aW9uPSJodHRwOi8vdXNjbHNwY2ltMDIxLmFpcnNlcnZpY2VzLmVk">

     

    • What_Lies_Bene1's avatar
      What_Lies_Bene1
      Icon for Cirrostratus rankCirrostratus
      Thanks. OK, it's possible with the scan command but I'm afraid I really can't work it out right now.
  • Do you need to capture this in a request or response context? Is the data coming from the server as the SAMLResponse form destined for the client, or coming from the client as the resulting form POST?

     

  • Praque, first thanks for the images. Great idea. Unfortunately, however, they're too small to read. Can you make them bigger?

     

    Also, please understand the context of my last question. The IdP will send a pre-filled form to the client with a little piece of JavaScript that will auto-post the form. That payload will contain the SAMLResponse value. The client will then POST that data to the SP. Again, the SAMLResponse value will be in the payload. So the question is, from which direction do you need to collect it? I stress this because the events and syntax will be different depending on your answer.

     

  • Hi Kevin,

     

    Please advice on the above, i need to grap the saml token and post it to sp side.

     

    when CLIENT_ACCEPTED { Get the defined pool for this VIP set default_pool [LB::server pool]

     

     Set an initial lookup flag
    set gotpath 1

    }

     

    when HTTP_REQUEST {

     

      log local0. "HTTP Method: [HTTP::method]"
    
      set d2 [getfield [HTTP::host] "." 2]
      set d3 [getfield [HTTP::host] "." 3]
      set d4 [getfield [HTTP::host] "." 4]
      set d5 [getfield [HTTP::host] "." 5]
      set d6 [getfield [HTTP::host] "." 6]
      set d7 [getfield [HTTP::host] "." 7]
      set domain ""
    
      foreach part "$d2 $d3 $d4 $d5 $d6 $d7" {
         set domain [format "%s.%s" $domain $part]
      }
    
      set domain [domain [HTTP::host] 6]
         log local0. "domain$domain"
    
        On first request (lookup flag exists) perform lookup
     if { $gotpath == 1 } {
    
         Save the original request
          set request [HTTP::request]
    
         Change URI for sideband lookup
          HTTP::uri "/iam/code.asp"
    
         Change pool to point to sideband web service
          pool Rachel_Test_208
    
      }   
    
     if { $gotpath == 0 } {
          HTTP::cookie insert name "SMSESSION" value $smsession path "/" domain $domain
          log local0. "gotpath0 HTTP Method: [HTTP::method]"
    
          HTTP::uri "/affwebservices/public/saml2sso?SPID=service_provider&ProtocolBinding=urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
     }

    }

     

    when HTTP_RESPONSE { If response from web service if { [HTTP::cookie exists "SMSESSION"] } { set smsession "[HTTP::cookie value SMSESSION]" log local0. "smsession$smsession" set gotpath 0 } if {[HTTP::header "Content-Length"] ne "" && [HTTP::header "Content-Length"] <= 6048576}{ set content_length [HTTP::header "Content-Length"] } else { set content_length 6048576 } Check if $content_length is not set to 0 if { $content_length > 0} { log local0. "content_length$content_length" HTTP::collect $content_length } log local0. "payload[HTTP::payload]" }

     

    when HTTP_RESPONSE_DATA { Full payload should be available here in [HTTP::payload] log local0. "payload[HTTP::payload]" log local0. "HTTP Method: [HTTP::method]"

     

    if { [HTTP::payload] contains "SAMLResponse" }{
       set requestpayload [HTTP::payload]
       log local0. "requestpayload444$requestpayload"
       log "substring value=[substr [HTTP::payload] 300 0]"
       log local0. "findstr output: [findstr "$requestpayload" "=" 1 "zO"]"
       foreach p [split [HTTP::payload] =] {
        set name  [URI::decode [getfield $p = 1]]
        set value [URI::decode [getfield $p = 2]]
    
        log local0. "name1$name"
        log local0. "value1$value"
       }
    
     }

    }