blob: 9985dd1093e5e7b4d71321310e26b69df281613c [file] [log] [blame]
(window.webpackJsonp=window.webpackJsonp||[]).push([[57],{bpau:function(e,t,n){"use strict";n.r(t),n.d(t,"_frontmatter",(function(){return s})),n.d(t,"default",(function(){return p}));var a=n("k1TG"),r=n("8o2o"),o=(n("q1tI"),n("7ljp")),i=n("hhGP"),s=(n("qKvR"),{});void 0!==s&&s&&s===Object(s)&&Object.isExtensible(s)&&!s.hasOwnProperty("__filemeta")&&Object.defineProperty(s,"__filemeta",{configurable:!0,value:{name:"_frontmatter",filename:"src/pages/docs/installation/configuring.mdx"}});var c={_frontmatter:s},l=i.a;function p(e){var t=e.components,n=Object(r.a)(e,["components"]);return Object(o.b)(l,Object(a.a)({},c,n,{components:t,mdxType:"MDXLayout"}),Object(o.b)("h2",{id:"configuring-superset"},"Configuring Superset"),Object(o.b)("h3",{id:"configuration"},"Configuration"),Object(o.b)("p",null,"To configure your application, you need to create a file ",Object(o.b)("inlineCode",{parentName:"p"},"superset_config.py")," and add it to your\n",Object(o.b)("inlineCode",{parentName:"p"},"PYTHONPATH"),". Here are some of the parameters you can set in that file:"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{}),"# Superset specific config\nROW_LIMIT = 5000\n\nSUPERSET_WEBSERVER_PORT = 8088\n\n# Flask App Builder configuration\n# Your App secret key\nSECRET_KEY = '\\2\\1thisismyscretkey\\1\\2\\e\\y\\y\\h'\n\n# The SQLAlchemy connection string to your database backend\n# This connection defines the path to the database that stores your\n# superset metadata (slices, connections, tables, dashboards, ...).\n# Note that the connection information to connect to the datasources\n# you want to explore are managed directly in the web UI\nSQLALCHEMY_DATABASE_URI = 'sqlite:////path/to/superset.db'\n\n# Flask-WTF flag for CSRF\nWTF_CSRF_ENABLED = True\n# Add endpoints that need to be exempt from CSRF protection\nWTF_CSRF_EXEMPT_LIST = []\n# A CSRF token that expires in 1 year\nWTF_CSRF_TIME_LIMIT = 60 * 60 * 24 * 365\n\n# Set this API key to enable Mapbox visualizations\nMAPBOX_API_KEY = ''\n")),Object(o.b)("p",null,"All the parameters and default values defined in\n",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"https://github.com/apache/superset/blob/master/superset/config.py"}),"https://github.com/apache/superset/blob/master/superset/config.py"),"\ncan be altered in your local ",Object(o.b)("inlineCode",{parentName:"p"},"superset_config.py"),". Administrators will want to read through the file\nto understand what can be configured locally as well as the default values in place."),Object(o.b)("p",null,"Since ",Object(o.b)("inlineCode",{parentName:"p"},"superset_config.py")," acts as a Flask configuration module, it can be used to alter the\nsettings Flask itself, as well as Flask extensions like ",Object(o.b)("inlineCode",{parentName:"p"},"flask-wtf"),", ",Object(o.b)("inlineCode",{parentName:"p"},"flask-cache"),", ",Object(o.b)("inlineCode",{parentName:"p"},"flask-migrate"),",\nand ",Object(o.b)("inlineCode",{parentName:"p"},"flask-appbuilder"),". Flask App Builder, the web framework used by Superset, offers many\nconfiguration settings. Please consult the\n",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"https://flask-appbuilder.readthedocs.org/en/latest/config.html"}),"Flask App Builder Documentation"),"\nfor more information on how to configure it."),Object(o.b)("p",null,"Make sure to change:"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"SQLALCHEMY_DATABASE_URI"),": by default it is stored at ~/.superset/superset.db"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"SECRET_KEY"),": to a long random string")),Object(o.b)("p",null,"If you need to exempt endpoints from CSRF (e.g. if you are running a custom auth postback endpoint),\nyou can add the endpoints to ",Object(o.b)("inlineCode",{parentName:"p"},"WTF_CSRF_EXEMPT_LIST"),":"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{}),"WTF_CSRF_EXEMPT_LIST = [‘’]\n")),Object(o.b)("h3",{id:"running-on-a-wsgi-http-server"},"Running on a WSGI HTTP Server"),Object(o.b)("p",null,"While you can run Superset on NGINX or Apache, we recommend using Gunicorn in async mode. This\nenables impressive concurrency even and is fairly easy to install and configure. Please refer to the\ndocumentation of your preferred technology to set up this Flask WSGI application in a way that works\nwell in your environment. Here’s an async setup known to work well in production:"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{}),' -w 10 \\\n -k gevent \\\n --timeout 120 \\\n -b 0.0.0.0:6666 \\\n --limit-request-line 0 \\\n --limit-request-field_size 0 \\\n --statsd-host localhost:8125 \\\n "superset.app:create_app()"\n')),Object(o.b)("p",null,"Refer to the ",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"https://docs.gunicorn.org/en/stable/design.html"}),"Gunicorn documentation")," for more\ninformation. ",Object(o.b)("em",{parentName:"p"},"Note that the development web server (",Object(o.b)("inlineCode",{parentName:"em"},"superset run")," or ",Object(o.b)("inlineCode",{parentName:"em"},"flask run"),") is not intended\nfor production use.")),Object(o.b)("p",null,"If you're not using Gunicorn, you may want to disable the use of ",Object(o.b)("inlineCode",{parentName:"p"},"flask-compress")," by setting\n",Object(o.b)("inlineCode",{parentName:"p"},"COMPRESS_REGISTER = False")," in your ",Object(o.b)("inlineCode",{parentName:"p"},"superset_config.py"),"."),Object(o.b)("h3",{id:"configuration-behind-a-load-balancer"},"Configuration Behind a Load Balancer"),Object(o.b)("p",null,"If you are running superset behind a load balancer or reverse proxy (e.g. NGINX or ELB on AWS), you\nmay need to utilize a healthcheck endpoint so that your load balancer knows if your superset\ninstance is running. This is provided at ",Object(o.b)("inlineCode",{parentName:"p"},"/health")," which will return a 200 response containing “OK”\nif the the webserver is running."),Object(o.b)("p",null,"If the load balancer is inserting ",Object(o.b)("inlineCode",{parentName:"p"},"X-Forwarded-For/X-Forwarded-Proto")," headers, you should set\n",Object(o.b)("inlineCode",{parentName:"p"},"ENABLE_PROXY_FIX = True")," in the superset config file (",Object(o.b)("inlineCode",{parentName:"p"},"superset_config.py"),") to extract and use the\nheaders."),Object(o.b)("p",null,"In case the reverse proxy is used for providing SSL encryption, an explicit definition of the\n",Object(o.b)("inlineCode",{parentName:"p"},"X-Forwarded-Proto")," may be required. For the Apache webserver this can be set as follows:"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{}),'RequestHeader set X-Forwarded-Proto "https"\n')),Object(o.b)("h3",{id:"custom-oauth2-configuration"},"Custom OAuth2 Configuration"),Object(o.b)("p",null,"Beyond FAB supported providers (Github, Twitter, LinkedIn, Google, Azure, etc), its easy to connect\nSuperset with other OAuth2 Authorization Server implementations that support “code” authorization."),Object(o.b)("p",null,"Make sure the pip package ",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"https://authlib.org/"}),Object(o.b)("inlineCode",{parentName:"a"},"Authlib"))," is installed on the webserver."),Object(o.b)("p",null,"First, configure authorization in Superset ",Object(o.b)("inlineCode",{parentName:"p"},"superset_config.py"),"."),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-python"}),"AUTH_TYPE = AUTH_OAUTH\nOAUTH_PROVIDERS = [\n { 'name':'egaSSO',\n 'token_key':'access_token', # Name of the token in the response of access_token_url\n 'icon':'fa-address-card', # Icon for the provider\n 'remote_app': {\n 'client_id':'myClientId', # Client Id (Identify Superset application)\n 'client_secret':'MySecret', # Secret for this Client Id (Identify Superset application)\n 'client_kwargs':{\n 'scope': 'read' # Scope for the Authorization\n },\n 'access_token_method':'POST', # HTTP Method to call access_token_url\n 'access_token_params':{ # Additional parameters for calls to access_token_url\n 'client_id':'myClientId'\n },\n 'access_token_headers':{ # Additional headers for calls to access_token_url\n 'Authorization': 'Basic Base64EncodedClientIdAndSecret'\n },\n 'api_base_url':'https://myAuthorizationServer/oauth2AuthorizationServer/',\n 'access_token_url':'https://myAuthorizationServer/oauth2AuthorizationServer/token',\n 'authorize_url':'https://myAuthorizationServer/oauth2AuthorizationServer/authorize'\n }\n }\n]\n\n# Will allow user self registration, allowing to create Flask users from Authorized User\nAUTH_USER_REGISTRATION = True\n\n# The default user self registration role\nAUTH_USER_REGISTRATION_ROLE = \"Public\"\n")),Object(o.b)("p",null,"Then, create a ",Object(o.b)("inlineCode",{parentName:"p"},"CustomSsoSecurityManager")," that extends ",Object(o.b)("inlineCode",{parentName:"p"},"SupersetSecurityManager")," and overrides\n",Object(o.b)("inlineCode",{parentName:"p"},"oauth_user_info"),":"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-python"}),"from superset.security import SupersetSecurityManager\n\nclass CustomSsoSecurityManager(SupersetSecurityManager):\n\n def oauth_user_info(self, provider, response=None):\n logging.debug(\"Oauth2 provider: {0}.\".format(provider))\n if provider == 'egaSSO':\n # As example, this line request a GET to base_url + '/' + userDetails with Bearer Authentication,\n # and expects that authorization server checks the token, and response with user details\n me = self.appbuilder.sm.oauth_remotes[provider].get('userDetails').data\n logging.debug(\"user_data: {0}\".format(me))\n return { 'name' : me['name'], 'email' : me['email'], 'id' : me['user_name'], 'username' : me['user_name'], 'first_name':'', 'last_name':''}\n ...\n")),Object(o.b)("p",null,"This file must be located at the same directory than ",Object(o.b)("inlineCode",{parentName:"p"},"superset_config.py")," with the name\n",Object(o.b)("inlineCode",{parentName:"p"},"custom_sso_security_manager.py"),". Finally, add the following 2 lines to ",Object(o.b)("inlineCode",{parentName:"p"},"superset_config.py"),":"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{}),"from custom_sso_security_manager import CustomSsoSecurityManager\nCUSTOM_SECURITY_MANAGER = CustomSsoSecurityManager\n")),Object(o.b)("p",null,Object(o.b)("strong",{parentName:"p"},"Notes")),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("p",{parentName:"li"},"The redirect URL will be ",Object(o.b)("inlineCode",{parentName:"p"},"https://<superset-webserver>/oauth-authorized/<provider-name>"),"\nWhen configuring an OAuth2 authorization provider if needed. For instance, the redirect URL will\nbe ",Object(o.b)("inlineCode",{parentName:"p"},"https://<superset-webserver>/oauth-authorized/egaSSO")," for the above configuration.")),Object(o.b)("li",{parentName:"ul"},Object(o.b)("p",{parentName:"li"},"If an OAuth2 authorization server supports OpenID Connect 1.0, you could configure its configuration\ndocument URL only without providing ",Object(o.b)("inlineCode",{parentName:"p"},"api_base_url"),", ",Object(o.b)("inlineCode",{parentName:"p"},"access_token_url"),", ",Object(o.b)("inlineCode",{parentName:"p"},"authorize_url")," and other\nrequired options like user info endpoint, jwks uri etc. For instance:"),Object(o.b)("pre",{parentName:"li"},Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-python"}),"OAUTH_PROVIDERS = [\n { 'name':'egaSSO',\n 'token_key':'access_token', # Name of the token in the response of access_token_url\n 'icon':'fa-address-card', # Icon for the provider\n 'remote_app': {\n 'client_id':'myClientId', # Client Id (Identify Superset application)\n 'client_secret':'MySecret', # Secret for this Client Id (Identify Superset application)\n 'server_metadata_url': 'https://myAuthorizationServer/.well-known/openid-configuration'\n }\n }\n]\n")))),Object(o.b)("h3",{id:"feature-flags"},"Feature Flags"),Object(o.b)("p",null,"To support a diverse set of users, Superset has some features that are not enabled by default. For\nexample, some users have stronger security restrictions, while some others may not. So Superset\nallow users to enable or disable some features by config. For feature owners, you can add optional\nfunctionalities in Superset, but will be only affected by a subset of users."),Object(o.b)("p",null,"You can enable or disable features with flag from ",Object(o.b)("inlineCode",{parentName:"p"},"superset_config.py"),":"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-python"}),"FEATURE_FLAGS = {\n 'CLIENT_CACHE': False,\n 'ENABLE_EXPLORE_JSON_CSRF_PROTECTION': False,\n 'PRESTO_EXPAND_DATA': False,\n}\n")),Object(o.b)("p",null,"A current list of feature flags can be found in ",Object(o.b)("inlineCode",{parentName:"p"},"RESOURCES/FEATURE_FLAGS.md")),Object(o.b)("h3",{id:"sip-15"},"SIP 15"),Object(o.b)("p",null,Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"https://github.com/apache/superset/issues/6360"}),"Superset Improvement Proposal 15")," aims to\nensure that time intervals are handled in a consistent and transparent manner for both the Druid and\nSQLAlchemy connectors."),Object(o.b)("p",null,"Prior to SIP-15 SQLAlchemy used inclusive endpoints however these may behave like exclusive for\nstring columns (due to lexicographical ordering) if no formatting was defined and the column\nformatting did not conform to an ISO 8601 date-time (refer to the SIP for details)."),Object(o.b)("p",null,"To remedy this rather than having to define the date/time format for every non-IS0 8601 date-time\ncolumn, once can define a default column mapping on a per database level via the ",Object(o.b)("inlineCode",{parentName:"p"},"extra")," parameter:"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{}),'{\n "python_date_format_by_column_name": {\n "ds": "%Y-%m-%d"\n }\n}\n')),Object(o.b)("p",null,Object(o.b)("strong",{parentName:"p"},"New Deployments")),Object(o.b)("p",null,"All new deployments should enable SIP-15 by setting this value in ",Object(o.b)("inlineCode",{parentName:"p"},"superset_config.py"),":"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{}),"SIP_15_ENABLED = True\n\n")),Object(o.b)("p",null,Object(o.b)("strong",{parentName:"p"},"Existing Deployments")),Object(o.b)("p",null,"Given that it is not apparent whether the chart creator was aware of the time range inconsistencies\n(and adjusted the endpoints accordingly) changing the behavior of all charts is overly aggressive.\nInstead SIP-15 proivides a soft transistion allowing producers (chart owners) to see the impact of\nthe proposed change and adjust their charts accordingly."),Object(o.b)("p",null,"Prior to enabling SIP-15, existing deployments should communicate to their users the impact of the\nchange and define a grace period end date (exclusive of course) after which all charts will conform\nto the [start, end) interval."),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-python"}),"from dateime import date\n\nSIP_15_ENABLED = True\nSIP_15_GRACE_PERIOD_END = date(<YYYY>, <MM>, <DD>)\n")),Object(o.b)("p",null,"To aid with transparency the current endpoint behavior is explicitly called out in the chart time\nrange (post SIP-15 this will be [start, end) for all connectors and databases). One can override the\ndefaults on a per database level via the ",Object(o.b)("inlineCode",{parentName:"p"},"extra")," parameter."),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-python"}),'{\n "time_range_endpoints": ["inclusive", "inclusive"]\n}\n')),Object(o.b)("p",null,"Note in a future release the interim SIP-15 logic will be removed (including the\n",Object(o.b)("inlineCode",{parentName:"p"},"time_grain_endpoints")," form-data field) via a code change and Alembic migration."))}void 0!==p&&p&&p===Object(p)&&Object.isExtensible(p)&&!p.hasOwnProperty("__filemeta")&&Object.defineProperty(p,"__filemeta",{configurable:!0,value:{name:"MDXContent",filename:"src/pages/docs/installation/configuring.mdx"}}),p.isMDXComponent=!0}}]);
//# sourceMappingURL=component---src-pages-docs-installation-configuring-mdx-6fa75297e4083961df03.js.map