Skip to content

feat(security): add SSO discovery and session token API endpoints#40024

Open
AlbertoSolaro wants to merge 1 commit into
apache:masterfrom
AlbertoSolaro:master
Open

feat(security): add SSO discovery and session token API endpoints#40024
AlbertoSolaro wants to merge 1 commit into
apache:masterfrom
AlbertoSolaro:master

Conversation

@AlbertoSolaro
Copy link
Copy Markdown

SUMMARY

Add two new REST API endpoints to SecurityRestApi for external client applications (e.g. mobile apps) that consume Superset's APIs and need to discover configured SSO providers and exchange browser sessions for JWT bearer tokens:

  • GET /api/v1/security/auth_providers/ — returns configured auth providers (OAuth/SAML) with login URLs, auth type, and whether a browser flow is required. Does not require authentication.
  • GET /api/v1/security/session_token/ — converts an active cookie session into a JWT access token. Requires authentication.

This addresses a gap where mobile and third-party applications that consume Superset's REST APIs need to programmatically discover login options and obtain API tokens after completing SSO flows in a web view.

Real-world use case: Glimvia (https://www.glimvia.app/), a mobile application that leverages Superset's API for data visualization, cannot implement SSO login because it is not exposed and API work amazing with JWT so converting it could be useful.

Implementation details:

  • JWT identity uses str(user.id) matching FAB's SecurityApi pattern
  • Anonymous users receive 401 with explicit guard
  • Provider login URLs use rstrip('/') for robust path construction
  • Full OpenAPI/Swagger documentation via docstrings
  • 6 integration tests covering DB auth, OAuth mock, unauthenticated access, and multi-role token generation

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

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

Add two new REST API endpoints to SecurityRestApi for external client
applications (e.g. mobile apps) that consume Superset's APIs and need
to discover configured SSO providers and exchange browser sessions for
JWT bearer tokens:

- GET /api/v1/security/auth_providers/ — returns configured auth
  providers (OAuth/SAML) with login URLs, auth type, and whether a
  browser flow is required. Does not require authentication.
- GET /api/v1/security/session_token/ — converts an active cookie
  session into a JWT access token. Requires authentication.

This addresses a gap where mobile and third-party applications that
consume Superset's REST APIs need to programmatically discover login
options and obtain API tokens after completing SSO flows in a web view.

Real-world use case: Glimvia (https://www.glimvia.app/), a mobile
application that leverages Superset's API for data visualization,
requires these endpoints to authenticate users via SSO and interact
with the API using bearer tokens.

Implementation details:
- JWT identity uses str(user.id) matching FAB's SecurityApi pattern
- Anonymous users receive 401 with explicit guard
- Provider login URLs use rstrip('/') for robust path construction
- Full OpenAPI/Swagger documentation via docstrings
- 6 integration tests covering DB auth, OAuth mock, unauthenticated
  access, and multi-role token generation
@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented May 11, 2026

Code Review Agent Run #043a9e

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: d297432..d297432
    • superset/security/api.py
    • tests/integration_tests/security/api_tests.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@dosubot dosubot Bot added api Related to the REST API authentication:sso Single Sign On labels May 11, 2026
@netlify
Copy link
Copy Markdown

netlify Bot commented May 11, 2026

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit d297432
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a01eb1f69df7200091f6d48
😎 Deploy Preview https://deploy-preview-40024--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.

@sadpandajoe sadpandajoe requested review from Copilot and dpgaspar May 13, 2026 18:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds two new REST API endpoints to SecurityRestApi to support external clients (e.g., mobile apps): one for discovering configured SSO providers and login URLs, and one for exchanging an authenticated browser session for a JWT access token. Includes integration test coverage for the new endpoints.

Changes:

  • Add GET /api/v1/security/auth_providers/ (unauthenticated) to expose OAuth/SAML provider metadata and login URLs.
  • Add GET /api/v1/security/session_token/ (authenticated) that returns a JWT created from the active session via flask_jwt_extended.create_access_token.
  • Add a TestSecuritySsoApi test class covering DB auth, OAuth (mocked), unauth access, and admin/gamma token retrieval.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
superset/security/api.py Implements auth_providers and session_token endpoints with OpenAPI docs.
tests/integration_tests/security/api_tests.py Adds integration tests for new endpoints.

Comment thread superset/security/api.py
Comment on lines +204 to +223
if auth_type == AUTH_OAUTH:
for provider in self.appbuilder.sm.oauth_providers:
name = provider["name"]
providers.append(
{
"name": name,
"icon": provider.get("icon", "fa-sign-in"),
"login_url": f"{login_base}/{name}",
}
)
elif auth_type == AUTH_SAML:
for provider in self.appbuilder.sm.saml_providers:
name = provider["name"]
providers.append(
{
"name": name,
"icon": provider.get("icon", "fa-sign-in"),
"login_url": f"{login_base}/{name}",
}
)
Comment thread superset/security/api.py
Comment on lines +204 to +224
if auth_type == AUTH_OAUTH:
for provider in self.appbuilder.sm.oauth_providers:
name = provider["name"]
providers.append(
{
"name": name,
"icon": provider.get("icon", "fa-sign-in"),
"login_url": f"{login_base}/{name}",
}
)
elif auth_type == AUTH_SAML:
for provider in self.appbuilder.sm.saml_providers:
name = provider["name"]
providers.append(
{
"name": name,
"icon": provider.get("icon", "fa-sign-in"),
"login_url": f"{login_base}/{name}",
}
)

Comment thread superset/security/api.py
500:
$ref: '#/components/responses/500'
"""
from flask_jwt_extended import create_access_token
Comment thread superset/security/api.py
500:
$ref: '#/components/responses/500'
"""
auth_type = current_app.config.get("AUTH_TYPE")
Comment thread superset/security/api.py
Comment on lines +272 to +274
if not user or user.is_anonymous:
return self.response_401()

@codecov
Copy link
Copy Markdown

codecov Bot commented May 13, 2026

Codecov Report

❌ Patch coverage is 41.17647% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.56%. Comparing base (7593d2a) to head (d297432).
⚠️ Report is 105 commits behind head on master.

Files with missing lines Patch % Lines
superset/security/api.py 41.17% 20 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (7593d2a) and HEAD (d297432). Click for more details.

HEAD has 6 uploads less than BASE
Flag BASE (7593d2a) HEAD (d297432)
python 11 5
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #40024      +/-   ##
==========================================
- Coverage   63.88%   55.56%   -8.33%     
==========================================
  Files        2583     2584       +1     
  Lines      136604   136729     +125     
  Branches    31502    31524      +22     
==========================================
- Hits        87276    75968   -11308     
- Misses      47812    60100   +12288     
+ Partials     1516      661     -855     
Flag Coverage Δ
hive 39.36% <41.17%> (-0.02%) ⬇️
mysql ?
postgres ?
presto 41.06% <41.17%> (-0.03%) ⬇️
python 42.32% <41.17%> (-18.26%) ⬇️
sqlite ?
unit 100.00% <ø> (ø)

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

☔ View full report in Codecov by Sentry.
📢 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.

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 authentication:sso Single Sign On size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants