Skip to content

feat(superset): connection mutator that forwards the user's token, refresh fix and per-user cache (#968 slice 4.2) #986

Closed

Description

@malon64

Slice 4.2 of #968 (tracker #960). No dependency — wave 1. Image and config only, gated so nothing changes until slice 4.3 imports a per-user database.

Scope (from spike #962; tested module in the spike comment)

  • New images/superset/olf_trino.py, copied in the Dockerfile:
    • DB_CONNECTION_MUTATOR: for a Trino URL with a bearer in connect_args["http_session"], set extra_credential=[("token", t)], user=<email claim>, strip a URI password (a password silently replaces the bearer: trino/sqlalchemy/dialect.py:146-149), copy verify onto the supplied session (trino/dbapi.py:203-207). No bearer → unchanged (Trino 401 starts the OAuth2 flow).
    • install() from FLASK_APP_MUTATOR: map a 400/401 from Dex's token endpoint on refresh to TrinoAuthError (stock 6.1.0 keeps a refused refresh token and errors on every query — reproduced) and store expires_in - 60.
  • Superset config (the openlakeforge_oidc override, active only with people's access): DATABASE_OAUTH2_CLIENTS["Trino"] on the existing superset Dex client with scope openid email groups federated:id offline_access audience:server:client_id:olf-cli, DATABASE_OAUTH2_REDIRECT_URI per stage, feature flags CACHE_QUERY_BY_USER, CACHE_IMPERSONATION on, ALERT_REPORTS and THUMBNAILS off, VIZ_TYPE_DENYLIST for the legacy viz.py types (their cache key has no user).
  • Pin the trino client exactly in images/superset/Dockerfile (the mutator depends on its http_session/extra_credential handling) and record it in release/component-catalog.yaml if the image build is tracked there.
  • patches/patch_trino_iceberg_partitions.py: _is_iceberg_database must also recognise the stage catalog URI, or the SQL Lab partition bug returns.
  • Port the spike's run (fake Trino + fake Dex inside the image) into the image tests: headers, refresh, refused refresh recovery, no-user case fails closed.

Acceptance

  • Image tests above pass in CI.
  • With no per-user database imported, the full local e2e is unchanged.

Activity

  1. added
    roadmap
    priority: P1
    track: identity
    on Nov 7, 2026
  2. malon64 commented on Nov 7, 2026

    @malon64
    CollaboratorAuthor

    PR: #999 (ready for review, CI green on 9212af2, including Deploy slim kind smoke).

    Summary

    • images/superset/olf_trino.py adds a DB_CONNECTION_MUTATOR and an install() for FLASK_APP_MUTATOR.
      • The mutator sets the token extra credential and the email user, strips a URI password, and copies verify onto the supplied session. With no bearer it changes nothing.
      • install() maps a Dex 400/401 on refresh to TrinoAuthError and stores expires_in - 60.
    • openlakeforge_oidc now sets DATABASE_OAUTH2_CLIENTS["Trino"] and the per-stage redirect. It also sets CACHE_QUERY_BY_USER and CACHE_IMPERSONATION on, ALERT_REPORTS and THUMBNAILS off, and VIZ_TYPE_DENYLIST for the legacy viz.py types. The Dex superset client accepts the extra redirect.
    • trino is pinned to ==0.340.0. The catalog does not track the image's pip dependencies, so release/component-catalog.yaml is unchanged.
    • The Iceberg partition patch now recognises the stage people-catalog URI.
    • Tests are in test_superset_trino.py: headers, refresh, a refused refresh token, and no bearer leaving the connection unchanged. They stub Superset and trino, like test_superset_oidc.py. They do not run a fake Trino or Dex over HTTP inside the image.

    Gates

    • ruff and mypy: clean.
    • pytest: 3360 passed, coverage 86.7% against the 81% floor.
    • olf check all: the Terraform and container checks passed. It stopped on project-code requires Python >=3.12,<3.13; found 3.13, which is this sandbox's interpreter. CI's "Validate project-code runtime" passed.

    Kind checks owed (coordinator)
    The Superset image must be rebuilt and loaded locally, for example with BUILD_SUPERSET_IMAGE=true olf infra deploy --provider local. Then check:

    1. olf infra e2e run --env local is unchanged, with no per-user database imported.
    2. The Superset pod starts without an import error for olf_trino or trino_settings.
    3. The Dex superset client lists both redirects.
    4. pip show trino in the image reports 0.340.0.
    5. SQL Lab previews on the shared Iceberg database still work.

    Before slice 4.3: the Dex trustedPeers entry (olf-cli trusting superset) is not in this issue. The audience:server:client_id:olf-cli scope will be refused until it exists.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: P1roadmaptrack: identitytype: feature

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions