Skip to content

feat(DB OAuth2): Allow admins to manage DB OAuth2 tokens - #45676

Merged
Vitor-Avila merged 10 commits into
masterfrom
feat/oauth2-token-management
Oct 28, 2026
Merged

Vitor-Avila merged 10 commits into
masterfrom
feat/oauth2-token-management

Conversation

@Vitor-Avila

Copy link
Copy Markdown
Contributor

SUMMARY

This PR provides admins with a way to delete existing OAuth2 tokens for specific users/DB connections. This is useful when the token was generated using an old incorrect role/config.

A new Manage OAuth2 tokens option is displayed for DB connections authenticated via OAuth2. The modal allows the deletion of a single token, multiple, and also all tokens. I decided to implement same behavior as CRUD views: can't select across pages for a bulk delete.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Screen.Recording.2026-10-23.at.4.52.49.PM.mov

TESTING INSTRUCTIONS

  1. Set up an OAuth2 connection.
  2. Go through the OAuth2 dance.
  3. Use the feature to delete the OAuth2 token.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@github-actions github-actions Bot added risk:db-migration PRs that require a DB migration api Related to the REST API labels Oct 23, 2026
@github-actions github-actions Bot added i18n Namespace | Anything related to localization i18n:spanish Translation related to Spanish language i18n:italian Translation related to Italian language i18n:french Translation related to French language i18n:chinese Translation related to Chinese language i18n:japanese Translation related to Japanese language i18n:russian Translation related to Russian language i18n:korean Translation related to Korean language doc Namespace | Anything related to documentation i18n:dutch i18n:slovak i18n:ukrainian i18n:portuguese i18n:brazilian i18n:traditional-chinese i18n:persian i18n:czech i18n:latvian labels Oct 23, 2026
@netlify

netlify Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 2782e5e
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6ae15e29012bf46864fd7ef4
😎 Deploy Preview https://deploy-preview-45676--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@Vitor-Avila
Vitor-Avila requested a balanced review from Copilot October 23, 2026 21:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

4 open issues
What changed in this PR

Adds an admin-facing workflow for viewing and deleting stored DB OAuth2 tokens (single, bulk on page, and delete-all), plus the backend support needed to expose OAuth2 state on connections.

Changes:

  • Add new REST API endpoints and command/DAO support for listing and deleting DB OAuth2 tokens (including a DB index for faster lookup).
  • Expose engine_information.oauth2_enabled so the UI can conditionally show “Manage OAuth2 tokens”.
  • Add frontend modal + tests, and update i18n/OpenAPI artifacts accordingly.
File Description
tests/​unit_tests/​semantic_layers/​connections_access_test.py Adds coverage for serialized connection payload exposing OAuth2-enabled state without leaking credentials.
tests/​unit_tests/​databases/​api_test.py Updates expectations to include engine_information.oauth2_enabled.
superset/​semantic_layers/​api.py Includes encrypted_extra in query and adds engine_information to serialized database payload.
superset/​security/​manager.py Marks can_manage_oauth2_tokens as admin-only permission.
superset/​models/​core.py Adds oauth2_enabled to engine_information; adds DB index definition for token table.
superset/​migrations/​versions/​2026-10-22_12-00_f72b6e9c104a_add_oauth2_token_management_indexes.py Adds an index on database_id for OAuth2 tokens table.
superset/​initialization/​__init__.py Registers the new DatabaseOAuth2TokensRestApi.
superset/​databases/​schemas.py Extends engine info schema with oauth2_enabled; adds delete payload schema for token IDs.
superset/​databases/​filters.py Adds a custom filter to search OAuth2 token owners (username/name/email).
superset/​databases/​api.py Implements list + delete endpoints under /api/v1/database/<pk>/oauth2_tokens/*.
superset/​daos/​database.py Adds DAO helpers for fetching tokens by IDs and bulk delete by database.
superset/​commands/​database/​oauth2.py Introduces OAuth2DeleteTokensCommand with validation and transactional deletion.
superset/​commands/​database/​exceptions.py Adds OAuth2 token-not-found and delete-failed exceptions/messages.
superset-frontend/​src/​pages/​DatabaseList/​index.tsx Adds “Manage OAuth2 tokens” action and modal wiring based on permission + oauth2_enabled.
superset-frontend/​src/​pages/​DatabaseList/​DatabaseList.oauth2Tokens.test.tsx Adds visibility/behavior tests for the new action in the DB list.
superset-frontend/​src/​features/​databases/​types.ts Adds engine_information.oauth2_enabled typing.
superset-frontend/​src/​features/​databases/​OAuth2TokensModal.test.tsx Adds modal behavior tests (select/delete, delete-all, retry/error states).
superset/​translations/​messages.pot Adds new message IDs for token management UI and legend toggles.
superset/​translations/​en/​LC_MESSAGES/​messages.po Updates English catalog for new OAuth2 token management strings.
superset/​translations/​ar/​LC_MESSAGES/​messages.po Updates Arabic catalog for new OAuth2 token management strings.
superset/​translations/​ca/​LC_MESSAGES/​messages.po Updates Catalan catalog for new OAuth2 token management strings.
superset/​translations/​cs/​LC_MESSAGES/​messages.po Updates Czech catalog for new OAuth2 token management strings.
superset/​translations/​de/​LC_MESSAGES/​messages.po Updates German catalog for new OAuth2 token management strings.
superset/​translations/​es/​LC_MESSAGES/​messages.po Updates Spanish catalog for new OAuth2 token management strings.
superset/​translations/​fa/​LC_MESSAGES/​messages.po Updates Persian catalog for new OAuth2 token management strings.
superset/​translations/​fi/​LC_MESSAGES/​messages.po Updates Finnish catalog for new OAuth2 token management strings.
superset/​translations/​fr/​LC_MESSAGES/​messages.po Updates French catalog for new OAuth2 token management strings.
superset/​translations/​it/​LC_MESSAGES/​messages.po Updates Italian catalog for new OAuth2 token management strings.
superset/​translations/​ja/​LC_MESSAGES/​messages.po Updates Japanese catalog for new OAuth2 token management strings.
superset/​translations/​ko/​LC_MESSAGES/​messages.po Updates Korean catalog for new OAuth2 token management strings.
superset/​translations/​lv/​LC_MESSAGES/​messages.po Updates Latvian catalog for new OAuth2 token management strings.
superset/​translations/​mi/​LC_MESSAGES/​messages.po Updates Māori catalog for new OAuth2 token management strings.
superset/​translations/​nl/​LC_MESSAGES/​messages.po Updates Dutch catalog for new OAuth2 token management strings.
superset/​translations/​pl/​LC_MESSAGES/​messages.po Updates Polish catalog for new OAuth2 token management strings.
superset/​translations/​pt/​LC_MESSAGES/​messages.po Updates Portuguese catalog for new OAuth2 token management strings.
superset/​translations/​pt_BR/​LC_MESSAGES/​messages.po Updates Brazilian Portuguese catalog for new OAuth2 token management strings.
superset/​translations/​ro/​LC_MESSAGES/​messages.po Updates Romanian catalog for new OAuth2 token management strings.
superset/​translations/​ru/​LC_MESSAGES/​messages.po Updates Russian catalog for new OAuth2 token management strings.
superset/​translations/​sk/​LC_MESSAGES/​messages.po Updates Slovak catalog for new OAuth2 token management strings.
superset/​translations/​sl/​LC_MESSAGES/​messages.po Updates Slovenian catalog for new OAuth2 token management strings.
superset/​translations/​sr/​LC_MESSAGES/​messages.po Updates Serbian catalog for new OAuth2 token management strings.
superset/​translations/​sr_Latn/​LC_MESSAGES/​messages.po Updates Serbian (Latin) catalog for new OAuth2 token management strings.
superset/​translations/​ta/​LC_MESSAGES/​messages.po Updates Tamil catalog for new OAuth2 token management strings.
superset/​translations/​th/​LC_MESSAGES/​messages.po Updates Thai catalog for new OAuth2 token management strings.
superset/​translations/​tr/​LC_MESSAGES/​messages.po Updates Turkish catalog for new OAuth2 token management strings.
superset/​translations/​uk/​LC_MESSAGES/​messages.po Updates Ukrainian catalog for new OAuth2 token management strings.
superset/​translations/​zh/​LC_MESSAGES/​messages.po Updates Chinese catalog for new OAuth2 token management strings.
superset/​translations/​zh_TW/​LC_MESSAGES/​messages.po Updates Traditional Chinese catalog for new OAuth2 token management strings.
docs/​static/​resources/​openapi.json Updates generated OpenAPI spec with new endpoints/schemas and oauth2_enabled field.

Review effort: Lite

Comment thread superset/commands/database/oauth2.py
Comment thread superset/databases/api.py Outdated
Comment thread superset/databases/api.py
Comment thread superset/databases/api.py Outdated
@codecov

codecov Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.75806% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.57%. Comparing base (e97d7ca) to head (019a590).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...ntend/src/features/databases/OAuth2TokensModal.tsx 93.39% 7 Missing ⚠️
superset/models/core.py 40.00% 3 Missing ⚠️
superset/databases/filters.py 80.00% 1 Missing and 1 partial ⚠️
superset-frontend/src/pages/DatabaseList/index.tsx 93.33% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master   #45676       +/-   ##
===========================================
+ Coverage   65.26%   84.57%   +19.30%     
===========================================
  Files        3068     3069        +1     
  Lines      204990   205227      +237     
  Branches    48174    48222       +48     
===========================================
+ Hits       133788   173570    +39782     
+ Misses      68154    28354    -39800     
- Partials     3048     3303      +255     
Flag Coverage Δ
hive 34.56% <54.33%> (+0.01%) ⬆️
javascript 80.77% <93.38%> (+0.01%) ⬆️
mysql 52.51% <86.61%> (?)
postgres 52.51% <86.61%> (?)
presto 36.28% <54.33%> (+0.01%) ⬆️
python 87.65% <96.06%> (+35.30%) ⬆️
sqlite 52.28% <86.61%> (+0.03%) ⬆️
unit 82.31% <96.06%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Vitor-Avila
Vitor-Avila marked this pull request as draft October 23, 2026 22:09
@Vitor-Avila
Vitor-Avila marked this pull request as ready for review October 23, 2026 22:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread superset/models/core.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Destructive credential management and the cross-dialect index migration require human validation and the migration approvals specified by SIP-59.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

@aminghadersohi
aminghadersohi self-requested a review October 26, 2026 21:25

@aminghadersohi aminghadersohi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the full diff. Looks good.

  • Admin-only permission (can_manage_oauth2_tokens) gates list and both delete endpoints.
  • Token secrets are never serialized: list columns are metadata only and bulk delete skips loading tokens.
  • Selected delete is scoped to the database and returns 404 if any ID doesn't belong to it. Delete-all is a single bulk delete.
  • Migration f72b6e9c104a chains from the current head d623a0cb6bb0, uses CONCURRENTLY on Postgres, and skips MySQL where the FK already indexes the column.
  • Frontend handles pagination, search, selection reset and error states, and has tests.

One nit, non-blocking: oauth2_enabled is set inside the same try as get_public_information(), so if is_oauth2_enabled() ever raises, the rest of the engine information is dropped too.

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Possible DB migration conflict

@Vitor-Avila the base branch master picked up a new database migration under superset/migrations/ after this PR was opened, and this PR adds or modifies migration files too. Alembic migrations form a single linear chain, so if both branch off the same parent revision, merging this PR as-is could leave the migration history with two heads instead of one, which makes superset db upgrade fail with Multiple head revisions are present.

To check and, if needed, fix this:

  1. Rebase this branch onto the latest master.
  2. Run superset db heads. If it lists more than one revision, you have a conflict.
  3. In your new migration's script, update down_revision (and the Revises comment) to point at the other head instead, so the chain has a single head again.

See Merging DB Migrations in the contributing guide for a worked example.

@github-actions github-actions Bot added the requires:rebase Requires rebasing on top of current master label Oct 28, 2026
@github-actions github-actions Bot removed the requires:rebase Requires rebasing on top of current master label Oct 28, 2026
@Vitor-Avila
Vitor-Avila merged commit 1aceca3 into master Oct 28, 2026
99 of 100 checks passed
@Vitor-Avila
Vitor-Avila deleted the feat/oauth2-token-management branch October 28, 2026 04:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Related to the REST API doc Namespace | Anything related to documentation i18n:brazilian i18n:chinese Translation related to Chinese language i18n:czech i18n:dutch i18n:french Translation related to French language i18n:italian Translation related to Italian language i18n:japanese Translation related to Japanese language i18n:korean Translation related to Korean language i18n:latvian i18n:persian i18n:portuguese i18n:russian Translation related to Russian language i18n:slovak i18n:spanish Translation related to Spanish language i18n:traditional-chinese i18n:ukrainian i18n Namespace | Anything related to localization risk:db-migration PRs that require a DB migration size/XXL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants