abdulsalam3105 commented on issue #12064:
URL: 
https://github.com/apache/trafficserver/issues/12064#issuecomment-2788293798

   Regarding lua in 9.2.X , i have updaed lua script and also added some 
rewrite in IHS httpd.conf it works, but it doesnt works in eclipse client. 
   
   function send_request()
   ts.server_request.header["Host"] = "trafficserverfqdn"
   local file = io.open("/var/log/trafficserver/lua_output2.log", "a")
   file:write("Lua script is changing the host header of outgoing request.\n")
   file:close()
   end
   
   function send_response()
     local header_name = "x-jsa-authorization-redirect"
     local jsa = ts.client_response.header[header_name]
     local file = io.open("/var/log/trafficserver/lua.log", "a")
   
     if jsa then
       file:write("Original Header: " .. jsa .. "\n")
   
       -- Replace redirect_uri host in the encoded header.
       -- Matches: redirect_uri=https%3A%2F%2F(ihsfqdn)
       local modified = jsa:gsub("(redirect_uri=https%%3A%%2F%%2F)ihsfqdn", 
"%1trafficserverfqdn", 1)
   
       -- Replace return host inside the encoded state parameter.
       -- Matches: return%3Dhttps%253A%252F%252F(ihsfqdn)
       modified = modified:gsub("(return%%3Dhttps%%253A%%252F%%252F)ihsfqdn", 
"%1trafficserverfqdn", 1)
   
       ts.client_response.header[header_name] = modified
       file:write("Modified Header: " .. modified .. "\n")
     else
       file:write("Header not found!\n")
     end
   
     file:close()
   end
   
   function do_remap()
   ts.hook(TS_LUA_HOOK_SEND_REQUEST_HDR, send_request)
     ts.hook(TS_LUA_HOOK_SEND_RESPONSE_HDR, send_response)
     local file = io.open("/var/log/trafficserver/lua.log", "a")
     file:write("Lua script is running.\n")
     file:close()
   
     return 0
   end
   
   
   ihs config file. 
   
   RewriteEngine On
   
   # Check if the Referer header matches the specified URL
   RewriteCond %{HTTP_REFERER} ^https://trafficserverfqdn/ [NC]
   
   # Check if the redirect_uri is not already set to the desired value
   RewriteCond %{QUERY_STRING} 
!(^|&)redirect_uri=https%3A%2F%2Ftrafficserverfqdn%2Fccm%2Fjsa(&|$)
   
   # Capture the existing query string without the redirect_uri
   RewriteCond %{QUERY_STRING} (.*)&?redirect_uri=[^&]*(.*)
   
   # Rewrite the URL to change only the redirect_uri parameter
   RewriteRule ^/oidc/endpoint/jazzop/authorize$ 
/oidc/endpoint/jazzop/authorize?%1&redirect_uri=https%3A%2F%2Ftrafficserverfqdn%2Fccm%2Fjsa
 [R=302,L,NE]
   
   
   i used lua plugin in remap.config 
   
   if i access trafficserver in eclipse it logs below error even i have enter 
valid credentials. 
   
   1742791665.254 20 10.169.116.27 TCP_MISS/503 868 GET 
https://ihsurl/ccm/jsa?error=login_required&error_description=End-User+authentication+is+required.+The+prompt+parameter+value+needs+to+be+modified+in+order+to+display+a+login+form%2C+or+a+user+credential+needs+to+be+supplied.&state=security_token1%3DHgYx1iqm%2FuHXAGhDsu9BMg2IjiVHljvsf%2BCHpwE4gbM%3D%26security_token2%3DejZPuGlrut3wvqqiVNQF%2FL2SvYjwpxdKNtOvrRT2eog%3D%26return%3Dhtt


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to