Skip to content

com_resources: restrict /api/resources/list to the caller's access level - #1910

Open
denphi wants to merge 1 commit into
hubzero:2.4-mainfrom
denphi:fix/resources-api-list-access
Open

com_resources: restrict /api/resources/list to the caller's access level#1910
denphi wants to merge 1 commit into
hubzero:2.4-mainfrom
denphi:fix/resources-api-list-access

Conversation

@denphi

@denphi denphi commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

listTask filtered on standalone, published and the publish window only, so GET /api/resources/list returned registered-, protected- and private-level entries to anonymous callers, including their titles, introtext and fulltxt.

Apply the same rule the site views use: public for everyone, plus registered-level once authenticated. Component administrators keep the unrestricted view, so the admin searchable path in v1.1 is unaffected.

Two related fixes in the same task:

  • type is documented as a type name but was compared straight against the numeric column, so only ids ever matched and an alias silently returned everything. Resolve an alias to its id, and let an unknown alias match nothing.

  • v1.1 referenced Config:: and User:: without importing them. Inside namespace Components\Resources\Api\Controllers those resolve to classes in that namespace, so the first call would throw "class not found". v1.0 already used a leading backslash for Config.

Before you submit this pull request, please make sure:

  • [] Make sure there are links in the PR to the source JIRA card(s) and hubzero ticket(s)
  • [] Include a brief summary of the issue in your own words
  • [] Include a brief summary of the fix/changed code
  • [] Include a brief summary of your testing. What did you specifically do to investigate that this change has the correct results?
  • [] Indicate if the change needs to be hotfixed to any production hubs before a normal core rollout
  • [] Double check someone is assigned to review the ticket

Thanks!

listTask filtered on standalone, published and the publish window only, so
GET /api/resources/list returned registered-, protected- and private-level
entries to anonymous callers, including their titles, introtext and fulltxt.

Apply the same rule the site views use: public for everyone, plus
registered-level once authenticated. Component administrators keep the
unrestricted view, so the admin `searchable` path in v1.1 is unaffected.

Two related fixes in the same task:

- `type` is documented as a type name but was compared straight against the
  numeric column, so only ids ever matched and an alias silently returned
  everything. Resolve an alias to its id, and let an unknown alias match
  nothing.

- v1.1 referenced Config:: and User:: without importing them. Inside
  `namespace Components\Resources\Api\Controllers` those resolve to classes in
  that namespace, so the first call would throw "class not found". v1.0 already
  used a leading backslash for Config.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@denphi
denphi requested a review from nkissebe as a code owner July 28, 2026 16:46
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.

1 participant