Skip to content

Commit

Permalink
Split up the return statement in _is_authorized_callback for clarity (a…
Browse files Browse the repository at this point in the history
…pache#42473)


Co-authored-by: Vincent <[email protected]>
  • Loading branch information
dstandish and vincbeck authored Sep 26, 2024
1 parent 2beb6a7 commit 291048a
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions airflow/api_connexion/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,12 @@ def callback():
if dag_id or access or access_entity:
return access

# No DAG id is provided, the user is not authorized to access all DAGs and authorization is done
# on DAG level
# If method is "GET", return whether the user has read access to any DAGs
# If method is "PUT", return whether the user has edit access to any DAGs
return (method == "GET" and any(get_auth_manager().get_permitted_dag_ids(methods=["GET"]))) or (
method == "PUT" and any(get_auth_manager().get_permitted_dag_ids(methods=["PUT"]))
)
# dag_id is not provided, and the user is not authorized to access *all* DAGs
# so we check that the user can access at least *one* dag
# but we leave it to the endpoint function to properly restrict access beyond that
if method not in ("GET", "PUT"):
return False
return any(get_auth_manager().get_permitted_dag_ids(methods=[method]))

return callback

Expand Down

0 comments on commit 291048a

Please sign in to comment.