-
Notifications
You must be signed in to change notification settings - Fork 14.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add readonly REST API endpoint for roles and permissions #14664
Add readonly REST API endpoint for roles and permissions #14664
Conversation
The Workflow run is cancelling this PR. Building images for the PR has failed. Follow the workflow link to check the reason. |
airflow/api_connexion/endpoints/role_and_permission_endpoint.py
Outdated
Show resolved
Hide resolved
airflow/api_connexion/endpoints/role_and_permission_endpoint.py
Outdated
Show resolved
Hide resolved
airflow/api_connexion/endpoints/role_and_permission_endpoint.py
Outdated
Show resolved
Hide resolved
958b92d
to
0f98cc7
Compare
I'm lost at what permissions should be used to protect these views @jhtimmins |
0f98cc7
to
460bbb4
Compare
do these endpoints work properly when environments use LDAP or Auth proxy? |
These endpoints are similar to what you would see when you go to Security > List Roles on the webserver. So it will work properly with any auth type since it just reads DB roles and permissions which are part of airflow. That's what I understand, unless I'm missing something. What do you think? |
This is very confusing to end users. They don't know all the limitations we have in the project. A similar situation occurs when the user uses the Backend Secret. See: https://apache-airflow.slack.com/archives/CCR6P6JRL/p1615394435242400 We should think about how to limit similar surprises because it takes users hours/days to discover that everything works as intended, but they misunderstood our product. This was one of the reasons this endpoint did not appear in the first version of the API.
https://cwiki.apache.org/confluence/display/AIRFLOW/AIP-32%3A+Airflow+REST+API As the simplest solution, we can disable this endpoint if it doesn't work properly in a current configuration, but we can also write a smart solution. |
These would certainly cause confusion for people checking roles and permissions just as it currently does on the UI. |
In Web UI, we should also disable it if it doesn't work properly.
Probably, when you pass * as the username to |
Hi @mik-laj , after going through the code, I see that we are good with this implementation. These roles must be one of the roles in FAB DB, that's why it's calculated here for LDAP. And you can see where roles in AUTH_ROLES_MAPPING are being searched here I believe we are good returning roles available in airflow because that's what auths use. The same thing applies to users endpoint, if user registration is set, users are created in FAB DB, if not, then no users in DB and there'll not be accident of returning users that was not added through LDAP or remote user. So I think this is different from secrets 🙁 |
2a478bc
to
0643192
Compare
Removed mistakenly added users endpoint |
nullable: false | ||
|
||
ActionResource: | ||
description: The Action-Resource permission item |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the different between a permission and an action resource?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ActionResource is equivalent to PermissonView Model https://github.com/dpgaspar/Flask-AppBuilder/blob/55b0976e1450295d5a26a06d28c5b992fb0b561e/flask_appbuilder/security/sqla/models.py#L71
It helps tie action with a resource
…lectionItem except where we have sensitive data
5b64a50
to
b78873e
Compare
This PR seeks to add readonly endpoints for roles and permissions.
Because this two endpoints share a lot together, I decided to have the code for both in one file instead of separate files. Let me know if this should be separated
^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.