Skip to content

feat: Add OpaClient to wrap auth checks#1541

Open
tpoliaw wants to merge 5 commits into
depends-userfrom
opa-client
Open

feat: Add OpaClient to wrap auth checks#1541
tpoliaw wants to merge 5 commits into
depends-userfrom
opa-client

Conversation

@tpoliaw
Copy link
Copy Markdown
Contributor

@tpoliaw tpoliaw commented May 15, 2026

Proof of concept opa client with dependency injection and example check

@tpoliaw tpoliaw changed the title feat: Add OpaClient to wrap auth checks" feat: Add OpaClient to wrap auth checks May 15, 2026
Comment thread src/blueapi/service/main.py Fixed
@tpoliaw tpoliaw force-pushed the opa-client branch 2 times, most recently from e8ddc77 to db3325b Compare May 15, 2026 15:31
@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.77%. Comparing base (e6ca161) to head (a093b5a).

Additional details and impacted files
@@               Coverage Diff                @@
##           depends-user    #1541      +/-   ##
================================================
+ Coverage         95.63%   95.77%   +0.14%     
================================================
  Files                43       44       +1     
  Lines              3228     3264      +36     
================================================
+ Hits               3087     3126      +39     
+ Misses              141      138       -3     

☔ 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.

@tpoliaw tpoliaw changed the base branch from main to depends-user May 29, 2026 10:50
@tpoliaw tpoliaw marked this pull request as ready for review June 2, 2026 11:13
@tpoliaw tpoliaw requested a review from a team as a code owner June 2, 2026 11:13
Copy link
Copy Markdown

@fajinyuan fajinyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please see my questions.

Comment thread src/blueapi/config.py
Comment thread helm/blueapi/values.schema.json
Copy link
Copy Markdown
Contributor

@ZohebShaikh ZohebShaikh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

Comment thread src/blueapi/service/authorization.py Outdated
Comment thread src/blueapi/service/authorization.py Outdated
Comment thread src/blueapi/service/authorization.py Outdated
}
},
)
return (await resp.json())["result"]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Will be good to TypeAdapter the result to bool because of python

Something like this

        from pydantic import TypeAdapter
        return TypeAdapter(bool).validate_python((await resp.json())["result"])

I think we should as put this in

try:
  	TypeAdapter(bool).validate_python((await resp.json())["result"])
except KeyError : # on result unlikely
	...
except Timeout to OPA as e:
	raise e as Timeouterror

or just Exception

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the TypeAdapter protect against? OPA returning "False" instead of False?

For the exception handling, does wrapping the exception here add much beyond letting the original exception be raised?

Comment thread src/blueapi/config.py
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.

3 participants