Skip to content

Conversation

@git-hyagi
Copy link
Collaborator

@git-hyagi git-hyagi commented Jan 13, 2026

Summary by Sourcery

Enhancements:

  • Replace domain-based public access permission with a generic permission that allows all unauthenticated GET requests.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jan 13, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR introduces a new DRF permission class that allows unauthenticated GET requests to the simple API by replacing the previous domain-based public access logic with a simple method check, and wires this behavior into the container build via an updated patch file.

Sequence diagram for unauthenticated GET request using AllowUnauthPull

sequenceDiagram
    actor Client
    participant DRFView
    participant AllowUnauthPull

    Client->>DRFView: HTTP GET /simple/
    DRFView->>AllowUnauthPull: has_permission(request, view)
    AllowUnauthPull-->>DRFView: True (method is GET)
    DRFView-->>Client: 200 OK

    Client->>DRFView: HTTP POST /simple/
    DRFView->>AllowUnauthPull: has_permission(request, view)
    AllowUnauthPull-->>DRFView: False (method is not GET)
    DRFView-->>Client: 403 Forbidden
Loading

Class diagram for updated DRF permission class allowing unauthenticated GET

classDiagram
    class BasePermission {
        <<abstract>>
        +has_permission(request, view) bool
    }

    class PublicDomainPermission {
        <<removed>>
        +has_permission(request, view) bool
    }

    class AllowUnauthPull {
        +has_permission(request, view) bool
    }

    BasePermission <|-- PublicDomainPermission
    BasePermission <|-- AllowUnauthPull
Loading

File-Level Changes

Change Details Files
Replace domain-based public access permission with a generic unauthenticated GET permission class.
  • Rename the permission class from PublicDomainPermission to AllowUnauthPull and update its docstring to describe unauthenticated GET access.
  • Simplify has_permission to return True for GET requests and False otherwise, removing all domain lookup and public- prefix logic, including exception handling paths.
pulp_service/pulp_service/app/authorization.py
Update the pulp-python auth override patch to use the new permission behavior.
  • Modify the existing auth override patch file so the image build applies the new AllowUnauthPull permission instead of the removed domain-based implementation.
images/assets/patches/0023-Add-auth-override-pulp-python.patch

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • The new AllowUnauthPull permission currently allows any unauthenticated GET to the view; if this is meant to be limited to specific endpoints, consider scoping it more narrowly (e.g. only for certain views or URL patterns) rather than applying it generically.
  • Instead of hardcoding request.method == "GET", consider using request.method in SAFE_METHODS from DRF if you also want to support other read-only verbs like HEAD/OPTIONS, or explicitly document why only GET is allowed.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new `AllowUnauthPull` permission currently allows any unauthenticated GET to the view; if this is meant to be limited to specific endpoints, consider scoping it more narrowly (e.g. only for certain views or URL patterns) rather than applying it generically.
- Instead of hardcoding `request.method == "GET"`, consider using `request.method in SAFE_METHODS` from DRF if you also want to support other read-only verbs like HEAD/OPTIONS, or explicitly document why only GET is allowed.

## Individual Comments

### Comment 1
<location> `pulp_service/pulp_service/app/authorization.py:123-131` </location>
<code_context>


-class PublicDomainPermission(BasePermission):
+class AllowUnauthPull(BasePermission):
     """
-    A Permission Class that grants permission to Domains with public- prefix
+    A Permission Class that grants permission to make GET requests without authN/authZ
     """

     def has_permission(self, request, view):
         # Only allow GET requests
-        if request.method != "GET":
-            return False
-
-        try:
-            domain_pk = get_domain_pk()
-            domain = Domain.objects.get(pk=domain_pk)
-            if domain.name.startswith("public-"):
-                return True
-        except Exception:
-            # If we can't get the domain, deny access
</code_context>

<issue_to_address>
**🚨 issue (security):** Broadening from public domains to all GET requests may introduce unintended data exposure.

This change removes the `public-` domain constraint and effectively allows unauthenticated access to any GET endpoint using this permission. Please verify that every view using `AllowUnauthPull` only returns data that is safe for anonymous users, and that there’s no indirect data leak via query params, path-based tenant selection, or similar mechanisms.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@git-hyagi git-hyagi force-pushed the modify-simple-auth branch 2 times, most recently from 0b982d8 to b5f588e Compare January 13, 2026 18:58
Copy link
Member

@decko decko left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@git-hyagi git-hyagi merged commit 68bc828 into pulp:main Jan 13, 2026
4 checks passed
@git-hyagi git-hyagi deleted the modify-simple-auth branch January 13, 2026 21:18
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