<p>I have two apps - one is a java based REST application (“A”) and the other one is a go lang based rego policy framework (“B”).</p>
<p>I have run these two apps as containers in a single pod in K8s. However, I am not sure how can I get the incoming HTTP requests to first hit the “B” rego policy framework and based on the policy decision, the request be forwarded to “A”. Is there a way this can be achieved?</p>

N Deepak Prasath
<blockquote>
<p>I am not sure how can I get the incoming HTTP requests to first hit the “B” rego policy framework</p>
</blockquote>
<p>A &quot;rego policy framework&quot;, e.g. OpenPolicyAgent are typically used as an assisting container.</p>
<p>In this setup, your application receives the request, then <strong>ask</strong> the &quot;rego policy framework&quot; container, &quot;is this request allowed?&quot;, then your application continue to process the request.</p>
<p>See e.g <a href="https://www.openpolicyagent.org/docs/latest/http-api-authorization/" rel="nofollow noreferrer">OpenPolicyAgent example - HTTP API Authorization</a> with this part, to <strong>ask if the request is allowed</strong>.</p>
<pre><code># ask OPA for a policy decision
# (in reality OPA URL would be constructed from environment)
rsp = requests.post(&quot;http://127.0.0.1:8181/v1/data/httpapi/authz&quot;, json=input_dict)
if rsp.json()[&quot;allow&quot;]:
  # HTTP API allowed
else:
  # HTTP API denied
</code></pre>
