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

Widgetize request with token_auth param fails if superuser session exists #17335

Closed
carlgrundberg opened this issue Mar 11, 2021 · 3 comments · Fixed by #17520
Closed

Widgetize request with token_auth param fails if superuser session exists #17335

carlgrundberg opened this issue Mar 11, 2021 · 3 comments · Fixed by #17520
Assignees
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Milestone

Comments

@carlgrundberg
Copy link

carlgrundberg commented Mar 11, 2021

As your documentation says I have created a view-only user with a token and when using that token to show a widget I'm getting an error saying "This user has superuser access". It works if I load the same url while logged out or in another browser. Seems odd if it shouldn't work since this should be a fairly common case.

Example url: http://localhost:8000/index.php?module=Widgetize&action=iframe&forceView=1&disableLink=1&token_auth=xxx&moduleToWidgetize=VisitsSummary&actionToWidgetize=getEvolutionGraph&viewDataTable=graphEvolution&idSite=1&date=2021-02-09,2021-03-10&period=range

Expected Behavior

It should be possible to show the widget even if you are currently logged in as a super user in the same browser.

Current Behavior

Error message saying
"This user has super user access. For embedding widgets super user token auths are not allowed. See our faq for more information."

Possible Solution

I have tried to follow the code and it seems that when using the token_auth parameter there is a call to the method Request::reloadAuthUsingTokenAuth eventually landing in Access::reloadAccess, however it return without reloading since $this->hasSuperUserAccess is still true from the session auth.

Steps to Reproduce (for Bugs)

  1. Create user with view permissions and generate a token
  2. Create a widgetized url and add the token to the url
  3. Load the url in a browser where you are logged in as a super user

Context

We are trying to embed widgets in an external dashboard.

Your Environment

I'm running your latest docker image.

  • Matomo Version: 4.2.1
@carlgrundberg carlgrundberg added the Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced. label Mar 11, 2021
@flamisz
Copy link
Contributor

flamisz commented Mar 11, 2021

Hi @carlgrundberg, thanks for creating this issue. Very appreciated.
I've just tried it and I was able to reproduce this.
It is definitely a bug. Sorry about it, we’ll do our best so we can hopefully get things sorted soon.

@flamisz flamisz added Bug For errors / faults / flaws / inconsistencies etc. and removed Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced. labels Mar 11, 2021
@flamisz
Copy link
Contributor

flamisz commented Mar 11, 2021

I tried it with admin user as well and got another error message:

This user has at least some write access. Only tokens of users who have only view access can be used.

The token I used was a view token.

@tsteur tsteur added this to the 4.5.0 milestone Mar 11, 2021
@carlgrundberg
Copy link
Author

Thanks for confirming. I guess it would make more sense to check if a token-param exists before setting up the session auth, to avoid authenticating twice. But maybe it's hard to change in the current execution flow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants