@@ -173,23 +173,29 @@ protected void masterOperation(Request request, ClusterState clusterState, Actio
173
173
// Early check to verify that the user can create the destination index and can read from the source
174
174
if (licenseState .isAuthAllowed ()) {
175
175
final String username = securityContext .getUser ().principal ();
176
- RoleDescriptor .IndicesPrivileges sourceIndexPrivileges = RoleDescriptor .IndicesPrivileges .builder ()
177
- .indices (config .getSource ().getIndex ())
178
- .privileges ("read" )
179
- .build ();
176
+ List <String > srcPrivileges = new ArrayList <>(2 );
177
+ srcPrivileges .add ("read" );
178
+
180
179
List <String > destPrivileges = new ArrayList <>(3 );
181
180
destPrivileges .add ("read" );
182
181
destPrivileges .add ("index" );
183
182
// If the destination index does not exist, we can assume that we may have to create it on start.
184
183
// We should check that the creating user has the privileges to create the index.
185
184
if (concreteDest .length == 0 ) {
186
185
destPrivileges .add ("create_index" );
186
+ // We need to read the source indices mapping to deduce the destination mapping
187
+ srcPrivileges .add ("view_index_metadata" );
187
188
}
188
189
RoleDescriptor .IndicesPrivileges destIndexPrivileges = RoleDescriptor .IndicesPrivileges .builder ()
189
190
.indices (destIndex )
190
191
.privileges (destPrivileges )
191
192
.build ();
192
193
194
+ RoleDescriptor .IndicesPrivileges sourceIndexPrivileges = RoleDescriptor .IndicesPrivileges .builder ()
195
+ .indices (config .getSource ().getIndex ())
196
+ .privileges (srcPrivileges )
197
+ .build ();
198
+
193
199
HasPrivilegesRequest privRequest = new HasPrivilegesRequest ();
194
200
privRequest .applicationPrivileges (new RoleDescriptor .ApplicationResourcePrivileges [0 ]);
195
201
privRequest .username (username );
0 commit comments