-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
fix: Gamma users shouldn't be able to create roles #29687
Conversation
@dpgaspar let me know if this pattern make sense or do you have another suggestion of either overriding the view registration, or adding security checks on the indy endpoints |
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.
instead of overriding register_views
can we leverage this instead https://github.com/apache/superset/blob/master/superset/security/manager.py#L226
add the FAB security views
# data=json.dumps({"name": "new_role"}), | ||
# content_type="application/json", | ||
# ) | ||
# self.assert403(response) |
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.
Yey for all the new tests! What should we do with these last two?
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.
Going to finishes these up today, mainly wanted to get the adjustment @dpgaspar in and will close these up soon
f35fd4c
to
cc096fe
Compare
superset/config.py
Outdated
@@ -320,6 +320,8 @@ def _try_json_readsha(filepath: str, length: int) -> str | None: | |||
# ex: http://localhost:8080/swagger/v1 | |||
FAB_API_SWAGGER_UI = True | |||
|
|||
FAB_ADD_SECURITY_API = True |
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.
@dpgaspar did we make and update in flask app builder to make this default True? When I recently pulled these were getting KeyError: FAB_ADD_SECURITY_API not found
Also I saw that flask app builder has this default True so to allow these test to run I just made this value consistent with what I saw upstream
Can you verify that this is what's happening?
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.
Default is false on FAB: https://github.com/dpgaspar/Flask-AppBuilder/blob/2d527aae09eed50fd52c6bf886a2970adb225428/flask_appbuilder/security/sqla/manager.py#L97
The link your mentioning is an example app
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.
Looks good, just a couple of non blocking comments
superset/config.py
Outdated
@@ -320,6 +320,8 @@ def _try_json_readsha(filepath: str, length: int) -> str | None: | |||
# ex: http://localhost:8080/swagger/v1 | |||
FAB_API_SWAGGER_UI = True | |||
|
|||
FAB_ADD_SECURITY_API = True |
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.
Default is false on FAB: https://github.com/dpgaspar/Flask-AppBuilder/blob/2d527aae09eed50fd52c6bf886a2970adb225428/flask_appbuilder/security/sqla/manager.py#L97
The link your mentioning is an example app
@with_config({"FAB_ADD_SECURITY_API": True}) | ||
def test_get_security_roles_gamma(self): | ||
""" | ||
Security API: Admin should be able to create roles |
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.
nit: comment is not correct
@with_config({"FAB_ADD_SECURITY_API": True}) | ||
def test_get_security_roles_admin(self): | ||
""" | ||
Security API: Admin should be able to create roles |
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.
nit: Security API: Admin should be able to get roles
(cherry picked from commit 7650c47)
SUMMARY
Currently users with gamma roles are still able to create roles, This PR is made to fix this as well as add test. Reason why this is happening is due to the instantiation of the
ModelRestAPI
classes happening here https://github.com/dpgaspar/Flask-AppBuilder/blob/2d527aae09eed50fd52c6bf886a2970adb225428/flask_appbuilder/security/sqla/manager.py#L97To fix it we'll just be adding the new security views names to the
ADMIN_ONLY_VIEW_MENUS
List in the manager classBEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
FAB_ADD_SECURITY_API = True
ADDITIONAL INFORMATION