Skip to content

Trigger button should be greyed out when no permissions to trigger DAG #57966

Closed

Description

@BasPH

Apache Airflow version

Other Airflow 2/3 version (please specify below)

If "Other Airflow 2/3 version" selected, which one?

3.1.0

What happened?

My user has no permission to trigger DAGs (i.e. no permission to create DAG runs).

However, in the UI, the trigger DAG button is accessible:

Image

You can enter details, and only after clicking the "Trigger" button do you receive an error:

Image

It would be more intuitive to grey out the button when the user has no permissions to trigger DAGs.

What you think should happen instead?

No response

How to reproduce

Run Airflow with read-only permissions

Operating System

Linux

Versions of Apache Airflow Providers

No response

Deployment

Astronomer

Deployment details

No response

Anything else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Activity

  1. added
    kind:bug
    needs-triage
    area:UI
    on Nov 6, 2025
  2. tirkarthi commented on Nov 6, 2025

    @tirkarthi
    Contributor

    There is an endpoint to return menus allowed with the UI disabling them menus not accessible in the UI. Perhaps there could be new API to dump the permissions relevant to UI like create a dagrun to disable/enable trigger button, delete a dagrun to enable/disable delete dagrun button etc.

    https://github.com/apache/airflow/blob/main/airflow-core/src/airflow/api_fastapi/core_api/routes/ui/auth.py

    <NavButton
    disabled={!authLinks?.authorized_menu_items.includes("Dags")}
    icon={DagIcon}
    title={translate("nav.dags")}
    to="dags"
    />

  3. removed
    kind:feature
    needs-triage
    on Nov 10, 2025
  4. bbovenzi commented on Nov 10, 2025

    @bbovenzi
    Contributor

    @vincbeck maybe its time to build a full permissions endpoint?

  5. added
    kind:feature
    and removed
    kind:bug
    on Nov 10, 2025
  6. potiuk commented on Nov 10, 2025

    @potiuk
    Member

    FYI @vincbeck has holidays and no computer with him. (🌴 )

  7. aaron-wolmutt commented on Nov 12, 2025

    @aaron-wolmutt
    Contributor

    @vincbeck maybe its time to build a full permissions endpoint?

    I think building an endpoint with permissions would be better. I have a PR open that can "grey" the button out if a 403 is returned by the API. But the error is no longer in state when the trigger dag modal is closed.

  8. 10 remaining items

  9. aaron-wolmutt commented on Nov 26, 2025

    @aaron-wolmutt
    Contributor

    I'm expecting the UI endpoints to be used as well. Probably in the auth.py module.

    I think to avoid downgrading the latency the permissions could be kept in session storage or something (maybe add a new hook to do this). I am still not super familiar with all aspects of the permissions-based auth since I'm a new contributor. We would definitely want to ensure the auth meta endpoint is called exactly once so the loading times and latencies do not degrade.

  10. jason810496 commented on Nov 27, 2025

    @jason810496
    Member

    I do not think we should call this endpoint to figure whether the user is allowed to trigger each individual dag, but we could call it when the user click on the trigger button (before displaying the pop up)

    Good call! Yes, this will be a great way to avoid the N+1 call I mentioned above. Maybe the RestAPI could be like GET /ui/auth/meta/method/{method}/access_entity/{access_entity}/{entity_id} (or POST /ui/auth/meta if we want to shorten the endpoint) for curret fearure? I just check that DetailsLayout might be the correct place to called the new meta endpoint.

  11. potiuk commented on Nov 28, 2025

    @potiuk
    Member

    Or maybe we could have one call where we can ask for multiple entity ids. We already have it implemented in some cases I believe (and keycloak client can efficiently ask for multiple resources - we looked at it before).

  12. aaron-wolmutt commented on Nov 28, 2025

    @aaron-wolmutt
    Contributor

    Or maybe we could have one call where we can ask for multiple entity ids. We already have it implemented in some cases I believe (and keycloak client can efficiently ask for multiple resources - we looked at it before).

    I was thinking that the call would happen after login. So, the user authenticates, the /ui/auth/meta/permissions API is called, then an authorization object persisted to local storage.

    It doesn't have to be local storage or session storage; it could be a global state manager or object if one is available (for example Redux).

    The only downside would be page load time could be too slow if the Airflow has 100+ DAGs. In the case that the Airflow has 100+s of DAGs, I think calling the /ui/auth/meta/permissions API when the run DAG modal is opened might be better. I guess it depends on what we're considering best practices.

  13. pierrejeambrun commented on Dec 1, 2025

    @pierrejeambrun
    Member

    I was thinking that the call would happen after login. So, the user authenticates, the /ui/auth/meta/permissions API is called, then an authorization object persisted to local storage.

    We cannot do that. Because there is no 'global' permissions object to return to the UI and store. We cannot possibly enumerate all that for every fine grained entity permissions.

    Check for permissions needs to be requested to the backend, ad hoc for specific operations, when necessary. As mentioned above only for tactical workflows, not everything. (typically not for table views).

    +1 for a single endpoint and capabilities to ask multiples permissions at once.

  14. potiuk commented on Dec 2, 2025

    @potiuk
    Member

    I was thinking that the call would happen after login. So, the user authenticates, the /ui/auth/meta/permissions API is called, then an authorization object persisted to local storage.

    Yeah. @aaron-wolmutt -> I think you did not really grasp the way how Auth Manager works. We have (and that's a deliberate decision) no single place where we keep all permissions that user has. This is delegated to the AuthManager and we just ask if we can do "this thing". And we always query "can I do THAT?" before we do THAT (this can be cached by Auth Manager, but it's totally dependent on implementation of the Auth Manager and is only possible if there is no dynamic THAT permission.

    The thing is that the THAT can contain (dag_id) for example. There might be completely different answer from the Auth Manager when you ask:

    • Can I trigger Dag A
    • Can I trigger Dag B

    And the logic which Dags can be triggered can be arbitrary complex and fully implemented in the Auth Manager implementation. For example in LDAP Auth Manager you could have separate database for:

    • users
    • departments
    • dags

    The department can be taken from some LDAP attribute - for example departmentNumber to get your department, and ten you can query dag list to see which dags are assigned to which departments. This is entirely dependent on the Auth Manager implementation, how complex and flexible it is. But eventually if you have 100.000 Dags - you would have to retrieve and cache 100.000 values "Can I trigger Dag X" for each user - and retrieve them right after login. Simply "permission" query contains also "resource id" as parameter - and result of the query can be different for each "resource".

    There is simply no "fixed" set of permission + resource combinations that user can enumerate effectively. This is why you need to query (Can I Trigger Dag 123) just about when you are going to show "Trigger Dag 123" button. You should also optimise such call for dag list - by being able to have one "Can I trigger Dags" fo all (say) 20 Dags you are about to display - and return the answer in one response for all 20 of them.

    But you cannot have "all permissions" for "all dags" combination. That would be just infeasible and require huge queries to backend (say LDAP) when you want to retrieve all those.

  15. aaron-wolmutt commented on Dec 2, 2025

    @aaron-wolmutt
    Contributor

    I was thinking that the call would happen after login. So, the user authenticates, the /ui/auth/meta/permissions API is called, then an authorization object persisted to local storage.

    Yeah. @aaron-wolmutt -> I think you did not really grasp the way how Auth Manager works. We have (and that's a deliberate decision) no single place where we keep all permissions that user has. This is delegated to the AuthManager and we just ask if we can do "this thing". And we always query "can I do THAT?" before we do THAT (this can be cached by Auth Manager, but it's totally dependent on implementation of the Auth Manager and is only possible if there is no dynamic THAT permission.

    The thing is that the THAT can contain (dag_id) for example. There might be completely different answer from the Auth Manager when you ask:

    • Can I trigger Dag A
    • Can I trigger Dag B

    And the logic which Dags can be triggered can be arbitrary complex and fully implemented in the Auth Manager implementation. For example in LDAP Auth Manager you could have separate database for:

    • users
    • departments
    • dags

    The department can be taken from some LDAP attribute - for example departmentNumber to get your department, and ten you can query dag list to see which dags are assigned to which departments. This is entirely dependent on the Auth Manager implementation, how complex and flexible it is. But eventually if you have 100.000 Dags - you would have to retrieve and cache 100.000 values "Can I trigger Dag X" for each user - and retrieve them right after login. Simply "permission" query contains also "resource id" as parameter - and result of the query can be different for each "resource".

    There is simply no "fixed" set of permission + resource combinations that user can enumerate effectively. This is why you need to query (Can I Trigger Dag 123) just about when you are going to show "Trigger Dag 123" button. You should also optimise such call for dag list - by being able to have one "Can I trigger Dags" fo all (say) 20 Dags you are about to display - and return the answer in one response for all 20 of them.

    But you cannot have "all permissions" for "all dags" combination. That would be just infeasible and require huge queries to backend (say LDAP) when you want to retrieve all those.

    Thanks guys I'm starting to understand.

    It looks like all of the DAGs that are listed in the UI do only support DAGAccessEntity.RUN like mentioned before.

    airflow-core/src/airflow/api_fastapi/core_api/routes/ui/dags.py

    dags_router = AirflowRouter(prefix="/dags", tags=["DAG"])
    
    
    @dags_router.get(
        "",
        response_model_exclude_none=True,
        dependencies=[
            Depends(requires_access_dag(method="GET")),
            Depends(requires_access_dag("GET", DagAccessEntity.RUN)),
        ],
        operation_id="get_dags_ui",
    )
    def get_dags(
        limit: QueryLimit,
        offset: QueryOffset,
    ...

    So could we require the dependency in /ui/auth/meta endpoint like this? I just did some debugging for the issue and I'm trying to understand it better.

    ...
    dependencies=[
          Depends(requires_access_dag(method="POST")),
    ]
    ...
  16. pierrejeambrun commented on Jan 16, 2026

    @pierrejeambrun
    Member

    Closed by:
    #58016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:UIarea:authkind:feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions