users: Removed default users and user->role mappings
This will force users to create a user via the esusers This also adds log warning when no users are found. Original commit: elastic/x-pack-elasticsearch@3c31f8d3b0
This commit is contained in:
parent
07875c530c
commit
858e7e9e35
|
@ -117,7 +117,11 @@ public class FileUserPasswdStore extends AbstractComponent implements UserPasswd
|
|||
users.put(username, hash.toCharArray());
|
||||
}
|
||||
|
||||
return users.build();
|
||||
ImmutableMap<String, char[]> usersMap = users.build();
|
||||
if (logger != null && usersMap.isEmpty()){
|
||||
logger.warn("No users found in file [" + path.toAbsolutePath() + "]. Use bin/shield/esusers to add users and role mappings");
|
||||
}
|
||||
return usersMap;
|
||||
}
|
||||
|
||||
public static void writeFile(Map<String, char[]> esUsers, Path path) {
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
package org.elasticsearch.shield.authc.esusers;
|
||||
|
||||
import com.carrotsearch.ant.tasks.junit4.dependencies.com.google.common.base.Charsets;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.logging.ESLoggerFactory;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.env.Environment;
|
||||
|
@ -29,6 +31,7 @@ import java.util.concurrent.CountDownLatch;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -116,4 +119,15 @@ public class FileUserPasswdStoreTests extends ElasticsearchTestCase {
|
|||
assertThat(users, notNullValue());
|
||||
assertThat(users.keySet(), hasSize(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseEmptyFile() throws Exception {
|
||||
File empty = this.tempFolder.newFile();
|
||||
Path path = Paths.get(getClass().getResource("users").toURI());
|
||||
ESLogger log = ESLoggerFactory.getLogger("test");
|
||||
log = spy(log);
|
||||
Map<String, char[]> users = FileUserPasswdStore.parseFile(empty.toPath(), log);
|
||||
|
||||
verify(log, times(1)).warn(contains("No users found"));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue