Skip to content

feat(auth): Skip OAUTH provider selection - #41635

Open
tahvane1 wants to merge 2 commits into
apache:masterfrom
tahvane1:oauth-skip-provider-selection
Open

feat(auth): Skip OAUTH provider selection#41635
tahvane1 wants to merge 2 commits into
apache:masterfrom
tahvane1:oauth-skip-provider-selection

Conversation

@tahvane1

@tahvane1 tahvane1 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

SUMMARY

This PR introduces functionality to skip provider selection screen if there is only one OAUTH provider and forwards request directly to the only OAUTH provider.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

Provider selection should not be visible when only one provider used.

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

@dosubot dosubot Bot added the authentication:sso Single Sign On label Jul 1, 2026
@bito-code-review

bito-code-review Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #36a495

Actionable Suggestions - 0
Filtered by Review Rules

Bito filtered these suggestions based on rules created automatically for your feedback. Manage rules.

  • superset/security/manager.py - 1
Review Details
  • Files reviewed - 3 · Commit Range: 4bcbd29..4bcbd29
    • superset/security/manager.py
    • superset/views/auth.py
    • tests/unit_tests/security/manager_test.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ 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

@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 68.75000% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.06%. Comparing base (3651020) to head (6438a8a).
⚠️ Report is 670 commits behind head on master.

Files with missing lines Patch % Lines
superset/views/auth.py 58.33% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #41635      +/-   ##
==========================================
- Coverage   64.41%   64.06%   -0.36%     
==========================================
  Files        2668     2774     +106     
  Lines      147198   155683    +8485     
  Branches    33949    35210    +1261     
==========================================
+ Hits        94824    99739    +4915     
- Misses      50657    53965    +3308     
- Partials     1717     1979     +262     
Flag Coverage Δ
hive 38.38% <43.75%> (-0.71%) ⬇️
mysql 57.55% <68.75%> (-0.10%) ⬇️
postgres 57.58% <68.75%> (-0.14%) ⬇️
presto 40.30% <43.75%> (-0.35%) ⬇️
python 58.99% <68.75%> (-0.14%) ⬇️
sqlite 57.21% <68.75%> (-0.14%) ⬇️
unit 100.00% <ø> (ø)

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.

@rusackas

Copy link
Copy Markdown
Member

The PR description mentions an OAUTH_SKIP_PROVIDER_SELECTION flag, but I don't see it referenced anywhere in the diff, this just always skips the selection screen for single-provider setups unconditionally. Was the flag meant to gate this, since it's a behavior change for anyone currently relying on that screen? Also worth noting unit-tests is failing on this branch, looks like the new tests are leaving oauth_remotes mocked in a way that breaks unrelated security tests running after them. Holler if I can help further.

@tahvane1

Copy link
Copy Markdown
Contributor Author

Sorry. Copy&paste error. Fixed.

@rusackas

Copy link
Copy Markdown
Member

Thanks for clearing up the description. unit-tests is still red on this branch though, same issue as before, the mocked oauth_remotes in the new tests is leaking into the security tests that run after them. Push a fix for that and I'll take another look, or let me know if you want me to jump in and push some commits.

@tahvane1

Copy link
Copy Markdown
Contributor Author

I am not really familiar with this testing framework so I do not mind if you take over. I will check how you did it and try to do it properly next time...

The new OAuth provider-selection tests were inserted in place of the
stored_metrics fixture, deleting it and breaking
test_raise_for_access_guest_user_ok and other downstream tests that
depend on it.
@rusackas

Copy link
Copy Markdown
Member

Pushed a fix. The new OAuth tests had landed right on top of the stored_metrics fixture and deleted it, which is what was breaking test_raise_for_access_guest_user_ok and the tests after it. Restored the fixture and dropped a couple of redundant local imports. CI should be green now — will take another look once it runs.

@netlify

netlify Bot commented Jul 27, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

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

assert sm


def test_superset_oauth_view_oauth_oauth_single_provider(

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.

Suggestion: The test name contains a duplicated oauth, which is an obvious naming typo and makes the test harder to identify consistently. [typo]

Severity Level: Minor 🧹
- ⚠️ Test discovery and execution remain unaffected.
- ⚠️ Only test readability and searchability are reduced.
Steps of Reproduction ✅
1. Run the test suite containing `tests/unit_tests/security/manager_test.py:56`, which
defines `test_superset_oauth_view_oauth_oauth_single_provider`.

2. Pytest discovers and executes the test despite the duplicated `oauth` token in its
function name.

3. The test invokes `SupersetOAuthView.login()` at
`tests/unit_tests/security/manager_test.py:76` and validates the behavior at line 78; the
typo does not alter execution or assertions.

4. The issue is therefore limited to readability and naming consistency; no functional
failure can be reproduced from the test name itself.

Fix in Cursor Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** tests/unit_tests/security/manager_test.py
**Line:** 56:56
**Comment:**
	*Typo: The test name contains a duplicated `oauth`, which is an obvious naming typo and makes the test harder to identify consistently.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Comment on lines +117 to +133
app.config["OAUTH_PROVIDERS"] = [
{
"name": "google",
"icon": "fa-google",
"token_key": "access_token",
"remote_app": {
"client_id": "test_client_id",
"client_secret": "test_client_secret",
"api_base_url": "https://accounts.google.com/o/oauth2/v2/auth",
"client_kwargs": {"scope": "email profile"},
},
}
]

mock_provider = mocker.Mock()
mock_remotes = {"google": mock_provider}
mocker.patch.object(app.appbuilder.sm, "oauth_remotes", mock_remotes)

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.

Suggestion: This test does not actually verify the AUTH_TYPE or OAUTH_PROVIDERS configuration because it replaces app.appbuilder.sm.oauth_remotes with a mock before invoking the view. It would pass even if configuration-driven OAuth provider initialization were broken; instantiate or configure the security manager through the real configuration instead of bypassing it. [possible bug]

Severity Level: Major ⚠️
- ⚠️ OAuth configuration initialization regressions can pass CI.
- ⚠️ Single-provider login coverage only tests an injected provider map.
- ⚠️ Production authentication setup remains insufficiently validated.
Steps of Reproduction ✅
1. Run `test_security_manager_with_oauth_auth_type` from
`tests/unit_tests/security/manager_test.py:107`.

2. The test sets `AUTH_TYPE` and a single `OAUTH_PROVIDERS` entry at
`tests/unit_tests/security/manager_test.py:116-129`, but does not construct or
reinitialize the security manager from those settings.

3. At line 133, it replaces `app.appbuilder.sm.oauth_remotes` with `{"google":
mock_provider}` before `SupersetOAuthView.login()` is called at line 139.

4. The view therefore observes the injected dictionary and delegates to
`AuthOAuthView.login("google")` at line 141, even if configuration-driven creation of
`oauth_remotes` were broken.

5. Introduce a failure in the security manager's OAuth provider initialization and rerun
this test; the patched `oauth_remotes` still allows the test to pass, demonstrating that
the test does not cover the configuration-to-provider initialization path.

Fix in Cursor Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** tests/unit_tests/security/manager_test.py
**Line:** 117:133
**Comment:**
	*Possible Bug: This test does not actually verify the `AUTH_TYPE` or `OAUTH_PROVIDERS` configuration because it replaces `app.appbuilder.sm.oauth_remotes` with a mock before invoking the view. It would pass even if configuration-driven OAuth provider initialization were broken; instantiate or configure the security manager through the real configuration instead of bypassing it.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

@bito-code-review

bito-code-review Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #90639b

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 4bcbd29..6438a8a
    • tests/unit_tests/security/manager_test.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ 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

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants