Repository navigation
Bug 2099092 - Remove the obsolete api_key_only user preference now that the native REST API only accepts API keys, OAuth2 tokens, or cookie + api token - #2849
Conversation
…at the native REST API only accepts API keys, OAuth2 tokens, or cookie + api token All API endpoints now authenticate through the native Mojo login helper, which never consulted api_key_only and does not accept the username/password or login-token methods the preference blocked. The remaining checks in the legacy auth stack are unreachable from the API. - Drop the api_key_only checks from Auth::Login::Cookie and Auth::Verify::DB, along with the now unused invalid_auth_method error. - Remove the setting and delete existing rows via a new OBSOLETE_SETTINGS list processed by update_settings(). - Remove the MFA-gated save logic for the setting from userprefs.cgi and the related MFA page text, JS and CSS. - Remove the "(weakened)" marker and api_key_only field from the BMO group members report.
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the removal of the obsolete api_key_only preference and its related authentication, MFA, and UI handling.
No open issues 🎉
What changed in this PR
Removes the obsolete api_key_only preference now that the native REST API enforces supported authentication methods independently of this setting.
Changes:
- Deletes the preference and adds upgrade cleanup for stored settings and user choices.
- Removes preference-dependent authentication checks and MFA handling.
- Cleans up related UI text, styling, and group-report output.
| File | Description |
|---|---|
userprefs.cgi |
Removes MFA verification for disabling the preference and forced activation during enrollment. |
template/en/default/global/user-error.html.tmpl |
Removes the unused authentication-method error. |
template/en/default/global/setting-descs.none.tmpl |
Removes the preference description. |
template/en/default/account/prefs/settings.html.tmpl |
Removes the preference’s MFA protection icon. |
template/en/default/account/prefs/mfa.html.tmpl |
Removes obsolete API-key guidance from MFA screens. |
skins/standard/admin.css |
Removes the deleted MFA blurb’s selector. |
js/account.js |
Removes visibility handling for the deleted blurb. |
extensions/BMO/template/en/default/pages/group_members.html.tmpl |
Removes the preference-dependent “weakened” MFA marker. |
extensions/BMO/lib/Reports/Groups.pm |
Removes api_key_only from report JSON. |
Bugzilla/Install.pm |
Removes the setting definition and adds documented obsolete-setting cleanup. |
Bugzilla/Auth/Verify/DB.pm |
Removes the preference-dependent password authentication restriction. |
Bugzilla/Auth/Login/Cookie.pm |
Removes the preference-dependent cookie restriction and unused tracking variable. |
Review effort: Balanced
There was a problem hiding this comment.
Checked nothing is left behind, checksetup cleanup works and can run safely and nothing else depends on what was removed.
=> All looks good to me, thanks Dave! :)
Just one small thing, out of the review: OBSOLETE_SETTINGS constant has only one entry, a direct remove_setting('api_key_only') (as BugModal does) would be enough ;)
| } | ||
|
|
||
| foreach my $name (OBSOLETE_SETTINGS) { | ||
| remove_setting($name); |
There was a problem hiding this comment.
Do we deploy with old and new pods serving traffic at once? If checksetup deletes the setting rows while old code is still running, SaveMFAupdate on an old pod would call ->set('on') on an autovivified unblessed hash and die for anyone enrolling in MFA. Should we hold off on remove_setting until a later release, or is that window small enough not to matter?
| use constant OBSOLETE_SETTINGS => ( | ||
|
|
||
| # 2026-11-29 -- Bug 2099092 | ||
| 'api_key_only', |
There was a problem hiding this comment.
Could we add a test for OBSOLETE_SETTINGS (maybe alongside t/sqlite-memory.t), checking that update_settings() removes the setting, setting_value and profile_setting rows and that a second run is a no-op? The test plan says this was checked by hand, but it seems worth keeping as a regression test now that the list will grow.
| } | ||
| $is_internal = 1; | ||
| } | ||
| elsif ($login_cookie && Bugzilla->usage_mode == USAGE_MODE_REST) { |
There was a problem hiding this comment.
If no API request reaches Bugzilla::Auth::Login::Cookie anymore, aren't the rest of the i_am_webservice() branches here (Bugzilla_api_token, login_token, the invalid_cookies_or_token error) also dead? Should we file a follow-up to remove those too, so the next reader doesn't assume they still guard the API?
There was a problem hiding this comment.
Well spotted! 👍 And I agree: nothing calls Bugzilla->login() in a REST usage context anymore, the Mojo login plugin does its own checks, so the i_am_webservice() branches in Cookie.pm are dead (and probably most of Bugzilla::Auth::Login::APIKey, which returns AUTH_NODATA outside of them).
As it fits the REST-to-Mojo cleanup (2057358), I can file the follow-up and work on it, if everyone agrees.
| @@ -251,10 +251,6 @@ sub members_report { | |||
| $rh_user->{groups} = [$rh->{name}]; | |||
| $rh_user->{lastseeon} = $member->last_seen_date; | |||
| $rh_user->{mfa} = $member->mfa; | |||
There was a problem hiding this comment.
The bug says consumers of the group members JSON output should be told that api_key_only is going away. Do we know who uses it (e.g. security/compliance scripts), and has anyone been contacted yet?
Summary
Removes the
api_key_onlyuser preference ("Require API key authentication for API requests"). Every API endpoint now authenticates through the native Mojo login helper (Bugzilla/App/Plugin/Login.pm), which accepts only API keys, OAuth2 bearer tokens, or a login cookie plusBugzilla_api_token. The username/password and login-token methods this preference blocked are no longer accepted anywhere, so the setting had no effect.Follow-up of 2081819.
Changes
Bugzilla/Auth/Login/Cookie.pmandBugzilla/Auth/Verify/DB.pm: drop theapi_key_onlychecks, which can't be reached from the API, and the now unusedinvalid_auth_methoderror.Bugzilla/Install.pm: remove the setting and add anOBSOLETE_SETTINGSlist thatupdate_settings()passes toremove_setting(), so checksetup deletes the existingsetting,setting_valueandprofile_settingrows.userprefs.cgi: remove the MFA prompt for turning the setting off (MfaSettings) and stop forcing it on when MFA is enabled.js/account.js,skins/standard/admin.css: remove the API key blurb and the settings-row MFA icon.api_key_onlykey from the JSON output.Test plan
test_sanitypasses (65 files, 18124 tests)checksetup.plon an existing database: theapi_key_onlyrows are removed, and running it again is a no-oppage.cgi?id=group_members.htmlfor a privileged group: the MFA column shows the method without "(weakened)"References