[fix][views] apply the token owner's read right on the heatmap endpoint - #7935
Open
ar2rsawseen wants to merge 1 commit into
Open
[fix][views] apply the token owner's read right on the heatmap endpoint#7935ar2rsawseen wants to merge 1 commit into
ar2rsawseen wants to merge 1 commit into
Conversation
The countly-token branch of /o/actions resolves the target app from the caller supplied app_key and then served the data once the token itself verified. It never resolved the token to the member who created it, so that member's own rights were never consulted. Everywhere else a token acts as its owner: verify_return hands back the owner, and the usual validation loads that member and applies their rights, while the token's app and endpoint fields only narrow things further. This branch skipped that step, which left the optional app restriction as the only thing bounding which app could be read. A token saved without an app restriction is not narrowed at all, which is correct in itself, so nothing remained to bound the read. Load the owner and require a views read right on the app resolved from app_key, the way validateRead does for the api_key branch below it. The heatmap feature has been out of the product for over two years and this endpoint stays only so that a long-standing integration does not break, so this keeps the existing flow working: the dashboard mints its token scoped to the active app, and its owner holds the read right for that app.
ar2rsawseen
force-pushed
the
fix/actions-token-owner-rights
branch
from
August 14, 2026 18:56
25ee5fb to
bfa5f3f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
The
countly-tokenbranch of/o/actionsresolves the target app from the caller suppliedapp_key:and then served the data as soon as the token verified. The
ownerit gets back was never used for anything: the member was not loaded and no read right was checked, sogetHeatmapran withmatchQuery.aset to whatever app theapp_keynamed.Everywhere else a token acts as its owner.
verify_returnreturns the owner, thenvalidateUser/validateReadload that member and apply their real rights, while the token'sapp,endpointandttlfields only narrow it further. This branch skipped that step, which left the optional app restriction as the only thing bounding the read. A token saved without an app restriction is not narrowed at all, which is correct in itself, so nothing remained to bound it.Change
Load the token's owner and require a
viewsread right on the app resolved fromapp_key, mirroring whatvalidateRead(params, FEATURE_NAME, getHeatmap)already does for theapi_keybranch a few lines below.Compatibility
The heatmap feature has been out of the product for over two years and this endpoint stays only so a long-standing integration does not break, so the existing flow is preserved rather than tightened:
createToken("View heatmap", "/o/actions", true, countlyCommon.ACTIVE_APP_ID, 1800, ...)inplugins/views/frontend/public/javascripts/countly.views.js. Same call in every repo checked.verify_tokenis untouched: an empty app scope still means "not additionally restricted", which is correct on every path that applies the owner's rights.Verification
No automated test accompanies this change, and that is deliberate rather than an omission.
plugins/views/tests/heatmaps.jsis commented out ofplugins/views/tests/index.js, so anything added there would not run, and it cannot simply be re-enabled here: the suite readsplugins.drillfrom/o/apps/pluginsand connects tocountly_drill, neither of which exists in this repo's CI. Since the feature is no longer supported, re-plumbing a suite for it is not worth the cost.Checked by hand instead:
hasReadRight('views', app._id, member), the same helpervalidateReaduses for this feature, so the token branch and theapi_keybranch now apply the same rule.if (owner)body.lint,node --check, and the rest of CI cover the change mechanically.