-
Notifications
You must be signed in to change notification settings - Fork 207
Bug 2073282 - Add deprecated api_key=<key> query-parameter fallback to native Mojo REST auth #2753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,8 +114,10 @@ Send only one authentication method with each request. BMO does not combine | |
| credentials or choose the strongest method when more than one is supplied. | ||
|
|
||
| Most resources have been migrated off the legacy authentication path onto BMO's | ||
| native REST framework, which accepts only a cookie, an ``X-Bugzilla-API-Key`` | ||
| header, or an OAuth2 bearer token. Legacy ``Bugzilla_login`` and | ||
| native REST framework, which accepts a cookie, an ``X-Bugzilla-API-Key`` | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "described in the warning below" overstates it — that warning covers |
||
| header, or an OAuth2 bearer token (plus the deprecated ``api_key`` query | ||
| parameter described in the warning below, kept only as a stopgap for | ||
| undiscovered callers). Legacy ``Bugzilla_login`` and | ||
| ``Bugzilla_password`` credentials are **not** accepted on these resources, even | ||
| though the old WebService dispatcher underneath BMO still supports them for | ||
| resources not yet migrated (currently ``Bug``, ``Group``, ``Product``, and | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,13 @@ $t->get_ok($url . $endpoint)->status_is(401); | |
| $t->get_ok($url . $endpoint => {'X-Bugzilla-API-Key' => $api_key}) | ||
| ->status_is(200)->json_has('/result'); | ||
|
|
||
| # | ||
| # 2a. Deprecated fallback: an API key passed as the ?api_key= query parameter | ||
| # also works (bug 2073282), same as the legacy WebService dispatcher. | ||
| # | ||
| $t->get_ok($url . $endpoint . '&api_key=' . $api_key) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. worth adding a case where both the header and that precedence is security relevant — |
||
| ->status_is(200)->json_has('/result'); | ||
|
|
||
| # | ||
| # 3. Authentication via the login cookie + Bugzilla_api_token parameter works. | ||
| # This is the mechanism the web UI (Bugzilla.API) uses, and is the path that | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two gaps versus the legacy dispatcher this is meant to match
fix_credentialsaccepts bothapi_keyandBugzilla_api_key(Bugzilla/WebService/Util.pm:330 promotes the short form, and Bugzilla/Auth/Login/APIKey.pm:54 reads the long form directly). the docs warning this PR now points to also lists both. a k8s-style caller sending?Bugzilla_api_key=<key>still gets a 401 on native resources, so the "undiscovered callers" case is only half coveredLooking through the logs, there are unfortunately some use of the Bugzilla_api_key query parameter in addition to api_key so we need to support both for now.
$c->paramreads urlencoded/multipart body params too, not just the query string. the code comment above says "query parameter", the docs change says "query parameter", and the test only covers the query string — so the deprecated surface being reopened is larger than what is described. either use$c->req->query_params->param('api_key')to keep the stopgap minimal, or say plainly that body params are accepted as well