superset icon indicating copy to clipboard operation
superset copied to clipboard

RBAC not Working

Open LalaGabor opened this issue 3 years ago • 18 comments

Problem: Role Based Access Control is not enabling users to view Dashboards correctly.

Feature flag enabled: RBAC Browser: Firefox Superset Version 1.4

Background: I have assigned a user a role AlphaDG (essentially Gamma) and have assigned this role to a dashboard.

Expected outcome: Even though the user has not been assigned access to the underlying dataset(s), this user should be able to see the dashboard.

Actual outcome: The user is not able to see the dashboard (whether published or not)

Gamma User Issue

image

image

LalaGabor avatar Feb 09 '22 08:02 LalaGabor

Perhaps I have not included a necessary permissions flag?

That being said, I have tested user roles who are give all permissions (except datasource access obviously, as this is why I am using RBAC.....)

LalaGabor avatar Feb 09 '22 08:02 LalaGabor

DASHBOARD_RBAC is the feature flag you enabled right.

nikhil-kuyya-talentas avatar Mar 17 '22 07:03 nikhil-kuyya-talentas

I had a similar issue:

User 1 - has access to a dataset via role AlphaCopy (all datasource access is removed) User 2 - has access to same dataset via role GammaCopy Dashboard 1 and Dashboard 2 - defined on dataset

Now feature flag is enabled and access is set as follows: Dashboard 1 - No specific user set, so all users with access to dataset should have access Dashboard 2 - Only Role AlphaCopy has access to it

Outcome expected: User 1 will have access to Dashboard 1 and Dashboard 2, User 2 will have access to only Dashboard 1 Actual Result: User 1 and User 2 didn't have access to any dashboards

I then gave specific access to Dashboard 1 to role AlphaCopy and GammaCopy. Same result

How exactly is the FEATURE FASHBOARD_RBAC supposed to work?

srinisubramanian avatar Mar 21 '22 05:03 srinisubramanian

I can confirm @srinisubramanian's observation. Same for me. I also pulled a fresh image without any modification (apart from the FF) to double check. The FF is not stable! Please investigate.

MM-Lehmann avatar May 04 '22 11:05 MM-Lehmann

Ping @amitmiran137 , have you run into this? We're hoping to push out 1.5.1 in 1-2 weeks, so if this feature is currently broken it would be nice to get a fix for this in.

villebro avatar May 04 '22 11:05 villebro

Are you using the DASHBOARD_RBAC ff?

Ehy not use the new UI for editing a dashboard

We use it as one of the core features we use and it does work

Please answer those questions sk we can proceed

amitmiran137 avatar May 04 '22 12:05 amitmiran137

I just tested this again with 1.5.0 and it works. Maybe it was an older version issue?

srinisubramanian avatar May 04 '22 12:05 srinisubramanian

Thanks @amitmiran137 and @srinisubramanian ! so we're ok closing this with the assumption that upgrading to 1.5 should fix the problem?

villebro avatar May 04 '22 12:05 villebro

I guess so @villebro as of now the feature flag works after the upgrade to 1.5.0 that I did.

srinisubramanian avatar May 04 '22 12:05 srinisubramanian

Alright, this has become a bit unstructured. I was just picking up on parts of https://github.com/apache/superset/issues/18634#issuecomment-1073508833 but actually my problem is described in #17227 So you might as well close this issue and continue discussion in the other one ;) Sorry for the mess

MM-Lehmann avatar May 04 '22 12:05 MM-Lehmann

I have issue with Superset v1.5.0 , I'm unable to Assign Roles for users in Dashboard Properties(Option is not showing). I have enabled DASHBOARD_RBAC=True in config.py Can anyone Help m Roles Option disable e

AkshayKumarC132 avatar Jun 14 '22 12:06 AkshayKumarC132

I have issue with Superset v1.5.0 , I'm unable to Assign Roles for users in Dashboard Properties(Option is not showing). I have enabled DASHBOARD_RBAC=True in config.py Can anyone Help m Roles Option disable e

Did you set the feature flag or just a variable?

MM-Lehmann avatar Jun 14 '22 17:06 MM-Lehmann

As mentioned elsewhere it's working good for me. The only catch is I had to give access to users on each dashboard. Default access didn't work.

Did you also run superset init? If not please try that.

srinisubramanian avatar Jun 14 '22 17:06 srinisubramanian

could be a duplicate ticket to https://github.com/apache/superset/issues/19988 (happens also on V2.0.0)

nigzak avatar Sep 15 '22 13:09 nigzak

The error is in

superset/security/manager.py

in the has_rbac_access function

 def has_rbac_access() -> bool:
            return (not is_feature_enabled("DASHBOARD_RBAC")) or any(
                dashboard_role.id
                in [user_role.id for user_role in self.get_user_roles()]
                for dashboard_role in dashboard.roles
            )

Delete the "not" and everything works as expected. Sorry, first post here, have to read up on how to officially post such things.

benjamin-mueller avatar Sep 16 '22 08:09 benjamin-mueller

The error is in

superset/security/manager.py

in the has_rbac_access function

 def has_rbac_access() -> bool:
            return (not is_feature_enabled("DASHBOARD_RBAC")) or any(
                dashboard_role.id
                in [user_role.id for user_role in self.get_user_roles()]
                for dashboard_role in dashboard.roles
            )

Delete the "not" and everything works as expected. Sorry, first post here, have to read up on how to officially post such things.

Sorry @benjamin-mueller, that doesn't make sense. Your solution would completely bypass any role management introduced with the feature flag and grant all access, only because the FF is enabled.

MM-Lehmann avatar Sep 16 '22 08:09 MM-Lehmann

The role management is done somewhere else, as mentioned in the parent function

def raise_for_dashboard_access(self, dashboard: "Dashboard") -> None:
        """
        Raise an exception if the user cannot access the dashboard.
        This does not check for the required role/permission pairs,
        it only concerns itself with entity relationships.
        :param dashboard: Dashboard the user wants access to
        :raises DashboardAccessDeniedError: If the user cannot access the resource
        """

https://github.com/apache/superset/blob/2d16100dbcc1d12d4c077b109f80ade53785077e/superset/security/manager.py#L1916

We tested it on our systems with roles assigned and it worked as expected, sorry.

benjamin-mueller avatar Sep 16 '22 08:09 benjamin-mueller

FYI I believe I've hit this issue, and I'm working on a fix for it

villebro avatar Sep 16 '22 09:09 villebro

I can confirm that DASHBOARD_RBAC works on 1.5.1. We want to upgrade to 2.0.1 but fear that it will impact our production users if this is broken in 2.0.0. A fix will be really appreciated.

mdeshmu avatar Sep 22 '22 01:09 mdeshmu

Agreed that there is a gap in user access, we're on 2.0.0, with DASHBOARD_RBAC enabled. Our ideal use case is

  • All users who login get a custom role, something like dashboard_viewer
  • We use dashboard RBAC to grant access to the full dashboard (view dashboard, see underlying datasets, and see filter datasets)
  • We apply RLS rule that limits user based on templated {{ current_username }}

This way all users can login, see the dashboard, but only see rows they are associated with.

The issue now is we are getting the You don't have access to this dashboard - seems like the only workaround is the snippet Benjamin shared, it would not be scalable to add access for the 100+ users through dashboard ownership, sounds like this may have a fix on the way.

The other issue is datasets associated with native filters, when working around the above issue by adding my test user as an owner so it can hit the dashboard I'm getting permission errors on all native filters that utilize datasets NOT used by the dashboard. I believe the root of this is that hitting the dashboard/ID/datasets endpoint only returns chart datasets and not filters.

wulfuric avatar Sep 23 '22 19:09 wulfuric

Hey guys,

I also had the same issue in both versions 1.5.1 and 2.0.0.

BUT after inspecting the code (specifically func raise_for_dashboard_access in branch 2.0 and line 1268) I figured out that you need your dashboards to be Published, but my dashboards were Draft

...
            can_access = (
                is_user_admin()
                or is_owner(dashboard, g.user)
                or (dashboard.published  and has_rbac_access()).   # <<HERE<<: dashboard.published
                or (not dashboard.published and not dashboard.roles)
            )
 ...

If I set the dashboard status to Published everything works like a charm in both v1.5.1 and v2.0.0

I don't know if this solves your issues, but I hope it helps :)

TheofilosBel avatar Dec 07 '22 19:12 TheofilosBel

I have issue with Superset v1.5.0 , I'm unable to Assign Roles for users in Dashboard Properties(Option is not showing). I have enabled DASHBOARD_RBAC=True in config.py Can anyone Help m Roles Option disable e

I`ve same issue here with superset 2.0.0 image

what i`ve done is adding this on config.py

#to Enabling DASHBOARD_RBAC (Role-Based Access Control) in Apache Superset - 2023-01-14
ENABLE_DASHBOARD_RBAC = True

then re inialize superset with superset init

so i open dashboard and make it published and choose edit. show the image above. how can i handle this?

lazuardi21 avatar Jan 14 '23 09:01 lazuardi21

Which version should I use ? Feature flags still not working

vlad-lits avatar Feb 24 '23 14:02 vlad-lits

@lazuardi21

correct way to enable dashboard rbac is to add following to superset_config.py

FEATURE_FLAGS = { "DASHBOARD_RBAC": True }

mdeshmu avatar Feb 24 '23 15:02 mdeshmu

@mdeshmu thank u a lot, it worked

vlad-lits avatar Feb 24 '23 16:02 vlad-lits

Hi @mdeshmu thank u a lot, it worked.

I hope for this issue can be closed since it worked on my local. Thank you!!

lazuardi21 avatar Mar 31 '23 02:03 lazuardi21

@villebro can we close this issue?

mdeshmu avatar Mar 31 '23 04:03 mdeshmu

Please take a look at #23586

villebro avatar Apr 06 '23 09:04 villebro

Hey guys,

I also had the same issue in both versions 1.5.1 and 2.0.0.

BUT after inspecting the code (specifically func raise_for_dashboard_access in branch 2.0 and line 1268) I figured out that you need your dashboards to be Published, but my dashboards were Draft

...
            can_access = (
                is_user_admin()
                or is_owner(dashboard, g.user)
                or (dashboard.published  and has_rbac_access()).   # <<HERE<<: dashboard.published
                or (not dashboard.published and not dashboard.roles)
            )
 ...

If I set the dashboard status to Published everything works like a charm in both v1.5.1 and v2.0.0

I don't know if this solves your issues, but I hope it helps :)

it works for me and my superset verison is 2.1.0. it's interesting the dashboard rbac works on development like run it on PyCharm even though the status is draft, but on live you need to change it to Published.

xiaotiao avatar May 14 '23 04:05 xiaotiao

Hey guys, I also had the same issue in both versions 1.5.1 and 2.0.0. BUT after inspecting the code (specifically func raise_for_dashboard_access in branch 2.0 and line 1268) I figured out that you need your dashboards to be Published, but my dashboards were Draft

...
            can_access = (
                is_user_admin()
                or is_owner(dashboard, g.user)
                or (dashboard.published  and has_rbac_access()).   # <<HERE<<: dashboard.published
                or (not dashboard.published and not dashboard.roles)
            )
 ...

If I set the dashboard status to Published everything works like a charm in both v1.5.1 and v2.0.0 I don't know if this solves your issues, but I hope it helps :)

it works for me and my superset verison is 2.1.0. it's interesting the dashboard rbac works on development like run it on PyCharm even though the status is draft, but on live you need to change it to Published.

May I ask how did you resolve this RBAC issue? After publishing my dashboard, I still don't see the role-based access drop-down menu, mine just looks similar to this using v2.1.0 image

Did you change anything in .py files other than adding FEATURE_FLAGS = {"DASHBOARD_RBAC": True} to superset_config.py?

ProjectsOfMLee avatar Aug 02 '23 22:08 ProjectsOfMLee