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

feat: Values object can be used in payload of generic contextualizer and remote authorizer #749

Merged
merged 5 commits into from
Jun 29, 2023

Conversation

dadrus
Copy link
Owner

@dadrus dadrus commented Jun 29, 2023

Related issue(s)

closes #686

Checklist

  • I agree to follow this project's Code of Conduct.
  • I have read, and I am following this repository's Contributing Guidelines.
  • I have read the Security Policy.
  • I have referenced an issue describing the bug/feature request.
  • I have added tests that prove the correctness of my implementation.
  • I have updated the documentation.

Description

Makes following possible:

- id: openfga
  config:
    endpoint: # etc.
    payload: |
      {
        "user": "user:{{ .Subject.ID }}",
        "relation": {{ quote .Values.relation }},
        "resource": {{ quote .Values.resource }}
      }

and then used in a pipeline like

- authorizer: openfga
  config:
    values:
      relation: read
      resource: "endpoint:foo"

which will result in the following json payload sent to the defined endpoint for the .Subject.ID being 1:

{
    "user": "user:1",
    "relation": "read",
    "resource": "endpoint:foo"
}

If the values property is defined in the configuration of the particular mechanism, the corresponding entries act as defaults for the rule pipeline making use of that mechanism.

@codecov
Copy link

codecov bot commented Jun 29, 2023

Codecov Report

Merging #749 (a9130ac) into main (9809fe4) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #749   +/-   ##
=======================================
  Coverage   89.59%   89.59%           
=======================================
  Files         215      215           
  Lines        9227     9229    +2     
=======================================
+ Hits         8267     8269    +2     
  Misses        767      767           
  Partials      193      193           
Impacted Files Coverage Δ
.../rules/mechanisms/authorizers/remote_authorizer.go 83.33% <100.00%> (+0.05%) ⬆️
...chanisms/contextualizers/generic_contextualizer.go 86.85% <100.00%> (+0.05%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@dadrus dadrus merged commit 42267cb into main Jun 29, 2023
@dadrus dadrus deleted the feat/values_for_payload branch June 29, 2023 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add endpoint.values equivalent for payload of remote authorizer
1 participant