Skip to content

Gate browsing and searching on a view access level (supersedes #1896) - #1938

Merged
nkissebe merged 4 commits into
2.4-mainfrom
search-access
Oct 7, 2026
Merged

nkissebe merged 4 commits into
2.4-mainfrom
search-access

Conversation

@nkissebe

@nkissebe nkissebe commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Supersedes #1896, carrying its three non-merge commits and adding one rework commit, as proposed in the review there.

What changes relative to #1896

  • The per-component "allow public search" boolean becomes a browse_access (tags: search_access) config field of type accesslevel, default Public. The hub's existing view levels (Public, Registered, Special, and any a hub defines) are the vocabulary, as they already are for com_projects' default access.
  • One helper on Hubzero\Component\SiteController, requireViewLevel($level, $message), replaces the three copied redirect blocks: a guest without the level is sent to log in with a return URL, a logged-in user without it gets a 403. The 410 Gone for a guest tag-filtered publications browse is gone.
  • The level is enforced everywhere a guest could list or search, not just one task per component: publications browse; resources browse, the tag browser (on by default, so Disabled public search as an option #1896's browse fallback never ran) and the AJAX browser; the tags view and its feed, counted on the de-duplicated tag list so /tags/foo, is not a multi-tag search; the resources API list when search is given; and the publications and resources site-search plugins.

Verified

  • ViewLevelGateTest (new) covers the pass, guest-redirect and logged-in-403 paths; lint clean, config XML well-formed, no leftover references to the old option.
  • On this hub with the default (Public) level, /publications/browse, /resources, /resources/tools, /tags/a,b, /tags/a,b/feed, /search?terms=… and /api/resources/list?search=… all behave as before with no PHP diagnostics. (/publications/browse?tag=… returns 403 here with or without this change; that is an Apache rule on this hub, not PHP.)

Note for hubs that enabled #1896's option on a dev branch: the old allow_public_search=0 has no effect any more; set the component's browse access to Registered to get the same behaviour.

🤖 Generated with Claude Code

denphi and others added 4 commits October 7, 2026 13:58
…nt boolean

Rework of the three previous commits, which added an "allow public
search" radio to publications, resources and tags and bounced guests to
log in from one entry point each. The intent, keeping bots off the
expensive listing queries, is kept; the mechanism changes:

- Each component gets a browse_access (tags: search_access) config field
  of type accesslevel, default Public, so nothing changes on hubs that
  leave it alone. "Registered only" is one choice among the hub's view
  levels rather than a special case.
- SiteController gains canView($level) and requireViewLevel($level,
  $message). A guest without the level is sent to log in with a return
  URL; a logged-in user without it gets a 403. The three copies of the
  redirect block go away, as does the 410 Gone that publications threw
  for a guest tag-filtered browse, which told crawlers a valid URL was
  permanently gone.
- The level is enforced on every listing and search path, not one per
  component: publications browse; resources browse, the tag browser
  (on by default, so the browse fallback never ran) and the AJAX
  browser; the tags view and its feed, counting the de-duplicated tags
  rather than the raw list so "/tags/foo," is not a multi-tag search;
  the resources API list when a search term is given; and the
  publications and resources search plugins.

ViewLevelGateTest covers the pass, guest-redirect and logged-in-403
paths of the helper.
@nkissebe
nkissebe merged commit d825674 into 2.4-main Oct 7, 2026
0 of 2 checks passed
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.

2 participants