You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "sfirke (via GitHub)" <gi...@apache.org> on 2024/09/24 20:44:20 UTC
[PR] feat(auth): when user is not logged in, failure to access a dashboard will redirect to login screen [superset]
sfirke opened a new pull request, #30380:
URL: https://github.com/apache/superset/pull/30380
### SUMMARY
If a viewer is not logged in, or they are the public/anonymous user, and they click a link that takes them to a Superset dashboard that is _not_ public, they are currently told "You don't have access" and sent to the list of dashboards, where they will see only public ones listed. This is often misleading: in most cases, the problem is not that they don't have access -- they just need to log in.
After the PR, such cases are routed to the login screen, and after a successful login the users are sent back to the dashboard they were trying to access.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
**BEFORE**
https://github.com/user-attachments/assets/053bbf0e-a2f5-4e2b-8498-47694ff213a6
**AFTER**
https://github.com/user-attachments/assets/fc78d404-0d63-4512-9ec4-c1e813b7a66b (ignore that it says "current" at the beginning)
### TESTING INSTRUCTIONS
Create a dashboard with restricted access, try to view it while not logged in.
### ADDITIONAL INFORMATION
Implements this feature request: https://github.com/apache/superset/discussions/22190
Replaces this stale PR: https://github.com/apache/superset/pull/23280
I have the DASHBOARD_RBAC flag enabled as well as the Public role in use. My code alterations are minimal so I don't think it will negatively affect deployments that differ from mine, but it would be good to have someone check.
I'm not sure how to write tests for this but am open to it if someone can advise.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(auth): when user is not logged in, failure to access a dashboard should redirect to login screen [superset]
Posted by "Ishankoradia (via GitHub)" <gi...@apache.org>.
Ishankoradia commented on PR #30380:
URL: https://github.com/apache/superset/pull/30380#issuecomment-3387807607
@sfirke i have a public dashboard and its redirecting users to `/login` page even when the dashboard is tagged with a `Public` role.
Does this PR handle this case too ?
I am using oauth with superset 4.1.1
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(auth): when user is not logged in, failure to access a dashboard should redirect to login screen [superset]
Posted by "villebro (via GitHub)" <gi...@apache.org>.
villebro commented on code in PR #30380:
URL: https://github.com/apache/superset/pull/30380#discussion_r1775760734
##########
superset/views/core.py:
##########
@@ -792,9 +792,16 @@ def dashboard(
try:
dashboard.raise_for_access()
except SupersetSecurityException as ex:
+ # anonymous users should get the login screen, others should go to dashboard list
+ if g.user is None or g.user.is_anonymous:
+ redirect_url = f"{appbuilder.get_url_for_login}?next={request.url}"
Review Comment:
Great, nice finishing touch to this! 👍
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(auth): when user is not logged in, failure to access a dashboard should redirect to login screen [superset]
Posted by "Ishankoradia (via GitHub)" <gi...@apache.org>.
Ishankoradia commented on PR #30380:
URL: https://github.com/apache/superset/pull/30380#issuecomment-3393141735
Ahh gotcha !!! thank you so much @sfirke
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(auth): when user is not logged in, failure to access a dashboard should redirect to login screen [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #30380:
URL: https://github.com/apache/superset/pull/30380#issuecomment-2372362203
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/30380?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
Attention: Patch coverage is `0%` with `2 lines` in your changes missing coverage. Please review.
> Project coverage is 65.32%. Comparing base [(`76d897e`)](https://app.codecov.io/gh/apache/superset/commit/76d897eaa2f9e137102bc194c2e3109c29d0348f?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`fe51be4`)](https://app.codecov.io/gh/apache/superset/commit/fe51be4ae71fd71386e7e80dfe9e42a07fa46820?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
> Report is 770 commits behind head on master.
| [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/30380?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [superset/views/core.py](https://app.codecov.io/gh/apache/superset/pull/30380?src=pr&el=tree&filepath=superset%2Fviews%2Fcore.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvdmlld3MvY29yZS5weQ==) | 0.00% | [2 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/30380?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #30380 +/- ##
==========================================
+ Coverage 60.48% 65.32% +4.83%
==========================================
Files 1931 533 -1398
Lines 76236 38521 -37715
Branches 8568 0 -8568
==========================================
- Hits 46114 25165 -20949
+ Misses 28017 13356 -14661
+ Partials 2105 0 -2105
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/30380/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [hive](https://app.codecov.io/gh/apache/superset/pull/30380/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `48.99% <0.00%> (-0.17%)` | :arrow_down: |
| [javascript](https://app.codecov.io/gh/apache/superset/pull/30380/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [presto](https://app.codecov.io/gh/apache/superset/pull/30380/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `53.49% <0.00%> (-0.31%)` | :arrow_down: |
| [python](https://app.codecov.io/gh/apache/superset/pull/30380/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `65.32% <0.00%> (+1.84%)` | :arrow_up: |
| [unit](https://app.codecov.io/gh/apache/superset/pull/30380/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `60.65% <0.00%> (+3.02%)` | :arrow_up: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/superset/pull/30380?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(auth): when user is not logged in, failure to access a dashboard should redirect to login screen [superset]
Posted by "sfirke (via GitHub)" <gi...@apache.org>.
sfirke merged PR #30380:
URL: https://github.com/apache/superset/pull/30380
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(auth): when user is not logged in, failure to access a dashboard should redirect to login screen [superset]
Posted by "sfirke (via GitHub)" <gi...@apache.org>.
sfirke commented on PR #30380:
URL: https://github.com/apache/superset/pull/30380#issuecomment-3387865778
I will look at my config tomorrow but try enabling the DASHBOARD_RBAC feature flag if that works for your security model.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(auth): when user is not logged in, failure to access a dashboard should redirect to login screen [superset]
Posted by "villebro (via GitHub)" <gi...@apache.org>.
villebro commented on code in PR #30380:
URL: https://github.com/apache/superset/pull/30380#discussion_r1775679064
##########
superset/views/core.py:
##########
@@ -792,9 +792,16 @@ def dashboard(
try:
dashboard.raise_for_access()
except SupersetSecurityException as ex:
+ # anonymous users should get the login screen, others should go to dashboard list
+ if g.user is None or g.user.is_anonymous:
+ redirect_url = f"{appbuilder.get_url_for_login}?next={request.url}"
Review Comment:
Does the `next=` url param work here, i.e. does it redirect you to the dashboard after you authenticate successfully?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(auth): when user is not logged in, failure to access a dashboard should redirect to login screen [superset]
Posted by "sfirke (via GitHub)" <gi...@apache.org>.
sfirke commented on code in PR #30380:
URL: https://github.com/apache/superset/pull/30380#discussion_r1775758533
##########
superset/views/core.py:
##########
@@ -792,9 +792,16 @@ def dashboard(
try:
dashboard.raise_for_access()
except SupersetSecurityException as ex:
+ # anonymous users should get the login screen, others should go to dashboard list
+ if g.user is None or g.user.is_anonymous:
+ redirect_url = f"{appbuilder.get_url_for_login}?next={request.url}"
Review Comment:
It does!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(auth): when user is not logged in, failure to access a dashboard should redirect to login screen [superset]
Posted by "sfirke (via GitHub)" <gi...@apache.org>.
sfirke commented on PR #30380:
URL: https://github.com/apache/superset/pull/30380#issuecomment-3391244994
I don't have `PUBLIC_ROLE_LIKE` in my config. Instead I define a Public role in the Superset UI, using a permissions list from https://github.com/apache/superset/discussions/25938#discussioncomment-7526594.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(auth): when user is not logged in, failure to access a dashboard should redirect to login screen [superset]
Posted by "sfirke (via GitHub)" <gi...@apache.org>.
sfirke commented on PR #30380:
URL: https://github.com/apache/superset/pull/30380#issuecomment-3387815018
@Ishankoradia two things:
1) I think you may need to configure something differently. In 4.1.1 I am able to have both OAuth and public dashboards. Maybe something missing about how you set it public.
2) this PR's functionality has since been unintentionally broken by other changes. I have PR #35345 open to re-add this functionality to Superset, hopefully for v6.0.0.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(auth): when user is not logged in, failure to access a dashboard should redirect to login screen [superset]
Posted by "Ishankoradia (via GitHub)" <gi...@apache.org>.
Ishankoradia commented on PR #30380:
URL: https://github.com/apache/superset/pull/30380#issuecomment-3387832398
Thanks @sfirke for the really quick response.
I will check my configuration again but correct me if I am wrong. Two important things to allow dashboards to he viewed publicly (without authentication)
1. Attach a `Public` role to that dashboard
2. Set `PUBLIC_ROLE_LIKE=Gamma`
Am I missing something ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org