-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide headers in input to authorization policy #1456
Comments
These changes update the server to include request headers in the authorization input document. Fixes open-policy-agent#1456 Signed-off-by: Torin Sandall <torinsandall@gmail.com>
These changes update the server to include request headers in the authorization input document. Fixes #1456 Signed-off-by: Torin Sandall <torinsandall@gmail.com>
Hi there @tsandall. I've seen a few questions around how to access the http headers from an OPA policy rego and came upon this thread. I had thought that I might be able to access the incoming http headers via input.headers, or input.request.headers in my own custom policies, but am I right in thinking that the headers are actually only available to the system.authz policy? Whereas if I write my own policy e.g. phil.rego, if I want it to have access to the http headers, the consumer has to provide them as part of the input object? There are other references to an envoy plugin, but I'm presuming that's doing some sort of proxying where it takes the actually http headers and adds them to the input object then forwards onto OPA? Thanks in advance |
@phil-lee-kb that's correct — you'll need to provide any data required for evaluation as part of the request body. Remember that running as a server is only one of many ways OPA may operate, and having headers included in the input would couple your policy to a single mode of operation (
Having the client add relevant data to the body might be a bit of a burden, but the upside is that your policy isn't coupled to any specific evaluation context, and may run in any of the above. |
Thank you @anderseknert 😄 When you put it in that context, it makes perfect sense that the headers aren't available. And also makes for a consistent experience across things like the rego playground and when running OPA itself |
Currently the HTTP server does not provide the HTTP headers of incoming requests to the authorization policy. If users want to inspect custom headers to control access to OPA itself, they cannot. We can extend OPA to expose the headers to the policy as a map of string arrays.
The text was updated successfully, but these errors were encountered: