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

Custom token check when updating from 3.x to 4.X #16318

Closed
wants to merge 1 commit into from
Closed

Conversation

tsteur
Copy link
Member

@tsteur tsteur commented Aug 18, 2020

Follow up from #16316

The token_auth check wouldn't work there because it would check against the new app specific token auth table which wouldn't exist yet at the time this is executed. At this time only the files would be updated but no DB migration executed yet meaning it can't authenticate the user.

Haven't tested this code yet. Any other idea @sgiehl @diosmosis ? The only other thing I can think of be to use redirects in https://github.com/matomo-org/matomo/pull/16316/files#diff-f879da4f4ea7f582701f6cd753dad715R133 instead of issuing an HTTP request. But the upgrade to Matomo 4 would maybe destroy the session so this would maybe not work.](url)

@tsteur
Copy link
Member Author

tsteur commented Aug 18, 2020

Or we could generate a random token in step1 in option table and check for that in the second step instead of the check super user access?

@diosmosis
Copy link
Member

@tsteur instead of a token auth, can we just use a temporary nonce? eg, before calling it in the update process, we create a a random nonce and store it somewhere (option table, maybe) set it in a query param, then in this controller action, check the query param == the stored nonce, and that it was invoked within a couple minutes. if it matches, remove stored nonce and continue updating. this ensures the only way the controller action can be called is during the update process

$userTableColumns = DbHelper::getTableColumns($userTable);
if (empty($token)
|| (int) \Piwik\Updater::getCurrentComponentVersion('core') >= 4
|| !isset($userTableColumns[$userTableColumns])
Copy link
Member

Choose a reason for hiding this comment

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

That seems incorrect. Guess the checked index needs to be something else?

@tsteur
Copy link
Member Author

tsteur commented Aug 19, 2020

will replace this PR with a better solution

@tsteur tsteur closed this Aug 19, 2020
@tsteur tsteur deleted the accesscheck branch August 19, 2020 01:06
@mattab mattab added this to the 4.0.0 milestone Sep 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants