Skip to content

triauth for Apache SupersetOIDC

Let your analysts and their readers open Apache Superset with one approval on their own device, and no Superset passwords.

  • Analytics and BI
  • Open source
Sign-in through
OpenID Connect bridge
Available in
Every Apache Superset installation
Set up in
superset_config.py

About Apache Superset

Apache Superset is a web application for exploring data and building charts and dashboards from company databases, without writing code for each chart. Analysts and business teams use it as a free alternative to commercial business intelligence tools, on servers of their own.

Connect Apache Superset to triauth

Superset signs people in through the triauth OpenID Connect bridge. Once connected, the login page shows a Sign In with triauth button. People on your team click it, type their username, and approve on their own device. Nobody keeps a Superset password, and when someone leaves, removing their identity records at your domain ends their access to Superset as well.

Superset takes its sign-in settings as a short piece of Python configuration rather than a settings page, so this one is for the person who runs your Superset.

How it works

  1. Open oidc.triauth.org and enter your domain. Paste Superset's redirect address, https://superset.example.com/oauth-authorized/triauth with your own Superset address in place of superset.example.com, and click Connect app. The bridge gives you a client ID and a client secret.

  2. Add the settings below to superset_config.py, with your domain in place of example.com and the two placeholders replaced by the client ID and the client secret from the bridge. The Authlib package must be installed next to Superset.

    python
    from flask_appbuilder.security.manager import AUTH_OAUTH
    from custom_sso_security_manager import CustomSsoSecurityManager
    
    AUTH_TYPE = AUTH_OAUTH
    AUTH_USER_REGISTRATION = True
    AUTH_USER_REGISTRATION_ROLE = "Gamma"
    CUSTOM_SECURITY_MANAGER = CustomSsoSecurityManager
    OAUTH_PROVIDERS = [{
        "name": "triauth",
        "icon": "fa-key",
        "token_key": "access_token",
        "remote_app": {
            "client_id": "<client ID from the bridge>",
            "client_secret": "<client secret from the bridge>",
            "server_metadata_url": "https://oidc.triauth.org/example.com/.well-known/openid-configuration",
            "client_kwargs": {"scope": "openid email profile groups", "code_challenge_method": "S256"},
        },
    }]

    Next to it, create custom_sso_security_manager.py, which tells Superset which fields of the sign-in to use. It follows the shape of the Keycloak example in Superset's own guide.

    python
    from superset.security import SupersetSecurityManager
    
    class CustomSsoSecurityManager(SupersetSecurityManager):
        def oauth_user_info(self, provider, response=None):
            me = self.oauth_remotes[provider].get("https://oidc.triauth.org/example.com/userinfo").json()
            return {
                "username": me.get("email"),
                "email": me.get("email"),
                "first_name": me.get("name", ""),
                "last_name": "",
                "role_keys": me.get("groups", []),
            }

    Restart Superset.

  3. Open Superset's login page and click Sign In with triauth.

Checkpoint

Superset's login page shows a Sign In with triauth button. Choosing it opens a page from the bridge that asks for the username, and the person's authenticator asks them to approve.

Good to know

  • Everyone with an identity at your domain gets a Superset account the first time they sign in, with the role named in the settings. To let only one team in, limit the app to a group when you connect it.
  • AUTH_ROLES_MAPPING turns the groups published at your domain into Superset roles, and AUTH_ROLES_SYNC_AT_LOGIN = True keeps them in step at every sign-in.
  • People who already have a Superset account keep it when their Superset username is their identifier.

For the person who connects the app

SettingValue
Redirect addresshttps://<your-superset>/oauth-authorized/<provider name>, with the name from OAUTH_PROVIDERS
Where in Supersetsuperset_config.py and a small security manager class next to it
Discoveryserver_metadata_url takes the full address, https://oidc.triauth.org/<your domain>/.well-known/openid-configuration
PKCEcode_challenge_method: S256 in client_kwargs, as above
RolesAUTH_ROLES_MAPPING = {"admins@example.com": ["Admin"]}, with the group's full name including the domain with AUTH_ROLES_SYNC_AT_LOGIN = True

Superset keeps the client secret, so leave This app can't keep a secret unticked when you connect it on the bridge. Superset's OAuth guide shows a complete example with group mapping, and the configuration reference describes every option.

Next steps

All logos and trademarks belong to their respective owners and do not imply affiliation or endorsement of the organization or product by triauth, nor vice versa. The content provided on this page may include information from third-party sources. We do not assume any responsibility for the completeness, correctness, or applicability of the information. You should independently verify any details before relying on them.