{"id":24072731,"url":"https://github.com/onaio/superset-patchup","last_synced_at":"2026-03-03T03:05:11.387Z","repository":{"id":34377987,"uuid":"169545397","full_name":"onaio/superset-patchup","owner":"onaio","description":"Superset-patchup is a python package that \"patches\" Superset to add custom functionality that we find to be useful","archived":false,"fork":false,"pushed_at":"2023-09-06T07:27:51.000Z","size":192,"stargazers_count":10,"open_issues_count":11,"forks_count":7,"subscribers_count":31,"default_branch":"main","last_synced_at":"2025-04-28T15:09:49.149Z","etag":null,"topics":["data-visualization","superset"],"latest_commit_sha":null,"homepage":"https://canopyinsights.com","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/onaio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-02-07T09:12:21.000Z","updated_at":"2025-03-14T19:10:42.000Z","dependencies_parsed_at":"2025-04-28T15:09:57.163Z","dependency_job_id":null,"html_url":"https://github.com/onaio/superset-patchup","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onaio%2Fsuperset-patchup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onaio%2Fsuperset-patchup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onaio%2Fsuperset-patchup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onaio%2Fsuperset-patchup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/onaio","download_url":"https://codeload.github.com/onaio/superset-patchup/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251336387,"owners_count":21573188,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-visualization","superset"],"created_at":"2025-01-09T17:20:16.502Z","updated_at":"2026-03-03T03:05:11.360Z","avatar_url":"https://github.com/onaio.png","language":"Python","readme":"# superset-patchup (Ketchup)\n\nSuperset-patchup is a python package that \"patches\" [Superset](https://superset.incubator.apache.org/) to add custom functionality that we find to be useful.\n\n## How it works\n\nSuperset-patchup is meant to be installed alongside Superset.\n\nThis can be done this way:\n\n```sh\n# to install version 0.1.0\npip install git+https://github.com/onaio/superset-patchup.git@v0.1.0\n```\n\nOnce installed, you would need to modify the `superset_config.py` to configure Superset using Superset-patchup.\n\n## Features\n\nCurrently Superset-patchup adds a CustomSecurityManager class that holds all of its functionality.  This CustomSecurityManager class also uses a custom AuthOAuthView class.\n\n### Allow access to superset using oAuth access tokens\n\nThis functionality is provided by the custom AuthOAuthView introduced by Superset-patchup.  It primarily allows you to access most Superset API endpoints using an oAuth access token.\n\nTo configure this, you would add the following to your `superset_config.py` file:\n\n```python\n# superset_config.py\nfrom flask_appbuilder.security.manager import AUTH_OAUTH\n\nfrom superset_patchup.oauth import CustomSecurityManager\n\n\n# standard Superset oAuth settings go here\nAUTH_TYPE = AUTH_OAUTH\nOAUTH_PROVIDERS = [\n{\n    'name': 'onadata',\n    'icon': 'fa-rebel',\n    'token_key': 'access_token',\n    'remote_app': {\n        'client_id': 'consumer key goes here',\n        'client_secret': 'consumer secret goes here',\n        'api_base_url': 'https://stage-api.ona.io/',\n        'access_token_url': 'https://stage-api.ona.io/o/token/',\n        'authorize_url': 'https://stage-api.ona.io/o/authorize/'\n    }\n}\n]\n# end of standard Superset oAuth settings\nCUSTOM_SECURITY_MANAGER = CustomSecurityManager\n```\n\n### Custom redirect url after oAuth sign in\n\nThis functionality is provided by the custom AuthOAuthView introduced by Superset-patchup.  It allows you to set a custom redirect url that the user will be sent to after they sign in using oAuth.\n\nTo configure this, you would add the following to your `superset_config.py` file:\n\n```python\n# superset_config.py\nfrom flask_appbuilder.security.manager import AUTH_OAUTH\n\nfrom superset_patchup.oauth import CustomSecurityManager\n\n\n# standard Superset oAuth settings go here\nAUTH_TYPE = AUTH_OAUTH\nOAUTH_PROVIDERS = [\n{\n    'name': 'onadata',\n    'icon': 'fa-eercast',\n        'token_key': 'access_token',\n        'remote_app': {\n            'client_id': 'consumer key goes here',\n            'client_secret': 'consumer secret goes here'\n            'api_base_url': 'https://stage-api.ona.io/',\n            'access_token_url': 'https://stage-api.ona.io/o/token/',\n            'authorize_url': 'https://stage-api.ona.io/o/authorize/',\n            # the redirect url is set below, it needs to be on the same domain as superset\n            'custom_redirect_url': 'https://example.com/superset/sqllab'\n        }\n}\n]\n# end of standard Superset oAuth settings\nCUSTOM_SECURITY_MANAGER = CustomSecurityManager\n```\n\nAs an alternative, you can also simply add a redirect variable to the url so as to redirect after logging in. This can be added as below\n\n```\n'https://example.com/login/provider?redirect=/superset/dashboard/3/'\n```\n\n### Add custom roles\n\nThis feature allows you to add custom roles to Superset on initialization.  This is useful when you want to add custom roles to Superset during an automated deployment.\n\nTo configure this, you would add the following to your `superset_config.py` file:\n\n```python\n# superset_config.py\nfrom superset_patchup.oauth import CustomSecurityManager\n\n\nCUSTOM_SECURITY_MANAGER = CustomSecurityManager\nADD_CUSTOM_ROLES = True\nCUSTOM_ROLES = {\n  'Custom_Role_1': {'all_datasource_access'},\n  'Custom_Role_2': {'all_datasource_access', 'SQL Lab'}\n}\n```\n\n### Custom oAuth user info methods\n\nKetchup's CustomSecurityManager class includes a custom `oauth_user_info` method that correctly sets user information when a user authenticates with Superset using any of the following oAuth providers:\n\n- `onadata`\n- `openlmis`\n- `OpenSRP`\n\n### Custom oAuth init endpoint\n\nOne of the ideas of integration Superset with an external service (eg. OpenLMIS) is to allow running the application and sign-in directly from the external application's API. To simplify the whole process, Ketchup provides the endpoint `/oauth-init/\u003cprovider\u003e`. It is a backend functionality that essentially does what the endpoint `/login/\u003cprovider\u003e` does, however it doesn't redirect a client. Instead of it, it returns information in the JSON form which contains the following fields:\n\n- `isAuthorized` - the flag which provides information about user's authorization in the app\n- `state` - oAuth state which is required during the oAuth sign-in process. It is provided only if `isAuthorized` is false\n\n#### PATCHUP_EMAIL_BASE\n\nIn cases where an oAuth provider does not provide an email address for its users, Superset's oAuth process might fail.  To remedy this, Superset-patchup you can set the `PATCHUP_EMAIL_BASE` variable in `superset_config.py`.\n\nWhen this is set, Superset-patchup will try to generate sensible email address for each authenticated user, like so:\n\n```python\n# superset_config.py\nPATCHUP_EMAIL_BASE = \"ketchup@example.com\"\n```\n\nWith this in place, Superset-patchup will assign each user an email in the form of `ketchup+USERNAME@example.com`.  So, for example, if a user named `bobbie` signed in, his email would be set as `ketchup+bobbie@example.com`.\n\n### Dashboards list endpoint\nThere are cases where you simply want a list of all the dashboards that are available to a user. This could be to display in a separate website or to help in making some other decision like for example what permissions to grant a user, or what tasks can be assigned to a user based on what dashboards they have access to. With the SupersetKetchupApiView, ketchup exposes a new endpoint `all_dashboards` which uses superset's DashboardAccessFilter to return a list of all the dashboards that the user has access to.\n\nTo get the dashboard list you would need to make a `GET` request to `/superset-ketchup/api/all_dashboards/` and the response will be something like\n\n```json\n[\n    {\n        \"id\": 1,\n        \"dashboard_link\": \"\u003ca href=\\\"/superset/dashboard/world_health/\\\"\u003eWorld\u0026#39;s Bank Data\u003c/a\u003e\",\n        \"dashboard_title\": \"World's Bank Data\",\n        \"url\": \"/superset/dashboard/world_health/\"\n    },\n    {\n        \"id\": 2,\n        \"dashboard_link\": \"\u003ca href=\\\"/superset/dashboard/births/\\\"\u003eBirths\u003c/a\u003e\",\n        \"dashboard_title\": \"Births\",\n        \"url\": \"/superset/dashboard/births/\"\n    },\n    {\n        \"id\": 3,\n        \"dashboard_link\": \"\u003ca href=\\\"/superset/dashboard/misc_charts/\\\"\u003eMisc Charts\u003c/a\u003e\",\n        \"dashboard_title\": \"Misc Charts\",\n        \"url\": \"/superset/dashboard/misc_charts/\"\n    }\n]\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonaio%2Fsuperset-patchup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fonaio%2Fsuperset-patchup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonaio%2Fsuperset-patchup/lists"}