You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "charlymarchiaro (via GitHub)" <gi...@apache.org> on 2025/12/12 22:21:46 UTC
[I] Embedding fails because GuestUser is never active [superset]
charlymarchiaro opened a new issue, #36598:
URL: https://github.com/apache/superset/issues/36598
### Bug description
When dashboards are embedded, api calls to the following endpoints fail with `Forbidden (403)` error.
- api/v1/dashboard/{id_or_slug}
- api/v1/dashboard/{id_or_slug}/charts
- api/v1/dashboard/{id_or_slug}/datasets
After discarding all the typical misconfiguration errors, I noticed that the issue seems to originate in the fact that the `GuestUser` instance's property `is_active` always returns `False`.
Even when the `GuestUser` class has an `active` attribute always set to `True`:
```
# guest_token.py
# --------------------------------------------------
class GuestUser(AnonymousUserMixin):
"""
Used as the "anonymous" user in case of guest authentication (embedded)
"""
is_guest_user = True
>> active = True
@property
def is_authenticated(self) -> bool:
"""
This is set to true because guest users should be considered authenticated,
at least in most places. The treatment of this flag is kind of inconsistent.
"""
return True
@property
def is_anonymous(self) -> bool:
"""
This is set to false because lots of code assumes that
if user.is_anonymous, then role = Public
But guest users need to have their own role independent of Public.
"""
return False
def __init__(self, token: GuestToken, roles: list[Role]):
user = token["user"]
self.guest_token = token
self.username = user.get("username", "guest_user")
self.first_name = user.get("first_name", "Guest")
self.last_name = user.get("last_name", "User")
self.roles = roles
self.groups: list[Group] = [] # Guest users don't belong to any groups
self.resources = token["resources"]
self.rls = token.get("rls_rules", [])
```
The problem is that it inherits the `is_active` property from `AnonymousUserMixin`, which is always set to `False`:
```
# flask_login.mixins.py
# --------------------------------------------------
class AnonymousUserMixin:
"""
This is the default object for representing an anonymous user.
"""
@property
def is_authenticated(self):
return False
>> @property
>> def is_active(self):
>> return False
@property
def is_anonymous(self):
return True
def get_id(self):
return
```
After overriding the inherited `is_active` logic so that it returns `True`, the dashboards are embedded correctly.
### Screenshots/recordings
_No response_
### Superset version
master / latest-dev
### Python version
3.11
### Node version
18 or greater
### Browser
Chrome
### Additional context
_No response_
### Checklist
- [x] I have searched Superset docs and Slack and didn't find a solution to my problem.
- [x] I have searched the GitHub issue tracker and didn't find a similar bug report.
- [x] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
--
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.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: [I] Embedding fails because GuestUser is never active [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on issue #36598:
URL: https://github.com/apache/superset/issues/36598#issuecomment-4898883626
Closing as fixed: PR #36716 ('fix: Use is_active for guest users') merged 2025-12-17, and master's superset/security/guest_token.py line 169 sets 'active = is_active = True'. Commenters already pointed at the fix, and the reporter confirmed his workaround predates it.
--
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: [I] Embedding fails because GuestUser is never active [superset]
Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
dosubot[bot] commented on issue #36598:
URL: https://github.com/apache/superset/issues/36598#issuecomment-3648361796
<!-- Greeting -->
Hi @charlymarchiaro! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the superset team.
<!-- Answer -->
You're right—embedding fails because the GuestUser class inherits is_active from AnonymousUserMixin, which always returns False. Flask-Login treats users with is_active=False as inactive, so API calls for embedded dashboards get a 403 error. Overriding is_active in GuestUser to return True fixes this, letting Flask-Login treat the guest as an active, authenticated user and allowing embedding to work as expected. This change is safe: access control is still enforced by the roles and resources in the guest token, so it doesn't grant extra permissions beyond what's intended. There isn't any official documentation or prior issue about this, so overriding is_active in GuestUser is the recommended workaround for now.
Reference: [GuestUser implementation](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/security/guest_token.py#L56-L90), [SupersetSecurityManager logic](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/security/manager.py#L48-L2790).
<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*
---
<sup>How did I do? [Good](https://app.dosu.dev/response-feedback/3143484c-8c6c-4fdd-a8f3-93437024228c?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/3143484c-8c6c-4fdd-a8f3-93437024228c?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/3143484c-8c6c-4fdd-a8f3-93437024228c?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/3143484c-8c6c-4fdd-a8f3-93437024228c?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/3143484c-8c6c-4fdd-a8f3-93437024228c?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/3143484c-8c6c-4fdd-a8f3-93437024228c?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/3143484c-8c6c-4fdd-a8f3-93437024228c?feedback_type=other)</sup>
[](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github) [](https://cursor.com/link/prompt?text=You%27re%20right%E2%80%94embedding%20fails%20because%20the%20GuestUser%20class%20inherits%20is_active%20from%20AnonymousUserMixin%2C%20which%20always%20returns%20False.%20Flask-Login%20treats%20users%20with%20is_active%3DFalse%20as%20inactive%2C%20so%20API%20calls%20for%20embedded%20dashboards%20get%20a%20403%20error.%20Overriding%20is_active%20in%20GuestUser%20to%20return%20True%20fixes%20this%2C%20letting%20Flask-Login%20treat%20the%20guest%20as%20an%20active%2C%20authenticated%20user%20and%20allowing%20embedding%20to%20work%20as%20expected.%20This%20change%20is%20safe%3A%20access%20control%20is%20still%20enforced%20by%20the%20roles%20and%20resources%20in%20the%20guest%20token%2C%20so%20it%20doesn%27t%20grant%20extra%20permissions%20beyond%20what
%27s%20intended.%20There%20isn%27t%20any%20official%20documentation%20or%20prior%20issue%20about%20this%2C%20so%20overriding%20is_active%20in%20GuestUser%20is%20the%20recommended%20workaround%20for%20now.%20%0A%0AReference%3A%20%5BGuestUser%20implementation%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/security/guest_token.py%23L56-L90%29%2C%20%5BSupersetSecurityManager%20logic%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/security/manager.py%23L48-L2790%29.) [](https://go.dosu.dev/discord-bot) [](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/issues/36598)
--
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: [I] Embedding fails because GuestUser is never active [superset]
Posted by "ppetruneac (via GitHub)" <gi...@apache.org>.
ppetruneac commented on issue #36598:
URL: https://github.com/apache/superset/issues/36598#issuecomment-3881188452
@charlymarchiaro this appeared to have been fixed in this PR https://github.com/apache/superset/pull/36716 - have you tested ?
--
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: [I] Embedding fails because GuestUser is never active [superset]
Posted by "charlymarchiaro (via GitHub)" <gi...@apache.org>.
charlymarchiaro commented on issue #36598:
URL: https://github.com/apache/superset/issues/36598#issuecomment-3881231124
Hi, thank you. Actually, I hadn't noticed this PR, it was created a couple of days after this issue.
I fixed it extending the default `SupersetSecurityManager` directly in the Helm chart:
```python
# Workaround for issue: https://github.com/apache/superset/issues/36598
class GuestUser2(GuestUser):
def __init__(self, user: GuestUser):
self.is_guest_user = user.is_guest_user
self.active = user.active
self.guest_token = user.guest_token
self.username = user.username
self.first_name = user.first_name
self.last_name = user.last_name
self.roles = user.roles
self.groups = user.groups
self.resources = user.resources
self.rls = user.rls
@property
def is_active(self):
return True
class CustomSsoSecurityManager(SupersetSecurityManager):
# [...]
def get_guest_user_from_token(self, token: GuestToken) -> GuestUser:
user = self.guest_user_cls(
token=token,
roles=[self.find_role(get_conf()["GUEST_ROLE_NAME"])],
)
# Workaround for issue: https://github.com/apache/superset/issues/36598
return GuestUser2(user)
```
I will test it soon, thanks.
--
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: [I] Embedding fails because GuestUser is never active [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas closed issue #36598: Embedding fails because GuestUser is never active
URL: https://github.com/apache/superset/issues/36598
--
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