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

Do not initiate auth instance if a user is already logged in in FrontController::init() #15591

Merged
merged 2 commits into from Feb 26, 2020

Conversation

diosmosis
Copy link
Member

@tsteur think this will solve the problem for the wp-matomo command?

Fixes #15550

@diosmosis diosmosis added not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. Needs Review PRs that need a code review labels Feb 19, 2020
@diosmosis diosmosis added this to the 3.13.3 milestone Feb 19, 2020
// user may already be logged in when init() is called, eg, in a CLI command
if (!Access::getInstance()->isUserLoggedIn()) {
// try authenticating w/ session first...
$sessionAuth = $this->makeSessionAuthenticator();
Copy link
Member

Choose a reason for hiding this comment

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

@diosmosis I'm not sure re possible side effects or so.

I wonder... if technically someone could do something like this

$_GET['token_auth'] = ...
FrontController::getInstance()->dispatch()

if that could be any issue. Or if the user may be temporarily logged in using doAsSuperUser but then the Access::$login is not reset or so.

It might be a great fix I'm just unable to tell re side effects etc it's so tricky! In generally it does sound good though cause there should be a need to authenticate again. Unless maybe for some random use case, not sure. I reckon we could do this only on CLI and maybe only skip the session auth? Or always skip session auth on CLI since there is no session? Might be more "secure" in terms of possible side effects?

Copy link
Member Author

@diosmosis diosmosis Feb 21, 2020

Choose a reason for hiding this comment

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

I guess it makes sense to just skip sessionauth if in cli mode. Can't imagine how it would work when used in cli mode...

Copy link
Member Author

Choose a reason for hiding this comment

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

@tsteur sound good to change it to:

if (!Access::getInstance()->isPhpCliMode()) {
    ...

?

Copy link
Member

Choose a reason for hiding this comment

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

👍 Although I reckon you mean Common::isPhpClimode?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes :) don't know how that got past me :)

@tsteur tsteur modified the milestones: 3.13.3, 3.13.4 Feb 19, 2020
@tsteur
Copy link
Member

tsteur commented Feb 19, 2020

btw moving this into 3.13.4 for now. I reckon it's actually not needed in 3.13.3

@diosmosis
Copy link
Member Author

@tsteur ready for another review

@tsteur tsteur merged commit 2ffc440 into 3.x-dev Feb 26, 2020
@tsteur tsteur deleted the 15550-no-session-auth branch February 26, 2020 00:31
jonasgrilleres pushed a commit to 1024pix/pix-analytics that referenced this pull request Sep 22, 2020
jbuget pushed a commit to 1024pix/pix-analytics that referenced this pull request Sep 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants