Skip to content

Conversation

ShimShtein
Copy link
Member

@ShimShtein ShimShtein commented Jun 18, 2025

What are the changes introduced in this pull request?

Patching the Katello controllers to enable access from an IoP smart proxy

Considerations taken when implementing this change?

The other option is to implement an RBAC scheme similar to the User object

What are the testing steps for this pull request?

Access the Katello API using cert based auth with a cert that belongs to a smart proxy

Summary by Sourcery

Patch Katello API controllers to allow Smart Proxy access via certificate authentication, introduce feature listing for on-prem proxies, update proxy-setting tests for on-prem scenarios, and seed the corresponding features in the database.

Enhancements:

  • Enable certificate-based Smart Proxy authentication for Katello Organizations and Repositories API by patching controllers with SmartProxyAuth and custom filters
  • Introduce on_prem_smart_proxy_features helper to list allowed Smart Proxy features

Tests:

  • Adjust HTTP proxy tests to stub on-prem advisor engine detection and add test for empty proxy setting in on-prem mode

Chores:

  • Add database seed script to create on-prem Smart Proxy features

Copy link

sourcery-ai bot commented Jun 18, 2025

Reviewer's Guide

This PR enables certificate-based smart proxy authentication for Katello API controllers by patching them in the engine’s after_initialize hook, defines on-prem smart proxy features, enhances proxy-related tests, and seeds the necessary feature entries.

File-Level Changes

Change Details Files
Patch Katello controllers to support smart proxy auth
  • Include SmartProxyAuth in OrganizationsController and RepositoriesController
  • Reorder callbacks for download_debug_certificate action
  • Add smart proxy filters for index and download_debug_certificate endpoints
lib/foreman_rh_cloud/engine.rb
Define helper for on-prem smart proxy features
  • Add on_prem_smart_proxy_features method returning ['insights']
lib/foreman_rh_cloud/engine.rb
Enhance RhCloudHttpProxyTest for on-prem scenarios
  • Stub with_local_advisor_engine? to return false by default
  • Add test verifying empty proxy_setting in on-prem setup
test/unit/rh_cloud_http_proxy_test.rb
Seed on-prem smart proxy features into database
  • Iterate over on-prem features and create Feature records
  • Raise error if feature creation fails
db/seeds.d/200_features.rb

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

@ShimShtein ShimShtein marked this pull request as draft June 18, 2025 20:42
Copy link

@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 @ShimShtein - I've reviewed your changes and they look great!


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.

@ShimShtein ShimShtein force-pushed the enable_smart_proxy_access branch 3 times, most recently from 86db83d to e25abac Compare June 19, 2025 14:08
Copy link
Member Author

@ShimShtein ShimShtein left a comment

Choose a reason for hiding this comment

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

@ekohl Fixed your comments and created a proper ticket to track the plugin interface enhancement.

@jeremylenz
Copy link
Collaborator

How do I test this? How do I get a smart proxy that provides this service?

@ShimShtein
Copy link
Member Author

@jeremylenz I have introduced the smart proxy interface to the IoP gateway in RedHatInsights/iop-gateway@6ef809c. You need to spin that container, and try to register it in your Foreman

@ekohl
Copy link
Member

ekohl commented Jun 25, 2025

@jeremylenz I have introduced the smart proxy interface to the IoP gateway in RedHatInsights/iop-gateway@6ef809c. You need to spin that container, and try to register it in your Foreman

This doesn't implement /version which the status code calls: https://github.com/theforeman/foreman/blob/6ca51b16316625e1974995ce82d90a55893578b8/app/models/smart_proxy.rb#L144.

In hindsight I regret not adding the top level version info in /v2/features so we could deprecate the old endpoints.

@ShimShtein ShimShtein marked this pull request as ready for review July 1, 2025 08:26
Copy link

@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 @ShimShtein - I've reviewed your changes and they look great!


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.

@ShimShtein
Copy link
Member Author

/test

@ShimShtein ShimShtein force-pushed the enable_smart_proxy_access branch 2 times, most recently from f74ca6a to f6fd3c7 Compare July 1, 2025 08:54
@ShimShtein
Copy link
Member Author

Got it working. Ready for review

@ShimShtein ShimShtein force-pushed the enable_smart_proxy_access branch from f6fd3c7 to 7467c32 Compare July 1, 2025 10:49
@ShimShtein ShimShtein force-pushed the enable_smart_proxy_access branch from 7467c32 to 8409fb7 Compare July 1, 2025 11:57
@ShimShtein ShimShtein force-pushed the enable_smart_proxy_access branch from 8409fb7 to bf095a9 Compare July 1, 2025 15:39
@ShimShtein ShimShtein force-pushed the enable_smart_proxy_access branch 2 times, most recently from 94eab0e to 46a9be4 Compare July 3, 2025 16:04
@ShimShtein ShimShtein force-pushed the enable_smart_proxy_access branch from 46a9be4 to 1ff776b Compare July 3, 2025 16:08
Copy link
Collaborator

@jeremylenz jeremylenz left a comment

Choose a reason for hiding this comment

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

thanks @ShimShtein! Let's give it a go.

Copy link
Collaborator

@jeremylenz jeremylenz left a comment

Choose a reason for hiding this comment

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

Screenshot 2025-07-03 at 1 22 08 PM

Confirmed the Insights feature is properly created via seeds.

@jeremylenz jeremylenz merged commit 01e9f3d into theforeman:develop Jul 3, 2025
11 of 12 checks passed
@ianballou
Copy link
Collaborator

ianballou commented Jul 21, 2025

This PR is causing User.current to be nil only when a Product ID is passed in for some reason in Katello. This causes a product's repositories page to be inaccessible. I just tested varying foreman_rh_cloud commits with Katello to verify.

@chris1984
Copy link
Member

This PR is causing User.current to be nil only when a Product ID is passed in for some reason in Katello. This causes a product's repositories page to be inaccessible. I just tested varying foreman_rh_cloud commits with Katello to verify.

Do you know what the fix would be?

@ianballou
Copy link
Collaborator

This PR is causing User.current to be nil only when a Product ID is passed in for some reason in Katello. This causes a product's repositories page to be inaccessible. I just tested varying foreman_rh_cloud commits with Katello to verify.

Do you know what the fix would be?

I think foreman_rh_cloud needs to ensure that add_smart_proxy_filters creates the before_action call to require_smart_proxy_or_login before the before_action calls in the repositories controller, not after.

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.

7 participants