Skip to content

Commit 0e68df4

Browse files
committed
feat: Add OpaConfig for authorization configuration
1 parent e6ca161 commit 0e68df4

6 files changed

Lines changed: 66 additions & 0 deletions

File tree

helm/blueapi/config_schema.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,22 @@
330330
"type": "object",
331331
"$id": "OIDCConfig"
332332
},
333+
"OpaConfig": {
334+
"additionalProperties": false,
335+
"properties": {
336+
"root": {
337+
"default": "http://localhost:8181/",
338+
"format": "uri",
339+
"maxLength": 2083,
340+
"minLength": 1,
341+
"title": "Root",
342+
"type": "string"
343+
}
344+
},
345+
"title": "OpaConfig",
346+
"type": "object",
347+
"$id": "OpaConfig"
348+
},
333349
"PlanSource": {
334350
"additionalProperties": false,
335351
"properties": {
@@ -612,6 +628,17 @@
612628
}
613629
],
614630
"default": null
631+
},
632+
"opa": {
633+
"anyOf": [
634+
{
635+
"$ref": "OpaConfig"
636+
},
637+
{
638+
"type": "null"
639+
}
640+
],
641+
"default": null
615642
}
616643
},
617644
"title": "ApplicationConfig",

helm/blueapi/values.schema.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,22 @@
751751
},
752752
"additionalProperties": false
753753
},
754+
"OpaConfig": {
755+
"$id": "OpaConfig",
756+
"title": "OpaConfig",
757+
"type": "object",
758+
"properties": {
759+
"root": {
760+
"title": "Root",
761+
"default": "http://localhost:8181/",
762+
"type": "string",
763+
"format": "uri",
764+
"maxLength": 2083,
765+
"minLength": 1
766+
}
767+
},
768+
"additionalProperties": false
769+
},
754770
"PlanSource": {
755771
"$id": "PlanSource",
756772
"title": "PlanSource",
@@ -1011,6 +1027,16 @@
10111027
}
10121028
]
10131029
},
1030+
"opa": {
1031+
"anyOf": [
1032+
{
1033+
"$ref": "OpaConfig"
1034+
},
1035+
{
1036+
"type": "null"
1037+
}
1038+
]
1039+
},
10141040
"scratch": {
10151041
"anyOf": [
10161042
{

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ dependencies = [
3737
"tomlkit",
3838
"graypy>=2.1.0",
3939
"httpx>=0.28.1",
40+
"aiohttp>=3.13.5",
4041
]
4142
dynamic = ["version"]
4243
license.file = "LICENSE"

src/blueapi/config.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,10 @@ class Tag(StrEnum):
296296
META = "Meta"
297297

298298

299+
class OpaConfig(BlueapiBaseModel):
300+
root: HttpUrl = HttpUrl("http://localhost:8181")
301+
302+
299303
class ApplicationConfig(BlueapiBaseModel):
300304
"""
301305
Config for the worker application as a whole. Root of
@@ -335,6 +339,7 @@ class ApplicationConfig(BlueapiBaseModel):
335339
oidc: OIDCConfig | None = None
336340
auth_token_path: Path | None = None
337341
numtracker: NumtrackerConfig | None = None
342+
opa: OpaConfig | None = None
338343

339344
def __eq__(self, other: object) -> bool:
340345
if isinstance(other, ApplicationConfig):
@@ -343,6 +348,7 @@ def __eq__(self, other: object) -> bool:
343348
& (self.env == other.env)
344349
& (self.logging == other.logging)
345350
& (self.api == other.api)
351+
& (self.opa == other.opa)
346352
)
347353
return False
348354

tests/unit_tests/test_config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,9 @@ def test_config_yaml_parsed(temp_yaml_config_file):
337337
}
338338
],
339339
},
340+
"opa": {
341+
"root": "http://opa.example.com/",
342+
},
340343
},
341344
{
342345
"stomp": {
@@ -392,6 +395,7 @@ def test_config_yaml_parsed(temp_yaml_config_file):
392395
}
393396
],
394397
},
398+
"opa": None,
395399
},
396400
],
397401
indirect=True,

uv.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)