Skip to content

Conversation

@git-hyagi
Copy link
Collaborator

@git-hyagi git-hyagi commented Feb 2, 2026

ref: https://issues.redhat.com/browse/PULP-1064

Summary by Sourcery

Bug Fixes:

  • Prevent continued access when deprecated c.rh.c ServiceAccount authentication is used by failing the request with an authentication error.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Feb 2, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR changes the deprecated ServiceAccount-based authentication path so that any attempt to authenticate via the remote_user header now fails with an AuthenticationFailed error instead of silently falling back to unauthenticated access.

Sequence diagram for deprecated ServiceAccount authentication behavior change

sequenceDiagram
  actor ApiClient
  participant PulpAPI
  participant AuthenticationBackend

  ApiClient->>PulpAPI: HTTP request with remote_user header
  PulpAPI->>AuthenticationBackend: authenticate(request)
  AuthenticationBackend->>AuthenticationBackend: Parse request JSON
  alt Invalid JSON
    AuthenticationBackend-->>PulpAPI: raise AuthenticationFailed Access denied. Invalid JSON.
    PulpAPI-->>ApiClient: 401 Unauthorized
  else Valid JSON and remote_user present
    AuthenticationBackend-->>PulpAPI: raise AuthenticationFailed Deprecated c.rh.c SA authentication method attempted by user
    PulpAPI-->>ApiClient: 401 Unauthorized
  else No remote_user
    AuthenticationBackend-->>PulpAPI: return None (no authentication)
    PulpAPI-->>ApiClient: Process as unauthenticated request
  end
Loading

File-Level Changes

Change Details Files
Reject deprecated ServiceAccount authentication attempts instead of ignoring them.
  • Update authentication flow to raise AuthenticationFailed when remote_user is present for the deprecated c.rh.c ServiceAccount method.
  • Change warning-only behavior into a hard authentication failure to prevent access using the deprecated mechanism.
pulp_service/pulp_service/app/authentication.py

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:

  • Consider preserving the warning log when rejecting deprecated SA authentication (log then raise) so that operational visibility of these attempts is not lost.
  • Including the remote_user value in the authentication failure message may leak user identifiers to clients; consider logging it server-side only and returning a more generic error to the caller.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider preserving the warning log when rejecting deprecated SA authentication (log then raise) so that operational visibility of these attempts is not lost.
- Including the `remote_user` value in the authentication failure message may leak user identifiers to clients; consider logging it server-side only and returning a more generic error to the caller.

## Individual Comments

### Comment 1
<location> `pulp_service/pulp_service/app/authentication.py:99-102` </location>
<code_context>
-            _logger.warning(f"Deprecated c.rh.c SA authentication method attempted by user: {remote_user}")
-            return None
+            raise AuthenticationFailed(
+                _(f"Deprecated c.rh.c SA authentication method attempted by user: {remote_user}")
+            )

</code_context>

<issue_to_address>
**suggestion:** Consider avoiding f-strings inside the translation function.

Using an f-string inside `_()` ties the translation key to the specific value, which makes catalog management harder. Prefer placeholders instead, e.g. `_("Deprecated c.rh.c SA authentication method attempted by user: %(user)s") % {"user": remote_user}`.

```suggestion
        if remote_user:
            raise AuthenticationFailed(
                _(
                    "Deprecated c.rh.c SA authentication method "
                    "attempted by user: %(user)s"
                )
                % {"user": remote_user}
            )
```
</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 disable-sa-auth-method branch from 328f410 to 179aab2 Compare February 2, 2026 18:29
@git-hyagi git-hyagi merged commit 7a79a23 into pulp:main Feb 3, 2026
4 checks passed
@git-hyagi git-hyagi deleted the disable-sa-auth-method branch February 3, 2026 11:03
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.

1 participant