Skip to content

refactor(api): remove redundant GET /api/users/security route#6398

Merged
gustavosbarreto merged 2 commits into
masterfrom
refactor/remove-get-session-record
Jun 1, 2026
Merged

refactor(api): remove redundant GET /api/users/security route#6398
gustavosbarreto merged 2 commits into
masterfrom
refactor/remove-get-session-record

Conversation

@geovannewashington
Copy link
Copy Markdown
Member

What

Removed the GET /api/users/security route and all associated code:
route registration, URL constant, handler, service method, mock, and
tests.

Why

The route returned a single boolean (namespace session record status)
already available from GET /api/namespaces/{tenant} via
settings.session_record. The active frontend (ui-react) does not
call it -- the only reference was in the dead Vue UI under /v1/.
The path was also misleading for a namespace-level setting, and had
no tenant guard unlike its sibling PUT /api/users/security/{tenant}.

Closes #6391.

Testing

  1. Start the environment with ./bin/docker-compose up
  2. Login and export the token as $TOKEN
  3. Confirm the route no longer exists:

curl -v -H "Authorization: Bearer $TOKEN" http://localhost/api/users/security

Should return 404.

API keys are namespace-scoped tokens and should not be usable on
account-level routes. Four routes were missing the BlockAPIKey
middleware, allowing API keys to reach handlers they should never
reach.

The most concrete gap was ListAPIKeys: an API key could enumerate
all other API keys in the namespace. The remaining three routes
(GetNamespaceList, CreateNamespace, LeaveNamespace) were safe by
accident -- the service layer rejected them -- but returned
confusing 404s instead of a clean 403.

Added BlockAPIKey to all four routes, matching the pattern already
used by CreateAPIKey, UpdateAPIKey and DeleteAPIKey. Removed the
x-internal overrides and api-key security entries from the OpenAPI
spec for the same operations, since the spec now accurately reflects
what the code enforces.

Removed TestListNamespacesAPIKeyScope, which tested the old scoped
behavior that no longer applies.
The GET /api/users/security route returned a single boolean
(namespace session record status) that is already available from
GET /api/namespaces/{tenant} via settings.session_record.

The active frontend (ui-react) does not call it. The only reference
was in the dead Vue UI under /v1/. The path was also misleading:
/users/security for a namespace-level setting, with no tenant guard
unlike its sibling PUT route.

Removed the route registration, URL constant, handler, service
method, mock, and all associated tests.
@geovannewashington geovannewashington self-assigned this Jun 1, 2026
@geovannewashington geovannewashington requested review from a team as code owners June 1, 2026 20:19
@geovannewashington geovannewashington added area/api go Pull requests that update Go code kind/refactor labels Jun 1, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 2026

Claude finished @geovannewashington's task in 6m 38s —— View job


Code Review Complete

Reviewed 10 files across code quality, security, testing, language patterns, and architecture — no issues found. The code looks good as-is.

Highlights:

  • GetSessionRecord is fully removed from handler, service interface, implementation, mock, tests, route registration, and URL constant — no dangling references remain.
  • BlockAPIKey middleware is correctly added to all 4 affected routes, and each has a corresponding test verifying 403 Forbidden.
  • OpenAPI specs are consistent with the middleware changes: api-key security and x-internal flags are removed from the same endpoints.
  • No cross-repo impact: the cloud/ enterprise repo does not reference GetSessionRecord or depend on API key access to any of the affected endpoints.

If you push additional changes and want a new review, tag @shellhub-io/admin and a team member can trigger it.

@gustavosbarreto gustavosbarreto merged commit 8306547 into master Jun 1, 2026
24 checks passed
@gustavosbarreto gustavosbarreto deleted the refactor/remove-get-session-record branch June 1, 2026 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api go Pull requests that update Go code kind/refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: remove redundant GET /api/users/security (checkSessionRecord)

2 participants