Skip to content

fix: allow unauthenticated access to package search for juliahub.com pkgserver - #52

Open
thelonewolf1603 wants to merge 2 commits into
mainfrom
nd/package-search-public
Open

fix: allow unauthenticated access to package search for juliahub.com pkgserver#52
thelonewolf1603 wants to merge 2 commits into
mainfrom
nd/package-search-public

Conversation

@thelonewolf1603

@thelonewolf1603 thelonewolf1603 commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

jh package search now works logged out — on juliahub.com only.
Package data there is public, so an unauthenticated search returns results instead of failing
with authentication required. Every other server (*.juliahub.dev, private
deployments) still requires auth.

Since the authenticated endpoints 401 when logged out, the anonymous path is
GraphQL-only: optionalToken returns (nil, nil) for juliahub.com when there's
no token, executeGraphQL then sends X-Hasura-Role: anonymous with no
Authorization header, the REST attempt is skipped, and registry IDs come from
the public /app/packages/registries (required — the anonymous role returns
nothing without a non-empty registries variable). Row-level permissions scope
results to public registries. Authenticated behavior is unchanged.

Also dropped Status and Score from --verbose output — internal registry
state and ranking details with no meaning to users.

thelonewolf1603 and others added 2 commits August 13, 2026 10:39
`jh package search --verbose` printed a `Status: Active/Inactive` line derived
from the registry map and a `Score:` line carrying the GraphQL ranking score.
Both are internal details with no meaning to users, so remove them from the
`packageInfo` display struct, the verbose printer, and the `gqlToInfo` mapping.

The wire-level `Package.Score` and `PackageRegistryMap.Status` fields stay,
since they still mirror the GraphQL response shape.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Searching without a stored token failed with "authentication required". On
juliahub.com the package data is public, so an anonymous search now works
there. Every other server (juliahub.dev, private deployments) still requires
authentication.

The authenticated endpoints are unusable logged out, so the anonymous path is
GraphQL-only:

- optionalToken(server) returns the stored token when there is one, and
  (nil, nil) for juliahub.com when there is not, so callers can fall back to
  public endpoints. Any other server gets an error, as before.
- executeGraphQL omits the Authorization header and sends
  X-Hasura-Role: anonymous when the token is nil.
- searchPackages skips the REST attempt when unauthenticated, since
  /packages/info is always authenticated and would only 401 before falling
  back to GraphQL anyway.
- fetchPackageRegistries resolves registry IDs from the public
  /app/packages/registries endpoint (the one the logged-out web UI uses).
  This is required, not an optimisation: the anonymous Hasura role returns no
  rows unless the registries variable is non-empty.
- apiGet skips the Authorization header when given an empty token.

Row-level permissions scope anonymous results to public registries, so
--registries naming a private registry returns "No packages found" rather than
an error. Authenticated behaviour is unchanged: REST first, GraphQL fallback.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Comment thread packages.go
// /packages/info always requires authentication, so anonymous searches go
// straight to GraphQL, which serves public registries under the anonymous role.
if token == nil {
return searchPackagesGraphQL(params)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldnt we access REST endpoints instead of Graphql?

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