Skip to content
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

Match response body in remote_json authorizer #1169

Open
4 of 5 tasks
jaspeen opened this issue Jun 15, 2024 · 0 comments
Open
4 of 5 tasks

Match response body in remote_json authorizer #1169

jaspeen opened this issue Jun 15, 2024 · 0 comments
Labels
rfc A request for comments to discuss and share ideas.

Comments

@jaspeen
Copy link

jaspeen commented Jun 15, 2024

Preflight checklist

Ory Network Project

No response

Context and scope

There are external autorization services like open policy agent and OpenFGA which don't response with HTTP 403 on authorization failure. Instead they return json value indicating the result of authorization - {"result": true} and {"allowed": true} for OPA and OpenFGA correspondingly.

In this case we need to check the response body to determine if the request is authorized or not.

There is related issue #1125

Goals and non-goals

  • Deny or allow request based on the particular response json body value in case response status is 200
  • Backward compatible with existing configuration

The design

New configuration key will be added under remote_json authorizer - match_json_field as object with following properties:

  • field : json field selector (gjson) to match
  • str_val : string value to match
  • bool_val : boolean value to match

If that key is specified in authorizaer configuration and reponse HTTP status is 200 it will try to parse the response body as json, extract the field value using gjson selector and compare it with the provided value.
In this case authorization passed only if the field exists and equals with value of proper type.

From my point of view gjson selector is better here than just simple parse json and get the field because beyond those mentioned external authorization service there may be other which put the result in nested structure like {"result":{"status": "ok"}} and selector gives there more flexibility. And gjson is already used in the codebase.

APIs

No response

Data storage

No response

Code and pseudo-code

No response

Degree of constraint

No response

Alternatives considered

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rfc A request for comments to discuss and share ideas.
Projects
None yet
Development

No branches or pull requests

1 participant