1
0
mirror of https://github.com/quay/quay.git synced 2026-01-26 06:21:37 +03:00
Files
quay/test
OpenShift Cherrypick Robot 57895ec081 [redhat-3.16] fix(api): superuser panel access without SUPERUSERS_FULL_ACCESS (PROJQUAY-9693) (#4512)
* fix(api): fix superuser panel access and permission bypass behavior

Fixed multiple issues with superuser functionality related to FEATURE_SUPERUSERS_FULL_ACCESS:

1. **Superuser Panel Access**: Fixed bug where superuser panel endpoints returned 403
   when FEATURE_SUPERUSERS_FULL_ACCESS was disabled. Basic superuser panel operations
   (user list, logs, org list, messages) now work with just FEATURE_SUPER_USERS enabled.

2. **Permission Bypass Logic**: Updated decorators to properly differentiate between:
   - Basic superuser operations (don't require FULL_ACCESS)
   - Permission bypass operations (require FULL_ACCESS)
   - Read operations (allow global readonly superusers with FULL_ACCESS)
   - Write operations (only allow regular superusers with FULL_ACCESS)

3. **Global Readonly Superuser Support**: Fixed decorators to allow global readonly
   superusers read access when FULL_ACCESS is enabled, while blocking write operations.

4. **License Bypass**: Superusers with FULL_ACCESS now bypass license/quota limits
   when creating or modifying private repositories in any namespace.

Changes:
- endpoints/api/__init__.py: Fixed allow_if_superuser() and decorators
- endpoints/api/organization.py: Updated 4 GET endpoints to require FULL_ACCESS
- endpoints/api/namespacequota.py: Updated 2 GET endpoints to require FULL_ACCESS
- endpoints/api/team.py: Updated 2 GET endpoints to require FULL_ACCESS
- endpoints/api/prototype.py: Updated 1 GET endpoint to require FULL_ACCESS
- endpoints/api/repository.py: Added license bypass for superusers with FULL_ACCESS
- endpoints/api/logs.py: Fixed log access to require FULL_ACCESS for permission bypass
- endpoints/api/test/test_superuser_full_access.py: Added comprehensive test suite
- test/test_api_usage.py: Updated test expectations for license bypass behavior

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* test(api): add plan limit test for regular users

Adds test_plan_limit_enforcement_for_regular_users to verify that
license limits still apply to non-superuser accounts. This restores
test coverage for plan limit enforcement that was changed when we
updated test_trychangevisibility to validate superuser bypass behavior.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(api): correct superuser cross-namespace permission model

Fixes permission checks to properly implement the superuser access model:

- Global Readonly Superusers (auditors): Always have read access to all
  content, independent of FEATURE_SUPERUSERS_FULL_ACCESS setting
- Regular Superusers: Can access /v1/superuser endpoints and their own
  content. Require FEATURE_SUPERUSERS_FULL_ACCESS=true for cross-namespace
  read access
- Full Access Superusers: Regular superusers with FULL_ACCESS enabled,
  can perform CRUD on content they don't own
- Write operations: Only allowed for full access superusers (global
  readonly superusers never get write access)

Updated 18 permission checks across 7 files:
- endpoints/api/__init__.py: require_repo_permission decorator
- endpoints/api/organization.py: org view, teams, collaborators, proxy cache
- endpoints/api/namespacequota.py: quota listing and individual quota
- endpoints/api/policy.py: auto-prune policies for orgs and repos
- endpoints/api/robot.py: robot listing, details, permissions, federation
- endpoints/api/build.py: repository build logs
- endpoints/api/repository_models_pre_oci.py: repository visibility query

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(api): require FULL_ACCESS for regular superusers on /v1/superuser/apptokens

Updates the SuperUserAppTokens endpoint to properly enforce permission model:

- Regular superusers WITHOUT FULL_ACCESS: Get 403 Unauthorized
- Global readonly superusers: Always get 200 (auditor access, independent of FULL_ACCESS)
- Full access superusers (FULL_ACCESS=true): Get 200 with all tokens

This ensures regular superusers can only audit app tokens across the system
when they have full access privileges enabled, while global readonly superusers
(auditors) always maintain read access for auditing purposes.

Changes:
- endpoints/api/superuser.py: Update permission check in SuperUserAppTokens.get()
- endpoints/api/test/test_appspecifictoken.py: Update test mocking and add new test
  for 403 behavior

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Dave O'Connor <doconnor@redhat.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Dave O'Connor <1656866+HammerMeetNail@users.noreply.github.com>
2025-11-13 16:50:32 +00:00
..
2019-11-12 11:09:47 -05:00
2020-06-05 16:50:13 -04:00
2019-11-12 11:09:47 -05:00
2019-12-02 12:23:08 -05:00