-
-
Notifications
You must be signed in to change notification settings - Fork 254
Fix server owner permissions #1703
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix server owner permissions #1703
Conversation
📝 WalkthroughWalkthroughAdds an early owner check in GetUserPermissionsService::handle() to immediately return ['*'] for server owners and removes a duplicate later owner check. Admin and subuser permission-resolution paths remain unchanged. No public signatures were modified. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant U as Caller
participant S as GetUserPermissionsService
U->>S: handle(user, server)
rect rgba(200,235,255,0.28)
note over S: New: Early owner check
alt User is server owner
S-->>U: return ["*"]
else Not owner
alt User is admin
S-->>U: return admin permissions
else
S-->>U: return aggregated subuser permissions
end
end
end
sequenceDiagram
autonumber
participant U as Caller
participant S as GetUserPermissionsService
U->>S: handle(user, server)
rect rgba(255,245,200,0.28)
note over S: Previous: Owner check occurred after admin/subuser logic
alt User is admin
S-->>U: return admin permissions
else
alt Later owner check true
S-->>U: return ["*"]
else
S-->>U: return aggregated subuser permissions
end
end
end
Pre-merge checks (3 passed)✅ Passed checks (3 passed)
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. 📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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. Comment |
|
All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
app/Services/Servers/GetUserPermissionsService.php (2)
20-22: Harden the owner check against ID type mismatches.Strict comparison can fail if one side is string-cast (e.g., UUIDs) and the other int. Cast both to the same type or use Eloquent’s key getter.
Apply:
- if ($user->id === $server->owner_id) { + if ((string) $user->getKey() === (string) $server->owner_id) {
20-22: Add an explicit test for the owner+admin edge case.Cover: (1) pure owner → ['']; (2) owner with admin lacking 'update' → still ['']; (3) non-owner admin with only 'view' → limited set.
I can draft PHPUnit tests (feature or service-level) that set up a server, owner user, and an admin role without 'update', then assert the returned permissions.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
app/Services/Servers/GetUserPermissionsService.php(1 hunks)
🔇 Additional comments (1)
app/Services/Servers/GetUserPermissionsService.php (1)
20-22: Early owner short-circuit is correct and resolves the reported issue.Returning ['*'] for the server owner before admin/subuser resolution matches the expected behavior and prevents an admin role with restricted perms from masking ownership.
Boy132
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems fine to me, this service is only used for checking subuser permissions.
I have stumbled upon a possible bug Server owner cannot start/restart/stop their own server if they have assigned some admin role without server update permission. I would expect that being a server owner would allow you to do anything with the server.
I am not sure if this is just a bug or if it is intentional. I have not read most of the codebase so I do not know if this change has some unwanted behaviour.