Skip to content

feat: allow admins to access suspended servers in client API - #2507

Open
lotus64yt wants to merge 2 commits into
pelican:mainfrom
lotus64yt:feat-admin-access-suspended
Open

feat: allow admins to access suspended servers in client API#2507
lotus64yt wants to merge 2 commits into
pelican:mainfrom
lotus64yt:feat-admin-access-suspended

Conversation

@lotus64yt

Copy link
Copy Markdown

This allows an admin user to bypass the suspended and maintenance checks in the client API, giving them access to the server's files even when the server is suspended.

@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4d3ba7ed-1192-4b81-9993-cd4809d00ac5

📥 Commits

Reviewing files that changed from the base of the PR and between b38ddad and fecda79.

📒 Files selected for processing (1)
  • app/Http/Middleware/Api/Client/Server/AuthenticateServerAccess.php
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/Http/Middleware/Api/Client/Server/AuthenticateServerAccess.php

📝 Walkthrough

Walkthrough

The server access middleware now recognizes administrator file routes as exceptions for suspended or maintenance-affected servers. The resources-route exemption and existing update-permission checks remain enforced.

Changes

Server access authorization

Layer / File(s) Summary
Administrator file-route exception
app/Http/Middleware/Api/Client/Server/AuthenticateServerAccess.php
Administrator file routes now join the configured exceptions and resources-route exemption. Existing update-permission checks remain active.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: allowing administrators to access suspended servers through the client API.
Description check ✅ Passed The description directly explains the administrator bypass for suspended and maintenance checks in the client API.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/Http/Middleware/Api/Client/Server/AuthenticateServerAccess.php`:
- Around line 53-54: Update the authorization flow around the two `throw_if`
calls in `AuthenticateServerAccess` so administrators are also bypassed for file
endpoints. Ensure unnamed `/files/*` routes are recognized as allowed alongside
the existing `api:client:server.ws` exception, while preserving the current
route restrictions for non-administrators.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: dc40bb30-5777-408b-b9db-ee5c251af9db

📥 Commits

Reviewing files that changed from the base of the PR and between 3518768 and b38ddad.

📒 Files selected for processing (1)
  • app/Http/Middleware/Api/Client/Server/AuthenticateServerAccess.php

Comment thread app/Http/Middleware/Api/Client/Server/AuthenticateServerAccess.php Outdated
@lotus64yt

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@Boy132

Boy132 commented Aug 13, 2026

Copy link
Copy Markdown
Member

What is the use case behind this?

@lotus64yt

Copy link
Copy Markdown
Author

I have a host powered by Pelican, and we have illegal servers. We suspend them, but we want to investigate to prevent other servers like this by finding repetitive code blocks without downloading all the files.

if (!$request->routeIs('api:client:server.view')) {
throw_if(($server->isSuspended() || $server->node->isUnderMaintenance()) && !$request->routeIs('api:client:server.resources'), $exception);
throw_if($user->cannot('update server', $server) || !$request->routeIs($this->except), $exception);
$isExcepted = $request->routeIs($this->except) || ($user->isAdmin() && $request->is('api/client/servers/*/files*'));

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.

Need to use route names

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.

3 participants