Make sure to initialize a session for the anonymous user #16423
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What happened is that every time an anonymous user would view a widget or report in the Matomo UI it would log a failed authentication (for brute force check) and eventually the anonymous user would be blocked. This is because of the code here: https://github.com/matomo-org/matomo/blob/4.0.0-a1/core/Access.php#L171-L174
The session auth always thinks that the session is expired because for anonymous user we had actually never started a session. When someone logs in, we would start the session in the login controller in https://github.com/matomo-org/matomo/blob/4.0.0-a1/plugins/Login/Controller.php#L309 but for anonymous users there is no log in.
Therefore initialising the session now when needed in the frontcontroller.