Skip to content

Commit 24b997b

Browse files
author
Stephen Bracken
committed
fix linting
1 parent ebc208e commit 24b997b

3 files changed

Lines changed: 13 additions & 7 deletions

File tree

providers/keycloak/docs/auth-manager/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ When using the Keycloak auth manager with a multi-team deployment, you will need
6060

6161
If a team has dags added to Airflow but they are not setup in the keycloak client, keycloak will return a 500 error on the ``/dags`` screen:
6262
```Resource with id [Dag:<team name>] does not exist.```
63-
The keycloak auth manager will handle this error by registering it as a 'deny' response to preserve access to the ``/dags`` screen for other teams.
63+
The keycloak auth manager will handle this error by registering it as a 'deny' response to preserve access to the ``/dags`` screen for other teams.

providers/keycloak/src/airflow/providers/keycloak/auth_manager/keycloak_auth_manager.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@
8282

8383

8484
def _is_missing_keycloak_resource_response(resource_name: str, status_code: int, text: Any) -> bool:
85-
return status_code == 500 and isinstance(text, str) and KEYCLOAK_RESOURCE_NOT_FOUND_ERROR.format(resource_name=resource_name).lower() in text.lower()
85+
return (
86+
status_code == 500
87+
and isinstance(text, str)
88+
and KEYCLOAK_RESOURCE_NOT_FOUND_ERROR.format(resource_name=resource_name).lower() in text.lower()
89+
)
8690

8791

8892
TEAM_SCOPED_RESOURCES = frozenset(
@@ -444,7 +448,9 @@ def _is_authorized(
444448
raise AirflowException(
445449
f"Request not recognized by Keycloak. {error.get('error')}. {error.get('error_description')}"
446450
)
447-
if is_team_resource and _is_missing_keycloak_resource_response(resource_name, resp.status_code, resp.text):
451+
if is_team_resource and _is_missing_keycloak_resource_response(
452+
resource_name, resp.status_code, resp.text
453+
):
448454
log.warning("Keycloak authorization resource is missing; denying access. Response: %s", resp.text)
449455
return False
450456
raise AirflowException(f"Unexpected error: {resp.status_code} - {resp.text}")

providers/keycloak/tests/unit/keycloak/auth_manager/test_keycloak_auth_manager.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
VariableDetails,
3939
)
4040

41-
from tests_common.test_utils.version_compat import AIRFLOW_V_3_1_7_PLUS, AIRFLOW_V_3_2_PLUS
4241
from tests_common.test_utils.config import conf_vars
42+
from tests_common.test_utils.version_compat import AIRFLOW_V_3_1_7_PLUS, AIRFLOW_V_3_2_PLUS
4343

4444
if AIRFLOW_V_3_2_PLUS:
4545
from airflow.api_fastapi.auth.managers.models.resource_details import TeamDetails
@@ -66,8 +66,6 @@
6666
)
6767
from airflow.providers.keycloak.auth_manager.user import KeycloakAuthManagerUser
6868

69-
from tests_common.test_utils.config import conf_vars
70-
7169

7270
def _build_access_token(payload: dict[str, object]) -> str:
7371
header = {"alg": "none", "typ": "JWT"}
@@ -396,7 +394,9 @@ def test_is_authorized_missing_keycloak_resource(self, auth_manager, user, caplo
396394
auth_manager.http_session.post = Mock(return_value=resp)
397395
caplog.set_level("WARNING", logger="airflow.providers.keycloak.auth_manager.keycloak_auth_manager")
398396

399-
result = auth_manager.is_authorized_dag(method="GET", details=DagDetails(id="dag_0", team_name="team-a"), user=user)
397+
result = auth_manager.is_authorized_dag(
398+
method="GET", details=DagDetails(id="dag_0", team_name="team-a"), user=user
399+
)
400400

401401
assert result is False
402402
assert "Keycloak authorization resource is missing; denying access" in caplog.text

0 commit comments

Comments
 (0)