|  | 
| 240 | 240 | import static org.opensearch.security.resources.ResourceSharingIndexHandler.getSharingIndex; | 
| 241 | 241 | import static org.opensearch.security.setting.DeprecatedSettings.checkForDeprecatedSetting; | 
| 242 | 242 | import static org.opensearch.security.support.ConfigConstants.OPENDISTRO_SECURITY_AUTHENTICATED_USER; | 
|  | 243 | +import static org.opensearch.security.support.ConfigConstants.OPENSEARCH_RESOURCE_SHARING_ENABLED_DEFAULT; | 
| 243 | 244 | import static org.opensearch.security.support.ConfigConstants.SECURITY_ALLOW_DEFAULT_INIT_SECURITYINDEX; | 
| 244 | 245 | import static org.opensearch.security.support.ConfigConstants.SECURITY_ALLOW_DEFAULT_INIT_USE_CLUSTER_STATE; | 
| 245 | 246 | import static org.opensearch.security.support.ConfigConstants.SECURITY_SSL_CERTIFICATES_HOT_RELOAD_ENABLED; | 
| @@ -691,7 +692,9 @@ public List<RestHandler> getRestHandlers( | 
| 691 | 692 |                 ); | 
| 692 | 693 | 
 | 
| 693 | 694 |                 // Resource sharing API to update sharing info | 
| 694 |  | -                handlers.add(new ShareRestAction()); | 
|  | 695 | +                if (settings.getAsBoolean(ConfigConstants.OPENSEARCH_RESOURCE_SHARING_ENABLED, OPENSEARCH_RESOURCE_SHARING_ENABLED_DEFAULT)) { | 
|  | 696 | +                    handlers.add(new ShareRestAction()); | 
|  | 697 | +                } | 
| 695 | 698 | 
 | 
| 696 | 699 |             } | 
| 697 | 700 |             log.debug("Added {} rest handler(s)", handlers.size()); | 
| @@ -722,7 +725,10 @@ public UnaryOperator<RestHandler> getRestHandlerWrapper(final ThreadContext thre | 
| 722 | 725 |             actions.add(new ActionHandler<>(WhoAmIAction.INSTANCE, TransportWhoAmIAction.class)); | 
| 723 | 726 | 
 | 
| 724 | 727 |             // transport action to handle sharing info update | 
| 725 |  | -            actions.add(new ActionHandler<>(ShareAction.INSTANCE, ShareTransportAction.class)); | 
|  | 728 | +            if (settings.getAsBoolean(ConfigConstants.OPENSEARCH_RESOURCE_SHARING_ENABLED, OPENSEARCH_RESOURCE_SHARING_ENABLED_DEFAULT)) { | 
|  | 729 | +                actions.add(new ActionHandler<>(ShareAction.INSTANCE, ShareTransportAction.class)); | 
|  | 730 | +            } | 
|  | 731 | + | 
| 726 | 732 |         } | 
| 727 | 733 |         return actions; | 
| 728 | 734 |     } | 
|  | 
0 commit comments