contrib icon indicating copy to clipboard operation
contrib copied to clipboard

Kong-OPA Authz plugin does not send headers information to

Open rLitto opened this issue 3 years ago • 4 comments

Use Case scenario: we want OPA to make different authorization decisions based on the Accept (eg json vs xml) or other headers present in the request.

Currently the plugin provides only:

  • token (jwt token)
  • method (GET, POST, etc)
  • path

We want to add headers. If to keep backward compatibility we don't want it set by default, we want a property configuration for the plugin to enable the option as in this old plugin: https://github.com/ninjaneers-team/kong-opa

We do NOT want to send the body too

rLitto avatar Nov 27 '20 15:11 rLitto

@rLitto that sounds reasonable. Feel free to submit a PR to the integration if you'd like to see it added. The contrib repo is primarily for examples and proof-of-concepts. I'm not too familiar w/ the integration but I suspect you'd just have to add the right value from the request context here: https://github.com/open-policy-agent/contrib/blob/master/kong_api_authz/src/kong/plugins/opa/access.lua#L54

tsandall avatar Nov 30 '20 15:11 tsandall

Hi @tsandall I have a PR almost ready, it works in our Kong but I wanted some advice on two things:

  1. Changing the tests: being not a lua expert, I am not sure what is the best way to update the test since I don't know the specs of the methods
  2. Changing the diagram to add the headers: it seems that the tool used needs a license to support the changes, I can switch it to mermaid.js if you are ok

rLitto avatar Dec 21 '20 13:12 rLitto

Draft PR: https://github.com/open-policy-agent/contrib/pull/129

rLitto avatar Dec 21 '20 14:12 rLitto

Switching to mermaid would be great! If it's not too much of a hassle for you.

If you get stuck with the tests, I'll try to look into them tomorrow.

srenatus avatar Dec 21 '20 14:12 srenatus

PR was closed long time ago, so will close the issue too. If there's interest in this later, we can have it reopened.

anderseknert avatar Sep 22 '22 11:09 anderseknert