Packaging: Fix broken paths, adapt to elasticsearch packaging
* Add config and bin directory to assembly * Add main method to ESUsersTool so it starts * Fix bin/esusers to actually start * Fix ESUsersTool to write files in config/shield by default as each plugin has its own directory after installation * Changed bin/ and config/ directory to reflect path after installation in ES Original commit: elastic/x-pack-elasticsearch@7d4165e389
This commit is contained in:
parent
9dd52bfb5f
commit
b78262046e
|
@ -8,11 +8,11 @@
|
|||
<fileSets>
|
||||
<fileSet>
|
||||
<filtered>false</filtered>
|
||||
<directory>bin</directory>
|
||||
<directory>bin/shield</directory>
|
||||
<outputDirectory>bin</outputDirectory>
|
||||
</fileSet>
|
||||
<fileSet>
|
||||
<directory>config</directory>
|
||||
<directory>config/shield</directory>
|
||||
<outputDirectory>config</outputDirectory>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.env.Environment;
|
||||
import org.elasticsearch.shield.authc.support.Hasher;
|
||||
import org.elasticsearch.shield.authc.support.UserPasswdStore;
|
||||
import org.elasticsearch.shield.plugin.SecurityPlugin;
|
||||
import org.elasticsearch.watcher.FileChangesListener;
|
||||
import org.elasticsearch.watcher.FileWatcher;
|
||||
import org.elasticsearch.watcher.ResourceWatcherService;
|
||||
|
@ -74,7 +75,8 @@ public class FileUserPasswdStore extends AbstractComponent implements UserPasswd
|
|||
public static Path resolveFile(Settings settings, Environment env) {
|
||||
String location = settings.get("shield.authc.esusers.files.users");
|
||||
if (location == null) {
|
||||
return env.configFile().toPath().resolve(".users");
|
||||
File shieldDirectory = new File(env.configFile(), SecurityPlugin.NAME);
|
||||
return shieldDirectory.toPath().resolve(".users");
|
||||
}
|
||||
return Paths.get(location);
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.elasticsearch.common.logging.ESLogger;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.env.Environment;
|
||||
import org.elasticsearch.shield.authc.support.UserRolesStore;
|
||||
import org.elasticsearch.shield.plugin.SecurityPlugin;
|
||||
import org.elasticsearch.watcher.FileChangesListener;
|
||||
import org.elasticsearch.watcher.FileWatcher;
|
||||
import org.elasticsearch.watcher.ResourceWatcherService;
|
||||
|
@ -67,7 +68,8 @@ public class FileUserRolesStore extends AbstractComponent implements UserRolesSt
|
|||
public static Path resolveFile(Settings settings, Environment env) {
|
||||
String location = settings.get("shield.authc.esusers.files.users_roles");
|
||||
if (location == null) {
|
||||
return env.configFile().toPath().resolve(".users_roles");
|
||||
File shieldDirectory = new File(env.configFile(), SecurityPlugin.NAME);
|
||||
return shieldDirectory.toPath().resolve(".users_roles");
|
||||
}
|
||||
return Paths.get(location);
|
||||
}
|
||||
|
|
|
@ -34,6 +34,10 @@ public class ESUsersTool extends CliTool {
|
|||
.cmds(Useradd.CMD, Userdel.CMD, Passwd.CMD)
|
||||
.build();
|
||||
|
||||
public static void main(String[] args) {
|
||||
new ESUsersTool().execute(args);
|
||||
}
|
||||
|
||||
public ESUsersTool() {
|
||||
super(CONFIG);
|
||||
}
|
||||
|
|
|
@ -17,9 +17,11 @@ import java.util.Collection;
|
|||
*/
|
||||
public class SecurityPlugin extends AbstractPlugin {
|
||||
|
||||
public static final String NAME = "shield";
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return "shield";
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -41,7 +41,7 @@ public class ShieldPluginTests extends ElasticsearchIntegrationTest {
|
|||
logger.info("--> Checking nodes info");
|
||||
for (NodeInfo nodeInfo : nodeInfos.getNodes()) {
|
||||
assertThat(nodeInfo.getPlugins().getInfos(), hasSize(1));
|
||||
assertThat(nodeInfo.getPlugins().getInfos().get(0).getName(), is("shield"));
|
||||
assertThat(nodeInfo.getPlugins().getInfos().get(0).getName(), is(SecurityPlugin.NAME));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue