Skip to content
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

feat(embedded): enforce allow domains #20251

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion superset/embedded/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
import json
from typing import Callable

from flask import abort
from flask import abort, request
from flask_appbuilder import expose
from flask_login import AnonymousUserMixin, LoginManager
from flask_wtf.csrf import same_origin

from superset import event_logger, is_feature_enabled, security_manager
from superset.embedded.dao import EmbeddedDAO
Expand Down Expand Up @@ -50,9 +51,20 @@ def embedded(
abort(404)

embedded = EmbeddedDAO.find_by_id(uuid)

if not embedded:
abort(404)

# validate request referrer in allowed domains
is_referrer_allowed = not embedded.allowed_domains
for domain in embedded.allowed_domains:
if same_origin(request.referrer, domain):
is_referrer_allowed = True
break

if not is_referrer_allowed:
abort(403)

# Log in as an anonymous user, just for this view.
# This view needs to be visible to all users,
# and building the page fails if g.user and/or ctx.user aren't present.
Expand Down