-
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
GuestToken and dashboard embed access check failure, causing 403 HTTP responses #30043
Comments
Hey @hao-zhuventures! I'm here to help with your Superset issue. I can assist with bugs, questions, and becoming a contributor. Let's tackle this together while we wait for a human maintainer. I found a similar open issue that might be relevant to your problem: Superset Login Redirect After Guest Token Usage in Angular Iframe. This issue discusses handling guest tokens and preventing redirection to the login page. The suggested solution involves ensuring the guest token is correctly set up and handled, including refreshing the guest token periodically and setting up the guest client properly. To address the specific issue you're encountering with the Here's a potential fix for the issue:
for resource in resources:
if resource["type"] == GuestTokenResourceType.DASHBOARD.value:
# TODO (embedded): remove this check once uuids are rolled out
dashboard = Dashboard.get(str(resource["id"]))
if not dashboard:
embedded = EmbeddedDashboardDAO.find_by_id(str(resource["id"]))
if not embedded:
raise EmbeddedDashboardNotFoundError() By using Additionally, ensure that the guest token contains the necessary claims and is correctly parsed and validated. The Here is the relevant code snippet for reference: def get_guest_user_from_request(self, req: Request) -> Optional[GuestUser]:
raw_token = req.headers.get(
current_app.config["GUEST_TOKEN_HEADER_NAME"]
) or req.form.get("guest_token")
if raw_token is None:
return None
try:
token = self.parse_jwt_guest_token(raw_token)
if token.get("user") is None:
raise ValueError("Guest token does not contain a user claim")
if token.get("resources") is None:
raise ValueError("Guest token does not contain a resources claim")
if token.get("rls_rules") is None:
raise ValueError("Guest token does not contain an rls_rules claim")
if token.get("type") != "guest":
raise ValueError("This is not a guest token.")
except Exception:
logger.warning("Invalid guest token", exc_info=True)
return None
return self.get_guest_user_from_token(cast(GuestToken, token)) Ensure that the guest token includes the By addressing the comparison logic and ensuring the guest token is correctly formed and validated, you should be able to resolve the 403 HTTP response issue. |
attempt to fix it here: #30042 |
Bug description
When security manager tries to use
guest_token
claims (parsed here) to check for dashboard access permissions here, because of the Enum type, incorrect result is returned.How to reproduce the bug
Abbreviated steps as I believe it's root-caused
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7InVzZXJuYW1lIjoiZW1iZWQiLCJmaXJzdF9uYW1lIjoiU3VwZXJzZXQiLCJsYXN0X25hbWUiOiJBZG1pbiJ9LCJyZXNvdXJjZXMiOlt7InR5cGUiOiJkYXNoYm9hcmQiLCJpZCI6IjkifV0sInJsc19ydWxlcyI6W10sImlhdCI6MTcyNDg3NDYxMi4xNTA5OCwiZXhwIjoxNzI0ODc0OTEyLjE1MDk4LCJhdWQiOiJodHRwOi8vc3VwZXJzZXQ6ODA4OC8iLCJ0eXBlIjoiZ3Vlc3QifQ.5YcCi9vqQDGOsh6M2XCzf8R67GkvJl4BBfb4uMwvJug
Screenshots/recordings
No response
Superset version
master / latest-dev
Python version
3.10
Node version
16
Browser
Chrome
Additional context
No response
Checklist
The text was updated successfully, but these errors were encountered: