Skip to content

feat(auth): add SAML login support to frontend#38606

Merged
dpgaspar merged 2 commits intoapache:masterfrom
preset-io:danielgaspar/sc-97146/visa-pcs-configure-saml-integration-with
Mar 13, 2026
Merged

feat(auth): add SAML login support to frontend#38606
dpgaspar merged 2 commits intoapache:masterfrom
preset-io:danielgaspar/sc-97146/visa-pcs-configure-saml-integration-with

Conversation

@dpgaspar
Copy link
Member

@dpgaspar dpgaspar commented Mar 12, 2026

User description

SUMMARY

Flask-AppBuilder 5.1.0 added SAML authentication (AuthSAMLView). The Superset backend already passes SAML providers to the frontend via bootstrap data (superset/views/base.py), but the React Login component didn't handle AUTH_TYPE = 5 (AUTH_SAML), so the login page rendered empty — just "Sign in" with no provider buttons.

This PR adds full SAML login support:

  • Frontend: Add AuthSAML = 5 to the AuthType enum and render SAML provider buttons using the same pattern as OAuth (same provider shape {name, icon} and /login/<provider> URL pattern)
  • Dependency: Add python3-saml via flask-appbuilder[saml] extra in pyproject.toml and pinned requirements
  • CSRF: Exempt FAB's SAML ACS endpoint (/saml/acs/) from CSRF protection — the IdP POSTs the SAML response cross-site without a CSRF token
  • Recaptcha: Exclude SAML from the recaptcha check (like OAuth, SAML users don't go through a self-registration form)
  • Tests: Backend tests for SAML/OAuth bootstrap data and recaptcha logic; frontend test for SAML provider button rendering

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before: With AUTH_TYPE = AUTH_SAML, the login page shows only "Sign in" with no buttons.

After: SAML provider buttons render correctly, matching the OAuth provider button style.

TESTING INSTRUCTIONS

  1. Configure SAML authentication in superset_config.py:
    from flask_appbuilder.const import AUTH_SAML
    
    AUTH_TYPE = AUTH_SAML
    AUTH_USER_REGISTRATION = True
    AUTH_USER_REGISTRATION_ROLE = "Admin"
    
    SAML_PROVIDERS = [
        {
            "name": "entra_id",
            "icon": "fa-microsoft",
            "idp": { ... },
            "attribute_mapping": { ... },
        },
    ]
    SAML_CONFIG = { "sp": { ... }, "security": { ... } }
  2. Verify the login page shows SAML provider buttons
  3. Click a provider button and complete the SAML flow
  4. Verify successful login and redirect to the welcome page
  5. Run backend tests: pytest tests/unit_tests/views/test_bootstrap_auth.py -v

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

CodeAnt-AI Description

Add SAML login support and ensure SAML providers and recaptcha behavior are exposed to the frontend

What Changed

  • Login page now shows SAML provider buttons (e.g., "Sign in with Okta") when server is configured for SAML
  • Server bootstrap data includes SAML providers and uses a default icon when none is provided, so the frontend can render provider buttons
  • Recaptcha is not included for SAML (same behavior as OAuth), preventing unnecessary captcha prompts for federated sign-ins
  • The SAML ACS endpoint is exempted from CSRF protection so IdP-posted SAML responses are accepted
  • Tests added to verify SAML provider bootstrap data and frontend rendering of SAML buttons

Impact

✅ Login page shows SAML providers
✅ No recaptcha prompt for SAML sign-ins
✅ Successful SAML ACS posts accepted without CSRF rejections

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

@bito-code-review
Copy link
Contributor

bito-code-review bot commented Mar 12, 2026

Code Review Agent Run #87a487

Actionable Suggestions - 0
Review Details
  • Files reviewed - 8 · Commit Range: b1bb8f3..b1bb8f3
    • pyproject.toml
    • requirements/base.txt
    • requirements/development.txt
    • superset-frontend/src/pages/Login/Login.test.tsx
    • superset-frontend/src/pages/Login/index.tsx
    • superset/config.py
    • superset/views/base.py
    • tests/unit_tests/views/test_bootstrap_auth.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

@codeant-ai-for-open-source codeant-ai-for-open-source bot added the size:L This PR changes 100-499 lines, ignoring generated files label Mar 12, 2026
@dosubot dosubot bot added authentication Related to authentication authentication:sso Single Sign On labels Mar 12, 2026
@codecov
Copy link

codecov bot commented Mar 12, 2026

Codecov Report

❌ Patch coverage is 44.44444% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.40%. Comparing base (4a9db24) to head (3e58c8f).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
superset/views/base.py 28.57% 4 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #38606      +/-   ##
==========================================
- Coverage   65.01%   64.40%   -0.61%     
==========================================
  Files        1817     2529     +712     
  Lines       72318   128959   +56641     
  Branches    23032    29722    +6690     
==========================================
+ Hits        47016    83054   +36038     
- Misses      25302    44459   +19157     
- Partials        0     1446    +1446     
Flag Coverage Δ
hive 40.75% <28.57%> (?)
javascript 65.02% <100.00%> (+0.01%) ⬆️
mysql 61.88% <28.57%> (?)
postgres 61.95% <28.57%> (?)
presto 40.77% <28.57%> (?)
python 63.58% <28.57%> (?)
sqlite 61.58% <28.57%> (?)
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.

@dpgaspar dpgaspar force-pushed the danielgaspar/sc-97146/visa-pcs-configure-saml-integration-with branch 2 times, most recently from 54f3f9b to 381db9f Compare March 12, 2026 16:58
Copy link
Contributor

@bito-code-review bito-code-review bot left a comment

Choose a reason for hiding this comment

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

Code Review Agent Run #440e8b

Actionable Suggestions - 1
  • superset/config.py - 1
Review Details
  • Files reviewed - 7 · Commit Range: 381db9f..381db9f
    • requirements/base.txt
    • requirements/development.txt
    • superset-frontend/src/pages/Login/Login.test.tsx
    • superset-frontend/src/pages/Login/index.tsx
    • superset/config.py
    • superset/views/base.py
    • tests/unit_tests/views/test_bootstrap_auth.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

@dpgaspar dpgaspar force-pushed the danielgaspar/sc-97146/visa-pcs-configure-saml-integration-with branch from 381db9f to dbaecb5 Compare March 12, 2026 19:58
@codeant-ai-for-open-source codeant-ai-for-open-source bot added size:L This PR changes 100-499 lines, ignoring generated files and removed size:L This PR changes 100-499 lines, ignoring generated files labels Mar 12, 2026
@netlify
Copy link

netlify bot commented Mar 12, 2026

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 3e58c8f
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/69b3ae24154faa0008c312d2
😎 Deploy Preview https://deploy-preview-38606--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

Copy link
Contributor

@bito-code-review bito-code-review bot left a comment

Choose a reason for hiding this comment

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

Code Review Agent Run #d2fb23

Actionable Suggestions - 2
  • superset/views/base.py - 1
  • superset-frontend/src/pages/Login/Login.test.tsx - 1
    • Incomplete test assertions for SAML login behavior · Line 61-78
Review Details
  • Files reviewed - 7 · Commit Range: dbaecb5..dbaecb5
    • requirements/base.txt
    • requirements/development.txt
    • superset-frontend/src/pages/Login/Login.test.tsx
    • superset-frontend/src/pages/Login/index.tsx
    • superset/config.py
    • superset/views/base.py
    • tests/unit_tests/views/test_bootstrap_auth.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

Flask-AppBuilder 5.1.0 added SAML authentication (AuthSAMLView).
The backend already passes SAML providers to the frontend via bootstrap
data, but the React Login component didn't handle AUTH_TYPE = 5
(AUTH_SAML), rendering an empty login page.

Changes:
- Add AuthSAML = 5 to the frontend AuthType enum and render SAML
  provider buttons using the same pattern as OAuth
- Exempt FAB's SAML ACS endpoint from CSRF protection (the IdP
  POSTs the SAML response cross-site without a CSRF token)
- Exclude SAML from recaptcha check (like OAuth, SAML users don't
  go through a registration form)
- Add backend tests for SAML/OAuth bootstrap data and recaptcha logic
- Add frontend test for SAML provider button rendering

Note: SAML requires `python3-saml` which is an optional dependency.
Install it with: `pip install flask-appbuilder[saml]` or
`pip install python3-saml`

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dpgaspar dpgaspar force-pushed the danielgaspar/sc-97146/visa-pcs-configure-saml-integration-with branch from dbaecb5 to fba38e9 Compare March 13, 2026 06:04
@codeant-ai-for-open-source codeant-ai-for-open-source bot added size:L This PR changes 100-499 lines, ignoring generated files and removed size:L This PR changes 100-499 lines, ignoring generated files labels Mar 13, 2026
@codeant-ai-for-open-source
Copy link
Contributor

Sequence Diagram

This PR enables the frontend to support SAML auth by consuming SAML providers from bootstrap config and rendering provider login buttons. It also ensures federated SAML flow works end to end by skipping recaptcha in bootstrap config and exempting the SAML ACS callback from CSRF checks.

sequenceDiagram
    participant User
    participant LoginPage
    participant Backend
    participant IdP

    User->>LoginPage: Open sign in page
    LoginPage->>Backend: Request bootstrap auth config
    Backend->>Backend: Build SAML auth config and skip recaptcha
    Backend-->>LoginPage: Return auth type and provider list
    LoginPage-->>User: Render SAML provider buttons
    User->>Backend: Start SAML login with selected provider
    IdP->>Backend: Post SAML response to ACS endpoint
    Backend-->>User: Accept callback and complete login
Loading

Generated by CodeAnt AI

@bito-code-review
Copy link
Contributor

bito-code-review bot commented Mar 13, 2026

Code Review Agent Run #887478

Actionable Suggestions - 0
Review Details
  • Files reviewed - 7 · Commit Range: fba38e9..3e58c8f
    • requirements/base.txt
    • requirements/development.txt
    • superset-frontend/src/pages/Login/Login.test.tsx
    • superset-frontend/src/pages/Login/index.tsx
    • superset/config.py
    • superset/views/base.py
    • tests/unit_tests/views/test_bootstrap_auth.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

Copy link
Member

@Antonio-RiveroMartnez Antonio-RiveroMartnez left a comment

Choose a reason for hiding this comment

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

LGTM, small nit and a question for learning purposes. Thanks

saml_providers.append(
{
"name": provider["name"],
"icon": provider.get("icon", "fa-sign-in"),

Choose a reason for hiding this comment

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

nit: FAB already has this null check, correct? so probably not needed here, also, Auth0 treats the icon as non optional, why being different here?

Copy link
Member Author

Choose a reason for hiding this comment

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

FAB Already had This view is not used by Superset. So we are adding the same check here

"superset.views.core.explore_json",
"superset.views.core.log",
"superset.views.datasource.views.samples",
"flask_appbuilder.security.views.acs",
Copy link
Member

@Antonio-RiveroMartnez Antonio-RiveroMartnez Mar 13, 2026

Choose a reason for hiding this comment

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

Question: Why other security views from FAB don't need to be included here but this does?

Copy link
Member Author

Choose a reason for hiding this comment

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

This view is called by the SAML IdP, the IdP can't send a POST with a CSRF. The other views from FAB are used by a user directly and should be protected

@dpgaspar dpgaspar merged commit 56d6bb1 into apache:master Mar 13, 2026
108 of 109 checks passed
@dpgaspar dpgaspar deleted the danielgaspar/sc-97146/visa-pcs-configure-saml-integration-with branch March 13, 2026 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

authentication:sso Single Sign On authentication Related to authentication size/L size:L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants