LuciaCabanillasRodriguez commented on issue #11908:
URL: https://github.com/apache/apisix/issues/11908#issuecomment-2595360903

   I am now trying something like this, using the headers: 
    ```
    "plugins": {
       "opa": {
         "_meta": {
           "disable": false
         },
         "host": "http://x:8181";,
         "policy": "example",
         "send_headers_upstream": [
           "Location"
         ]
       },
       "proxy-rewrite": {
         "uri": "/${custom_uri}"
       },
       "serverless-pre-function": {
         "functions": [
           "return function(conf, ctx)\n    local core = 
require(\"apisix.core\")\n    local custom_uri = ctx.var.header    if 
custom_uri then\n        core.request.header(ctx, \"Location\") = custom_uri\n  
      core.log.info(\"Custom URI set by OPA: \" .. custom_uri)\n    else\n      
  core.log.warn(\"OPA result is missing\")\n    end\nen"
         ],
         "phase": "rewrite"
       }
     },
   ```
   
   My policy in OPA: 
   
   ```
   allow if {
        is_get
        is_admin
   }
   
   headers = {
                "Location": "/example"
   } if {
       allow
        is_org1
   }
   ```
   


-- 
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