Skip to content

fix(auth): gate legacy FAB password reset routes behind config flag - #37773

Closed
jayvenn21 wants to merge 11 commits into
apache:masterfrom
jayvenn21:fix/37700-gate-legacy-fab-password-views
Closed

jayvenn21 wants to merge 11 commits into
apache:masterfrom
jayvenn21:fix/37700-gate-legacy-fab-password-views

Conversation

@jayvenn21

Copy link
Copy Markdown
Contributor

Summary

After the frontend porting in Superset 6.0.0, most user-facing views were migrated to the React SPA and rendered via render_app_template. However, the legacy Flask-AppBuilder password reset views (ResetPassword and ResetMyPassword) remain directly accessible via URL and render using server-side templates.

This results in inconsistent behavior and exposes legacy SSR FAB views that were not intended to be accessible post-migration.

What this PR does

  • Prevents direct URL access to legacy FAB password reset views
  • Aligns password-related routes with the post-6.0.0 SPA-based frontend architecture
  • Ensures legacy SSR views are no longer rendered when accessed directly

What this PR does not do

  • Does not redesign password reset UX
  • Does not migrate legacy FAB views to SPA
  • Does not modify existing admin password reset behavior
  • Does not introduce new authentication flows

Rationale

This change addresses an unintended side effect of the FAB → SPA migration and keeps Superset’s frontend behavior consistent without expanding scope into broader authentication or UX changes.

Related Issue

Fixes #37700

@bito-code-review

bito-code-review Bot commented Feb 7, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #4d4f94

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 6530a72..6530a72
    • superset/config.py
    • superset/security/manager.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 [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@dosubot dosubot Bot added the authentication:fab Related to authentication with FAB label Feb 7, 2026
Comment thread superset/security/manager.py Resolved
@bito-code-review

bito-code-review Bot commented Feb 7, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #d815df

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 6530a72..3f7db61
    • superset/config.py
    • superset/security/manager.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 [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

Comment thread superset/security/manager.py Resolved
@codecov

codecov Bot commented Feb 9, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.19%. Comparing base (7a9fe06) to head (9a24ed8).
⚠️ Report is 26 commits behind head on master.

Files with missing lines Patch % Lines
superset/security/manager.py 74.35% 5 Missing and 5 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master   #37773   +/-   ##
=======================================
  Coverage   66.19%   66.19%           
=======================================
  Files        2949     2949           
  Lines      177374   177413   +39     
  Branches    41102    41109    +7     
=======================================
+ Hits       117411   117437   +26     
- Misses      57460    57467    +7     
- Partials     2503     2509    +6     
Flag Coverage Δ
hive 36.94% <70.00%> (+0.01%) ⬆️
mysql 56.15% <75.00%> (+<0.01%) ⬆️
postgres 56.16% <75.00%> (+<0.01%) ⬆️
presto 38.88% <70.00%> (+0.01%) ⬆️
python 56.48% <75.00%> (+<0.01%) ⬆️
sqlite 55.88% <75.00%> (+<0.01%) ⬆️

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.

@EnxDev

EnxDev commented Feb 9, 2026

Copy link
Copy Markdown
Contributor

Superset uses Git pre-commit hooks courtesy of pre-commit. To install run the following:

pre-commit install

This will install the hooks in your local repository. From now on, a series of checks will automatically run whenever you make a Git commit. To run pre-commit manually run the following:

pre-commit run --all-files

Comment thread superset/security/manager.py Resolved
@pull-request-size pull-request-size Bot added size/M and removed size/S labels Feb 9, 2026
@netlify

netlify Bot commented Feb 9, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

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

@jayvenn21

Copy link
Copy Markdown
Contributor Author

I’ve run pre-commit run --all-files locally and addressed the feedback.
CI checks appear pending approval; happy to re-run or adjust once workflows are approved.

@bito-code-review

bito-code-review Bot commented Feb 9, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #d6e5b3

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 3f7db61..b4bbcaf
    • superset/config.py
    • superset/security/manager.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 [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@rusackas

Copy link
Copy Markdown
Member

Running CI 🤞

@jayvenn21

Copy link
Copy Markdown
Contributor Author

Thanks once again and CI surfaced two remaining issues I’m addressing now:

• A ruff E501 (line length) in security/manager.py, which I’ll fix by wrapping the comment.
• Integration tests asserting ResetPasswordView is always present for Admin. Since this PR gates legacy FAB password views behind ENABLE_LEGACY_FAB_PASSWORD_VIEWS, I’m updating the tests to reflect the new behavior (present only when the flag is enabled).

The fixes will be pushed shortly.

@bito-code-review

bito-code-review Bot commented Feb 10, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #08d3ef

Actionable Suggestions - 0
Review Details
  • Files reviewed - 3 · Commit Range: b4bbcaf..c143394
    • superset/config.py
    • superset/security/manager.py
    • tests/integration_tests/core_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 [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@rusackas

Copy link
Copy Markdown
Member

Thanks for sticking with this @jayvenn21. It's gone conflicting with master, so it'll need a rebase.

One open question from @dpgaspar still stands: he floated doing this as a FAB config (like FAB_ADD_SECURITY_VIEWS) so the views just never register, which is cleaner than gating here. Worth deciding which direction we want before we run CI again?

@jayvenn21
jayvenn21 force-pushed the fix/37700-gate-legacy-fab-password-views branch from c143394 to 561d932 Compare June 19, 2026 15:07
@jayvenn21

Copy link
Copy Markdown
Contributor Author

@rusackas Thanks for the feedback! It’s been a while since I touched this, so I rebased the PR on current master.

I also revisited the implementation. Instead of registering the legacy FAB password reset views and then trying to remove/unregister them afterward, this now skips registering those views during FAB security view registration. That gets closer to the FAB config direction discussed earlier, without requiring a new FAB release/dependency bump for this PR.

Here are the validation tests:

  • tests/integration_tests/core_tests.py::TestCore::test_admin_only_menu_views
  • tests/integration_tests/core_tests.py::TestCore::test_legacy_fab_password_views_are_not_registered
  • scoped mypy and ruff on the changed files

Note: I attempted pre-commit run --all-files, but seems like it is currently blocked by unrelated mypy errors in tests/unit_tests/semantic_layers/mapper_test.py, which this PR does not modify.

@bito-code-review

bito-code-review Bot commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #95daeb

Actionable Suggestions - 0
Review Details
  • Files reviewed - 3 · Commit Range: d1d071a..561d932
    • superset/config.py
    • superset/security/manager.py
    • tests/integration_tests/core_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 [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Translation Regression Detected

A source change in this PR renamed or reworded strings, invalidating existing translations (they are now #, fuzzy) in fi, fr, it, ko, th, tr. Please resolve the affected .po files before merging.

Note: intentionally deleting a translatable string is not a regression and is not flagged here — only translations invalidated by a renamed/reworded source string are.

Language Fuzzy before Fuzzy after New
fi 4814 4817 +3
fr 1004 1014 +10
it 1665 1667 +2
ko 1519 1521 +2
th 4814 4817 +3
tr 585 786 +201

How to fix

1. Install dependencies (if not already set up):

pip install -r superset/translations/requirements.txt
sudo apt-get install gettext   # or: brew install gettext

2. Re-extract strings and sync .po files:

./scripts/translations/babel_update.sh

This rewrites superset/translations/messages.pot from the current source files and merges the changes into every .po file. Strings whose msgid changed will be marked #, fuzzy.

3. Resolve the fuzzy entries in the affected language files (fi, fr, it, ko, th, tr):

grep -n '#, fuzzy' superset/translations/<lang>/LC_MESSAGES/messages.po

For each fuzzy entry, either rewrite the msgstr to match the new string and remove the #, fuzzy line, or clear the msgstr to "" if you cannot provide a translation.

4. Commit your changes to the .po files.

Comment thread superset/security/manager.py Resolved
Comment thread tests/integration_tests/core_tests.py Resolved
@EnxDev

EnxDev commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

EnxDev's Review Agent — #37773 · HEAD 561d932

comment — Fix works and is tested for the default path, but a maintainer steered toward an upstream FAB config and the self-service password-change path needs confirming.

🔴 Functional

  • superset/security/manager.py:4218 — Gating un-registers both ResetMyPasswordView (a logged-in AUTH_DB user changing their own password) and ResetPasswordView (admin resetting another user's password), so both routes 404. Does the 6.0 SPA actually provide replacements for both? If not, every AUTH_DB principal (Gamma/Alpha/Admin) loses self-service password change and admins lose user-password reset — a functional regression, not just a styling fix. (test: assert the SPA route / documented alternative exists before the FAB route is removed)

🟡 Should-fix

  • Approach — @dpgaspar asked for this upstream in FAB via a new FAB_ADD_SECURITY_*-style flag and offered to review/release it; the current monkeypatch of appbuilder.add_view_no_menu is a workaround.
    Pursue the FAB route as discussed in-thread.
  • Tests — only the disabled (default) path is covered. Add a case with ENABLE_LEGACY_FAB_PASSWORD_VIEWS=True asserting the routes ARE registered, so the enable branch is guarded.

🔵 Nits

  • superset/security/manager.py:4297 — continue is the last statement in the loop body; it's a no-op, drop it.
  • superset/security/manager.py:4216 — the 'temporal change to remove the roles view…' comment now sits above _skip_legacy_fab_password_view_registration but describes register_views; move it back down with that method.
  • superset/security/manager.py:4233-4236 — A or B and C relies on operator precedence; wrap (isinstance(baseview, type) and issubclass(...)) in parens for readability.

Reviewed by EnxDev's Review Agent — @EnxDev · HEAD 561d932.

@rusackas

Copy link
Copy Markdown
Member

Thanks for chasing this down, @jayvenn21. Think there seems to be a regression here though:

password_change.py:187 hardcodes ResetMyPasswordView.this_form_get as the redirect target for the forced-password-change flow (ENABLE_FORCE_PASSWORD_CHANGE). With the new flag defaulting ENABLE_LEGACY_FAB_PASSWORD_VIEWS to False, that endpoint no longer exists, so url_for fails and the hook falls back to logging the user out instead of letting them reset. Anyone with password_must_change set would just get bounced to login/logout in a loop, never able to actually change their password. Would be good to add a test that exercises both flags together.

Also, @dpgaspar's suggestion of a cleaner FAB-side config flag (like FAB_ADD_SECURITY_VIEWS) doesn't seem to have been followed up on. The PR ended up monkeypatching appbuilder.add_view_no_menu instead. Did the FAB PR not happen, or is there a reason the local patch would be preferred? Would rather not merge a workaround like that without closing that loop first.

@bito-code-review

bito-code-review Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #48d118

Actionable Suggestions - 0
Additional Suggestions - 1
  • superset/security/manager.py - 1
    • Null view_menu dereference · Line 3077-3077
      The new filter dereferences `pvm.view_menu.name` without a null check. `_get_all_pvms` uses `joinedload` on `view_menu`, and `create_missing_perms` already guards with `if pv.permission and pv.view_menu`, so `view_menu` can be `None`. A PVM row with a null `view_menu_id` would raise `AttributeError` during `sync_role_definitions` at startup. Add a `pvm.view_menu and` guard.
Review Details
  • Files reviewed - 4 · Commit Range: cb84706..eeeed14
    • superset/config.py
    • superset/security/manager.py
    • tests/integration_tests/core_tests.py
    • tests/unit_tests/security/manager_test.py
  • Files skipped - 1
    • UPDATING.md - Reason: Filter setting
  • 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 an incremental AI Review.

  • /review full - 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 [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

):
assert "ResetPasswordView" in view_menus
else:
assert "ResetPasswordView" not in view_menus

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.

Could we make this assertion independent of pre-existing role metadata? I can reproduce a failure with:

pytest tests/integration_tests/core_tests.py -k "admin_only_menu_views or legacy_fab_password_views_are_not_registered" -q

ResetPasswordView is still attached to Admin until sync_role_definitions() runs, because skipping route registration does not itself rewrite persisted role assignments. That makes this test depend on whether the test database was created fresh or upgraded. The unit test below already covers the role-sync behavior, so the cleanest option may be to keep this integration test focused on the registered endpoints; alternatively, explicitly run/setup role sync before asserting the role contents.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good catch. I dropped the Admin assertion from that integration test, so it only checks that Alpha/Gamma never get ResetPasswordView, and left the role-sync behavior to the unit tests.

@github-actions github-actions Bot added the requires:rebase Requires rebasing on top of current master label Sep 14, 2026
def add_view_no_menu_without_legacy_password_views(
baseview: Any, *args: Any, **kwargs: Any
) -> Any:
if isinstance(baseview, legacy_password_views) or (

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The FAB user-info and admin-user pages still render their reset actions, but those POST handlers call url_for() for the views skipped here, so clicking either button now raises BuildError and returns a 500. Could the flag also suppress or redirect those actions so every still-reachable launcher has a valid destination?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah, that was a 500 waiting to happen. With the views skipped, the matching resetpasswords / resetmypassword actions on the user view are now hidden from the show and list widgets, and a direct request to either answers 404 instead of hitting url_for.


pvms = self._get_all_pvms()

if excluded_view_menus := self._legacy_password_view_menus_to_exclude():

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

After superset init runs with the default flags, this filter removes the reset-view permissions, but changing either flag only re-registers routes on web startup. An operator who later enables the documented escape hatch still gets access denied, while enabling forced password change can redirect affected users to a view they cannot access; could route registration and role assignment be kept in sync without requiring another undocumented init?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No other FAB view-registration setting hot-reloads, and Superset builds the appbuilder with update_perms=False, so permissions only ever move at superset init anyway. I documented that in the config comment and UPDATING.md instead: flipping either flag means a restart plus superset init.

Comment thread UPDATING.md Outdated
### Legacy FAB password reset routes are no longer registered by default

The legacy Flask-AppBuilder SSR password reset views are no longer registered
by default. `/superset/resetpassword` (admin-triggered password reset) is no

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These paths do not match the FAB routes: the forms are mounted at /resetpassword/form and /resetmypassword/form, without a /superset prefix. Could this migration note name the actual URLs so operators audit and update the right links?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oops, fixed. The note (and the config comment) now name /resetpassword/form and /resetmypassword/form.

@rusackas

Copy link
Copy Markdown
Member

Still conflicting with master, and the required checks are failing. sadpandajoe also flagged a couple of live regressions from removing these routes (BuildError/500 on the FAB reset-password launchers, and the flag only re-registering routes on restart), plus a wrong path in the UPDATING.md note. All still open. Holding until those land and it rebases. Holler if you want a hand with any of this.

@rusackas
rusackas force-pushed the fix/37700-gate-legacy-fab-password-views branch from eeeed14 to 6ba4884 Compare September 17, 2026 19:29
@github-actions github-actions Bot removed the requires:rebase Requires rebasing on top of current master label Sep 17, 2026

@bito-code-review bito-code-review Bot 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.

Code Review Agent Run #147aa7

Actionable Suggestions - 4
  • tests/unit_tests/security/manager_test.py - 2
  • tests/integration_tests/core_tests.py - 2
Additional Suggestions - 3
  • tests/unit_tests/security/manager_test.py - 3
    • Duplicated Config Restore Pattern · Line 4358-4369
      This hand-rolled save/restore of `current_app.config` (save at 4358-4365, restore in the finally at 4379) duplicates the `mocker.patch.dict` pattern this same file already uses at line 70, with a comment there explaining it prevents config leaks into the module-scoped app. Prefer `mocker.patch.dict` here and in the sibling test at 4894-4905 for consistency and less teardown boilerplate.
    • Duplicated Config Restore Pattern · Line 4894-4905
      Second instance of the hand-rolled config save/restore (save at 4894-4901, restore at 4905), duplicating the `mocker.patch.dict` idiom documented at line 68-74 of this file and the sibling test at 4358-4380. Using `mocker.patch.dict` removes the try/finally boilerplate and keeps config isolation uniform across the module.
    • Fragile Mock Args Unpack · Line 4907-4908
      `role_name, _classifier_fn, synced_pvms = call.args` assumes `set_role` is always invoked positionally; a keyword-arg call would leave `call.args` empty and raise `ValueError: not enough values to unpack`, masking the intended assertion message. Today `sync_role_definitions` passes positionally (manager.py:3103-3116), so this is forward-proofing rather than a current failure.
Review Details
  • Files reviewed - 4 · Commit Range: a40425a..6ba4884
    • superset/config.py
    • superset/security/manager.py
    • tests/integration_tests/core_tests.py
    • tests/unit_tests/security/manager_test.py
  • Files skipped - 1
    • UPDATING.md - Reason: Filter setting
  • 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 an incremental AI Review.

  • /review full - 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 [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

Comment on lines +4342 to +4343
from flask import current_app
from flask_appbuilder.security.views import ResetMyPasswordView, ResetPasswordView

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.

Inline Imports Violate Rule

from flask import current_app at 4342 duplicates the module-level import on line 27, and the flask_appbuilder.security.views import has no circular-dependency justification (this module already imports flask_appbuilder at top level, lines 28-29). Repo rule requires module-level imports unless a documented circular dependency exists; delete the flask re-import and hoist the FAB view import.

Code Review Run #147aa7


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fair, hoisted both to module level and dropped the duplicate current_app import.

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.

The changes correctly address the review suggestion by moving the imports to the module level and removing the duplicate import. This aligns with the repository's import rules and maintains clean code structure.

Comment on lines +4371 to +4373
original_add_view_no_menu: Callable[..., Any] = fake_appbuilder.add_view_no_menu
try:
original_add_view_no_menu = sm._skip_legacy_fab_password_view_registration()

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.

Dead Redundant Assignment

Line 4371 initializes original_add_view_no_menu from fake_appbuilder.add_view_no_menu, but line 4373 immediately rebinds it to _skip_legacy_fab_password_view_registration() return value before any read; on the early-raise path the finally at 4380 restores a value identical to what the namespace already holds. Drop the 4371 initializer and the now-unused Callable import added on line 23.

Code Review Run #147aa7


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yep, dropped the initializer and the Callable import.

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.

Understood. Removing the redundant initializer and the unused import is the correct approach to clean up the code in that test case.

Comment on lines +124 to +127
def test_admin_only_menu_views(self) -> None:
def assert_admin_view_menus_in(
role_name: str, assert_func: Callable[[str, list[str]], None]
) -> None:

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.

Missing docstrings on new test

New test method test_admin_only_menu_views and its nested helper assert_admin_view_menus_in carry no docstrings. BITO.md adaptive rule 12147 requires docstrings on all new Python functions, helpers, and test methods, and rule 12148 covers new test functions specifically. Adding one-line docstrings keeps the new typing-heavy signature consistent with the org documentation standard.

Code Review Run #147aa7


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Added, thanks.

assert_admin_view_menus_in("Alpha", self.assertNotIn)
assert_admin_view_menus_in("Gamma", self.assertNotIn)

def test_legacy_fab_password_views_are_not_registered(self) -> None:

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.

Missing docstring on new test

New test test_legacy_fab_password_views_are_not_registered has no docstring. BITO.md adaptive rule 12148 mandates a docstring on every newly added test function documenting purpose, scenario, and expected outcome. It is especially useful here because the assertions branch on ENABLE_LEGACY_FAB_PASSWORD_VIEWS and ENABLE_FORCE_PASSWORD_CHANGE rather than asserting a single fixed outcome.

Code Review Run #147aa7


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Added, thanks.

@github-actions github-actions Bot added the requires:rebase Requires rebasing on top of current master label Sep 18, 2026
jayvenn21 and others added 11 commits September 22, 2026 18:15
Prevent direct URL access to /superset/resetpassword and
/superset/resetmypassword when ENABLE_LEGACY_FAB_PASSWORD_VIEWS is False
(default). Unregister FAB ResetPasswordView and ResetMyPasswordView
blueprints so these SSR views are not user-accessible post-frontend port.

Fixes apache#37700
…w gating

Addresses two open review comments on this PR: document what
_skip_legacy_fab_password_view_registration does/returns, and note the
route-removal behavior change in UPDATING.md so operators relying on the
legacy SSR password reset routes know how to opt back in.

Co-Authored-By: Evan Rusackas <[email protected]>
Co-Authored-By: Claude Sonnet 5 <[email protected]>
On an upgraded install, a ResetPasswordView permission/view-menu row
persisted from before ENABLE_LEGACY_FAB_PASSWORD_VIEWS existed would still
get handed to Admin by sync_role_definitions even though the flag disables
the view's registration. Exclude it (and ResetMyPasswordView, when
applicable) from role sync when the flag says they shouldn't be registered,
and add a regression test covering the stale-row case.

Co-Authored-By: Evan Rusackas <[email protected]>
Co-Authored-By: Claude Sonnet 5 <[email protected]>
…nly flag

Review follow-ups for the ENABLE_LEGACY_FAB_PASSWORD_VIEWS gate:

- Hide the user view's "Reset Password" / "Reset my password" actions when
  their target view is skipped, and answer 404 on a direct request, instead
  of letting FAB's url_for raise BuildError (a 500).
- Centralize the skip rule in _legacy_password_views_to_skip so route
  registration, launcher hiding and role sync all agree.
- Document that the flag is read at startup and permissions only move at
  `superset init`, and name the actual /resetpassword/form and
  /resetmypassword/form routes in config.py and UPDATING.md.
- Make the admin-only-menu integration test independent of persisted role
  metadata, add docstrings to the new tests, hoist the test imports and
  drop the dead assignment.

Co-Authored-By: Evan Rusackas <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
@rusackas
rusackas force-pushed the fix/37700-gate-legacy-fab-password-views branch from 6ba4884 to 9a24ed8 Compare September 23, 2026 01:47
@rusackas

Copy link
Copy Markdown
Member

@msyavuz to answer your question: yes, with the flag off there's no UI left for an admin to reset someone else's password. The FAB "Reset Password" button is hidden (it was 500ing anyway), the SPA edit-user modal has no password field, and only PUT /api/v1/security/users/<id> with a password still does it. Self-service resets still work from the SPA profile page, and ENABLE_LEGACY_FAB_PASSWORD_VIEWS = True brings the legacy forms back. Whether that's an acceptable default, or whether we want password fields on the SPA edit modal first, is the call I'd like from you, @dpgaspar and @sadpandajoe before this merges.

Also rebased on master and worked through the open threads: the reset launchers no longer 500, the UPDATING.md paths are fixed, the restart plus superset init requirement is documented, and the integration test no longer depends on DB state.

@github-actions github-actions Bot removed the requires:rebase Requires rebasing on top of current master label Sep 23, 2026
@bito-code-review

bito-code-review Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #f13cd5

Actionable Suggestions - 0
Additional Suggestions - 1
  • superset/config.py - 1
    • Redundant bool annotation · Line 2177-2177
      `ENABLE_LEGACY_FAB_PASSWORD_VIEWS: bool = False` is the only FAB view-registration setting here with an explicit annotation; neighbors `FAB_ADD_SECURITY_VIEWS`, `FAB_API_KEY_ENABLED` (superset/config.py:2154-2164) and `ENABLE_FORCE_PASSWORD_CHANGE` (superset/config.py:423) use bare assignments, and mypy infers `bool` from the literal. Per repo rule 13982, rely on inference for module-level constants to keep the config block uniform. ([BITO.md adaptive rule 13982])
Review Details
  • Files reviewed - 4 · Commit Range: 4bec80e..9a24ed8
    • superset/config.py
    • superset/security/manager.py
    • tests/integration_tests/core_tests.py
    • tests/unit_tests/security/manager_test.py
  • Files skipped - 1
    • UPDATING.md - Reason: Filter setting
  • 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 an incremental AI Review.

  • /review full - 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 [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@EnxDev EnxDev 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.

Went through the latest push. The reset launchers are hidden and dispatch to the 404 handler in the real app's user view, not just the unit test's stub, the UPDATING paths are right, and the stale-perm exclusion does what it says.

Two notes inline: the red unit-tests job, and the forced-change redirect loop. babel-extract and the pot-drift test fail on master too, and execution_claim_test passes locally, so that one looks like a flake.

return ()
if current_app.config.get("ENABLE_FORCE_PASSWORD_CHANGE", False):
return (ResetPasswordView,)
return (ResetPasswordView, ResetMyPasswordView)

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.

This is what's turning unit-tests red: the positive control at the end of test_enforcement_exempts_health_blueprint (tests/unit_tests/security/test_password_change.py:146) expects / to redirect to /resetmypassword/form, but that test's app boots with ENABLE_FORCE_PASSWORD_CHANGE off, so the view gets skipped here and the hook falls back to /logout/. Passes on master, fails GET and HEAD on this branch.

Booting the app with the flag on fixes it (that file plus manager_test.py go 202/202 locally):

@pytest.mark.parametrize("app", [{"ENABLE_FORCE_PASSWORD_CHANGE": True}], indirect=True)
@pytest.mark.parametrize("method", ["GET", "HEAD"])
def test_enforcement_exempts_health_blueprint(


:returns: view-menu names to exclude from role assignment
"""
return {view.__name__ for view in self._legacy_password_views_to_skip()}

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.

If the superset init step gets missed after turning ENABLE_FORCE_PASSWORD_CHANGE on, flagged users don't get an access-denied page, they get an endless redirect: with no built-in role holding can_this_form_get on ResetMyPasswordView, the form bounces to /login/ and the hook sends /login/ straight back (reproduced locally, Admin included since its perms go through this filter too).

Could ResetMyPasswordView stay out of this exclusion set? A perm on an unrouted view is harmless, and upgraded installs would then keep working whichever way the flag gets flipped.

@rusackas

Copy link
Copy Markdown
Member

Thanks again for pushing this along, @jayvenn21. Mulling it over, I'd rather not carry a flag for pages nobody asked to keep, so I went the other way and removed the views outright, with the SPA picking up the admin reset, self-service and forced-change flows. That's up as #44626, with your registration intercept and tests carried over and you credited as co-author. Closing this one in favor of it.

@rusackas rusackas closed this Sep 25, 2026
rusackas added a commit that referenced this pull request Sep 28, 2026
…rd resets into the SPA

The Flask-AppBuilder server-rendered ResetPasswordView and
ResetMyPasswordView (/resetpassword/form, /resetmypassword/form) survived
the SPA migration and were still reachable in 6.0 (#37700). Rather than
gating them behind a config flag (#37773), remove them for good and make
the SPA cover every flow they served:

- register_views() intercepts add_view_no_menu for the duration of FAB's
  own registration so the two views never reach the URL map; the "Reset
  Password" / "Reset my password" launchers on the FAB user pages are
  hidden and answer 404 instead of raising BuildError; and
  sync_role_definitions stops assigning the stale ResetPasswordView,
  ResetMyPasswordView and UserDBModelView launcher permissions that an
  upgraded metadata database still carries.
- The Users list edit modal gains optional "New password" / "Confirm new
  password" fields wired to PUT /api/v1/security/users/<id>, the admin
  path that never required a current password. PUT /api/v1/me/ keeps
  requiring current_password for self-service changes.
- The profile page's "Reset my password" modal now sends current_password,
  which /api/v1/me/ has required since #42934, so the SPA self-service
  flow works again.
- The forced-password-change hook (ENABLE_FORCE_PASSWORD_CHANGE) redirects
  to /user_info/ instead of the removed view, exempting the profile page,
  the current-user API and the CSRF endpoint so the page is usable, and a
  successful self-service change through /api/v1/me/ clears
  password_must_change in the same unit of work as the new hash.

Fixes #37700
Supersedes #37773

Co-authored-by: jayvenn21 <[email protected]>
Co-Authored-By: Evan Rusackas <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
rusackas added a commit that referenced this pull request Sep 30, 2026
…rd resets into the SPA

The Flask-AppBuilder server-rendered ResetPasswordView and
ResetMyPasswordView (/resetpassword/form, /resetmypassword/form) survived
the SPA migration and were still reachable in 6.0 (#37700). Rather than
gating them behind a config flag (#37773), remove them for good and make
the SPA cover every flow they served:

- register_views() intercepts add_view_no_menu for the duration of FAB's
  own registration so the two views never reach the URL map; the "Reset
  Password" / "Reset my password" launchers on the FAB user pages are
  hidden and answer 404 instead of raising BuildError; and
  sync_role_definitions stops assigning the stale ResetPasswordView,
  ResetMyPasswordView and UserDBModelView launcher permissions that an
  upgraded metadata database still carries.
- The Users list edit modal gains optional "New password" / "Confirm new
  password" fields wired to PUT /api/v1/security/users/<id>, the admin
  path that never required a current password. PUT /api/v1/me/ keeps
  requiring current_password for self-service changes.
- The profile page's "Reset my password" modal now sends current_password,
  which /api/v1/me/ has required since #42934, so the SPA self-service
  flow works again.
- The forced-password-change hook (ENABLE_FORCE_PASSWORD_CHANGE) redirects
  to /user_info/ instead of the removed view, exempting the profile page,
  the current-user API and the CSRF endpoint so the page is usable, and a
  successful self-service change through /api/v1/me/ clears
  password_must_change in the same unit of work as the new hash.

Fixes #37700
Supersedes #37773

Co-authored-by: jayvenn21 <[email protected]>
Co-Authored-By: Evan Rusackas <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

authentication:fab Related to authentication with FAB size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reset My Password and Reset Password views are still accessible in Superset 6.0.0 after the major frontend porting.

6 participants