Skip to content
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

Bug 1209148 - Stop using short-life token for internal REST API auth, which is problematic especially on My Dashboard, and rely on login cookie instead #782

Closed
wants to merge 1 commit into from

Conversation

kyoshino
Copy link
Collaborator

@kyoshino kyoshino commented Oct 1, 2018

Description

  • Internal Bugzilla_api_token is problematic and redundant. The existing login cookie can be used instead for API auth.
  • Public Bugzilla_token is a different thing, and it should not be affected by this change.

Bug

Bug 1209148 - Stop using short-life token for internal REST API auth, which is problematic especially on My Dashboard, and rely on login cookie instead

@kyoshino kyoshino self-assigned this Oct 1, 2018
@kyoshino
Copy link
Collaborator Author

kyoshino commented Oct 1, 2018

So... I tried, and looks like this is working. The real culprit is $login_cookie = '' in Cookie.pm.

@kyoshino kyoshino changed the title Bug 1209148 - "Failed to load flag list from Bugzilla: The token is not valid" when loading My Dashboard after being away for a few days Bug 1209148 - Stop using short-life token for internal REST API auth, which is problematic especially on My Dashboard, and rely on login cookie instead Oct 1, 2018
@kyoshino kyoshino requested a review from dylanwh October 1, 2018 21:57
@kyoshino kyoshino added perl review this PR needs someone that can review perl API API bugs and enhancements labels Oct 1, 2018
@kyoshino
Copy link
Collaborator Author

kyoshino commented Oct 5, 2018

/rest/bug/attachment/${id} I want to use for Bug 1496207 doesn't work when the Bugzilla_api_token param is set in the query string. It's a PUT request. I would like to this PR get reviewed and merged so the problem should be gone.

The requested method 'Bugzilla::Attachment::set_Bugzilla_api_token' was not found.

@kyoshino
Copy link
Collaborator Author

I just encountered the invalid token error on My Dashboard 😐

invalid token error

@kyoshino kyoshino removed the perl review this PR needs someone that can review perl label Nov 1, 2018
@floatingatoll
Copy link

floatingatoll commented Nov 1, 2018

I encountered this today after updating Nightly (I skipped the broken-cookie build), and am glad to see we're resolving it.

@kyoshino
Copy link
Collaborator Author

kyoshino commented Nov 1, 2018

This is basically a removal so no code review needed. Just want to make sure this works as expected and no security issues introduced.

@floatingatoll
Copy link

@kyoshino What circumstances can activate this code block today?

https://github.com/mozilla-bteam/bmo/pull/782/files#diff-e432c9f5510c145bfbb4a9eb373e5209L107

            # forbid logging in with a cookie if only api-keys are allowed
            if (i_am_webservice() && !$is_internal) {

@kyoshino
Copy link
Collaborator Author

kyoshino commented Nov 1, 2018

I meant: no review for newly added code is required...

And I think removing the forbid logging in with a cookie if only api-keys are allowed part is the right thing. It is the source of the issue, and we will instead rely on cookies.

@floatingatoll
Copy link

(I'd planned to ask that question in any case, but thank you for clarifying all the same!)

@kyoshino
Copy link
Collaborator Author

kyoshino commented Nov 1, 2018

Maybe @floatingatoll is right. That particular part should not be removed after all. I'm reverting it and only remove the is_internal check. But hmm, what happens then? I wasn't aware of the api_key_only setting.

@dylanwh
Copy link
Contributor

dylanwh commented Nov 1, 2018

I think api_key only might just have been for preventing CSRF attacks, which is now mitigated by SameSite cookies.

@kyoshino
Copy link
Collaborator Author

kyoshino commented Nov 1, 2018

So can we remove the api_key_only setting also?

Copy link
Collaborator

@dklawren dklawren left a comment

Choose a reason for hiding this comment

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

https://github.com/mozilla-bteam/bmo/blob/master/docs/en/rst/api/core/v1/general.rst

mentions Bugzilla_token and short form token= so the docs need to be updated as well.

@kyoshino
Copy link
Collaborator Author

kyoshino commented Nov 9, 2018

It’s very confusing but Bugzilla_token or token is a long-life token which is different from the undocumented Bugzilla_api_token param for internal API calls. We are going to only remove the latter in favour of cookies.

@kyoshino kyoshino added the defect Issues people complain about label Nov 9, 2018
Copy link
Contributor

@dylanwh dylanwh left a comment

Choose a reason for hiding this comment

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

since dkl requeted changes, I'll do the same so this drops off my radar.

@kyoshino
Copy link
Collaborator Author

This PR needs to be updated once #917 is merged.

@kyoshino kyoshino added WIP and removed WIP labels Jul 3, 2019
… which is problematic especially on My Dashboard, and rely on login cookie instead
@kyoshino kyoshino closed this Jun 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API API bugs and enhancements defect Issues people complain about needs test
Development

Successfully merging this pull request may close these issues.

4 participants