Skip to content

Commit 016586e

Browse files
fix(airflow): Fix call to OPA
1 parent 69fdd3d commit 016586e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

airflow/opa-auth-manager/opa_auth_manager/opa_fab_auth_manager.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Custom Auth manager for Airflow
33
"""
44

5-
from typing import cast, override
5+
from typing import override
66
from airflow.auth.managers.base_auth_manager import ResourceMethod
77
from airflow.auth.managers.models.base_user import BaseUser
88
from airflow.auth.managers.models.resource_details import (
@@ -61,23 +61,23 @@ def _init_config(self):
6161
config.setdefault("AUTH_OPA_REQUEST_URL", "http://opa:8081/v1/data/airflow")
6262
config.setdefault("AUTH_OPA_REQUEST_TIMEOUT", 10)
6363

64-
def call_opa(self, url: str, json: dict, timeout: int) -> requests.Response | None:
65-
self.opa_session.post(url=url, json=json, timeout=timeout)
64+
def call_opa(self, url: str, json: dict, timeout: int) -> requests.Response:
65+
return self.opa_session.post(url=url, json=json, timeout=timeout)
6666

6767
@cachedmethod(lambda self: self.opa_cache)
6868
def _is_authorized_in_opa(self, endpoint: str, input: OpaInput) -> bool:
6969
config = self.appbuilder.get_app.config
7070
opa_url = config.get("AUTH_OPA_REQUEST_URL")
7171
try:
72-
response = cast(requests.Response, self.call_opa(
72+
response = self.call_opa(
7373
f'{opa_url}/{endpoint}',
7474
json=input.to_dict(),
7575
timeout=config.get("AUTH_OPA_REQUEST_TIMEOUT")
76-
))
76+
)
7777
result = response.json().get("result")
7878
return result == True
7979
except Exception as e:
80-
self.log.error(f"Request to OPA failed: {e}")
80+
self.log.error(f"Request to OPA failed", exc_info=e)
8181
return False
8282

8383
@override

0 commit comments

Comments
 (0)