From f15dba45dbb516b27df0a8d02ed7119af97104bd Mon Sep 17 00:00:00 2001 From: Michael Calmer Date: Tue, 4 Feb 2025 16:21:56 +0100 Subject: [PATCH] disable APIs which add channels and org credentials --- .../sync/content/ContentSyncHandler.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/sync/content/ContentSyncHandler.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/sync/content/ContentSyncHandler.java index 26e3b550306..b84aba966aa 100644 --- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/sync/content/ContentSyncHandler.java +++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/sync/content/ContentSyncHandler.java @@ -30,6 +30,7 @@ import com.redhat.rhn.manager.setup.MirrorCredentialsManager; import com.suse.manager.api.ReadOnly; +import com.suse.manager.model.hub.HubFactory; import java.util.ArrayList; import java.util.Collection; @@ -197,6 +198,11 @@ public Integer synchronizeRepositories(User loggedInUser, String mirrorUrl) thro public Integer addChannel(User loggedInUser, String channelLabel, String mirrorUrl) throws ContentSyncException { ensureSatAdmin(loggedInUser); + HubFactory hubFactory = new HubFactory(); + if (hubFactory.isISSPeripheral()) { + throw new ContentSyncException("This is an ISS Peripheral Server. " + + "Managing channels is disabled and can only be done from the Hub Server."); + } ContentSyncManager csm = new ContentSyncManager(); if (csm.isRefreshNeeded(mirrorUrl)) { throw new ContentSyncException("Product Data refresh needed. Please call mgr-sync refresh."); @@ -223,6 +229,11 @@ public Integer addChannel(User loggedInUser, String channelLabel, String mirrorU public Object[] addChannels(User loggedInUser, String channelLabel, String mirrorUrl) throws ContentSyncException { ensureSatAdmin(loggedInUser); + HubFactory hubFactory = new HubFactory(); + if (hubFactory.isISSPeripheral()) { + throw new ContentSyncException("This is an ISS Peripheral Server. " + + "Managing channels is disabled and can only be done from the Hub Server."); + } ContentSyncManager csm = new ContentSyncManager(); if (csm.isRefreshNeeded(mirrorUrl)) { throw new ContentSyncException("Product Data refresh needed. Please call mgr-sync refresh."); @@ -268,6 +279,10 @@ public Object[] addChannels(User loggedInUser, String channelLabel, String mirro public Integer addCredentials(User loggedInUser, String username, String password, boolean primary) throws ContentSyncException { ensureSatAdmin(loggedInUser); + HubFactory hubFactory = new HubFactory(); + if (hubFactory.isISSPeripheral()) { + throw new ContentSyncException("This is an ISS Peripheral Server. Managing credentials is disabled."); + } MirrorCredentialsDto creds = new MirrorCredentialsDto(username, password); MirrorCredentialsManager credsManager = new MirrorCredentialsManager(); long id = credsManager.storeMirrorCredentials(creds, null); @@ -293,6 +308,10 @@ public Integer addCredentials(User loggedInUser, String username, String passwor public Integer deleteCredentials(User loggedInUser, String username) throws ContentSyncException { ensureSatAdmin(loggedInUser); + HubFactory hubFactory = new HubFactory(); + if (hubFactory.isISSPeripheral()) { + throw new ContentSyncException("This is an ISS Peripheral Server. Managing credentials is disabled."); + } for (SCCCredentials c : CredentialsFactory.listSCCCredentials()) { if (c.getUsername().equals(username)) { new MirrorCredentialsManager().deleteMirrorCredentials(c.getId(), null);