Skip to content

[OPA] Fix OPA middleware to comply with OPA V1#8084

Merged
michaelstaib merged 12 commits into
ChilliCream:mainfrom
stoyanovskydmitry:fix/Opa-Authorization
Mar 13, 2025
Merged

[OPA] Fix OPA middleware to comply with OPA V1#8084
michaelstaib merged 12 commits into
ChilliCream:mainfrom
stoyanovskydmitry:fix/Opa-Authorization

Conversation

@stoyanovskydmitry
Copy link
Copy Markdown
Contributor

@stoyanovskydmitry stoyanovskydmitry commented Mar 2, 2025

  • Add support to validate policy before and after the request with IMiddlewareContext (access to input arguments)
  • Add OPA request extensions handler support
  • Fix unit tests
  • Actualize OPA middleware support

There is no known assoicated bug number, only discussion here: https://hotchocolategraphql.slack.com/archives/CD9TNKT8T/p1739806911182499

Partially related ticket #5541.

- Add support to validate policy before and after request with IMiddlewareContext (access to input arguments)
- Add OPA request extensions handler support
- Fix unit tests
- Other fixes
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 2, 2025

CLA assistant check
All committers have signed the CLA.

@stoyanovskydmitry stoyanovskydmitry marked this pull request as draft March 2, 2025 15:28
@stoyanovskydmitry stoyanovskydmitry marked this pull request as ready for review March 2, 2025 15:48
@stoyanovskydmitry stoyanovskydmitry changed the title Fix OPA middleware to comply with OPA V1 [OPA] Fix OPA middleware to comply with OPA V1 Mar 6, 2025
@michaelstaib
Copy link
Copy Markdown
Member

Hey @stoyanovskydmitry,

this PR looks very good ... I will merge it today if all tests are green. Thank you a lot for work on this. I will integrate it with the next preview of HotChocolate 15.1

@michaelstaib michaelstaib added Area: Authorization Issue is related to authorization 🍒 cherry-pick Consider cherry-picking these changes into the previous major version. labels Mar 7, 2025
@michaelstaib michaelstaib added this to the HC-15.1.0 milestone Mar 7, 2025
@stoyanovskydmitry
Copy link
Copy Markdown
Contributor Author

stoyanovskydmitry commented Mar 8, 2025

It looks like something wrong with OPA tests env:
System.IO.DirectoryNotFoundException : Could not find a part of the path '/home/runner/work/graphql-platform/graphql-platform/src/HotChocolate/AspNetCore/test/AspNetCore.Authorization.Opa.Tests/bin/Debug/net9.0/policies/has_age_defined.rego'.
As far as I understand fix should be done on the env side, if not please let me know what should be fixed on the PR's side.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.15%. Comparing base (95ef2c4) to head (d9bf5b2).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8084      +/-   ##
==========================================
+ Coverage   74.02%   74.15%   +0.13%     
==========================================
  Files        2664     2665       +1     
  Lines      140319   140322       +3     
  Branches    16338    16323      -15     
==========================================
+ Hits       103873   104059     +186     
+ Misses      30879    30683     -196     
- Partials     5567     5580      +13     
Flag Coverage Δ
unittests 74.15% <ø> (+0.13%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@michaelstaib michaelstaib self-requested a review March 13, 2025 18:58
@michaelstaib michaelstaib merged commit 97db427 into ChilliCream:main Mar 13, 2025
michaelstaib pushed a commit that referenced this pull request Mar 13, 2025
Co-authored-by: Glen <glen.84@gmail.com>
@michaelstaib
Copy link
Copy Markdown
Member

This is now integrated into 15.1.0-p.17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Authorization Issue is related to authorization 🍒 cherry-pick Consider cherry-picking these changes into the previous major version. 🌶️ hot chocolate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants