You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by gr...@apache.org on 2020/11/19 22:04:23 UTC
[incubator-superset] 01/01: use firefox proxy
This is an automated email from the ASF dual-hosted git repository.
graceguo pushed a commit to branch test-email-profile
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
commit 9889a991e22b865a6498c590fb571aa054b2a7a5
Author: Grace <gr...@airbnb.com>
AuthorDate: Fri Nov 13 21:49:08 2020 -0800
use firefox proxy
---
setup.cfg | 2 +-
superset/utils/machine_auth.py | 29 +++++++++++++++++++++++++++++
superset/views/core.py | 1 +
3 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/setup.cfg b/setup.cfg
index 44f7e0d..eaf0844 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -30,7 +30,7 @@ combine_as_imports = true
include_trailing_comma = true
line_length = 88
known_first_party = superset
-known_third_party =alembic,apispec,backoff,bleach,cachelib,celery,click,colorama,contextlib2,croniter,cryptography,dateutil,flask,flask_appbuilder,flask_babel,flask_caching,flask_compress,flask_login,flask_migrate,flask_sqlalchemy,flask_talisman,flask_testing,flask_wtf,freezegun,geohash,geopy,humanize,isodate,jinja2,markdown,markupsafe,marshmallow,msgpack,numpy,pandas,parameterized,parsedatetime,pathlib2,polyline,prison,pyarrow,pyhive,pytest,pytz,retry,selenium,setuptools,simplejson,slac [...]
+known_third_party =alembic,apispec,backoff,bleach,cachelib,celery,click,colorama,contextlib2,croniter,cryptography,dateutil,flask,flask_appbuilder,flask_babel,flask_caching,flask_compress,flask_login,flask_migrate,flask_sqlalchemy,flask_talisman,flask_testing,flask_wtf,freezegun,geohash,geopy,humanize,isodate,jinja2,markdown,markupsafe,marshmallow,msgpack,numpy,pandas,parameterized,parsedatetime,pathlib2,polyline,prison,pyarrow,pyhive,pytest,pytz,requests,retry,selenium,setuptools,simple [...]
multi_line_output = 3
order_by_type = false
diff --git a/superset/utils/machine_auth.py b/superset/utils/machine_auth.py
index 778f2a6..f4e49dc 100644
--- a/superset/utils/machine_auth.py
+++ b/superset/utils/machine_auth.py
@@ -17,11 +17,18 @@
import importlib
import logging
+from tempfile import NamedTemporaryFile
from typing import Callable, Dict, TYPE_CHECKING
+from urllib.parse import urlparse
+import requests
from flask import current_app, Flask, request, Response, session
from flask_login import login_user
+from selenium import webdriver
+from selenium.webdriver import FirefoxOptions
from selenium.webdriver.remote.webdriver import WebDriver
+from selenium.webdriver.support import expected_conditions as EC
+from selenium.webdriver.support.ui import WebDriverWait
from werkzeug.http import parse_cookie
from superset.utils.urls import headless_url
@@ -49,8 +56,29 @@ class MachineAuthProvider:
if self._auth_webdriver_func_override:
return self._auth_webdriver_func_override(driver, user)
+ print("\n\n i am user:{}".format(user))
+ with NamedTemporaryFile() as file:
+ file.write(
+ requests.get(
+ "https://github.com/bewisse/modheader_selenium/blob/master/firefox-modheader/modheader.xpi?raw=true"
+ ).content
+ )
+
+ driver.install_addon(file.name)
+
+ print("\n\n setting header \n\n")
+ driver.get(
+ "https://webdriver.bewisse.com/add?X-Internalauth-Username=svc_di_analytics_products"
+ )
+ WebDriverWait(driver, 10).until(EC.title_is("Done"))
+ print("\n\n installed")
+
# Setting cookies requires doing a request first
driver.get(headless_url("/login/"))
+ driver.find_element_by_tag_name("button").click()
+
+ print("\n\n i am url:{}\n\n".format(driver.current_url))
+ print("\n\n i am page source:{}".format(driver.page_source))
if user:
cookies = self.get_auth_cookies(user)
@@ -59,6 +87,7 @@ class MachineAuthProvider:
else:
cookies = {}
+ print(f"\n\n i am cookies:{cookies}")
for cookie_name, cookie_val in cookies.items():
driver.add_cookie(dict(name=cookie_name, value=cookie_val))
diff --git a/superset/views/core.py b/superset/views/core.py
index 97eef1f..9c8fd8c 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -1669,6 +1669,7 @@ class Superset(BaseSupersetView): # pylint: disable=too-many-public-methods
# set a default value to appease pylint
update_log_payload: Callable[..., None] = lambda **kwargs: None,
) -> FlaskResponse:
+ print(f"\n\n got headers: {request.headers}\n\n")
"""Server side rendering for a dashboard"""
session = db.session()
qry = session.query(Dashboard)