fix #2709 add index.user.initial_password

This commit is contained in:
Shinsuke Sugaya 2023-01-12 22:23:26 +09:00
parent 0916c4094c
commit 16f5b072df
4 changed files with 24 additions and 2 deletions

View file

@ -55,6 +55,7 @@ import org.codelibs.curl.CurlResponse;
import org.codelibs.fesen.client.EngineInfo;
import org.codelibs.fesen.client.HttpClient;
import org.codelibs.fess.Constants;
import org.codelibs.fess.app.web.base.login.FessLoginAssist;
import org.codelibs.fess.entity.FacetInfo;
import org.codelibs.fess.entity.GeoInfo;
import org.codelibs.fess.entity.HighlightInfo;
@ -717,8 +718,13 @@ public class SearchEngineClient implements Client {
mapper.readValue(prev, new TypeReference<Map<String, Map<String, String>>>() {
});
if (result.containsKey("index")) {
String source = line;
if ("fess_user.user".equals(configIndex)) {
source = source.replace("${fess.index.initial_password}", ComponentUtil.getComponent(FessLoginAssist.class)
.encryptPassword(fessConfig.getIndexUserInitialPassword()));
}
final IndexRequestBuilder requestBuilder = client.prepareIndex().setIndex(configIndex)
.setId(result.get("index").get("_id")).setSource(line, XContentType.JSON);
.setId(result.get("index").get("_id")).setSource(source, XContentType.JSON);
builder.add(requestBuilder);
}
}

View file

@ -538,6 +538,9 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
/** The key of the configuration. e.g. SHA-512 */
String INDEX_ID_DIGEST_ALGORITHM = "index.id.digest.algorithm";
/** The key of the configuration. e.g. admin */
String INDEX_USER_initial_password = "index.user.initial_password";
/** The key of the configuration. e.g. favorite_count */
String INDEX_FIELD_favorite_count = "index.field.favorite_count";
@ -3506,6 +3509,13 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
*/
String getIndexIdDigestAlgorithm();
/**
* Get the value for the key 'index.user.initial_password'. <br>
* The value is, e.g. admin <br>
* @return The value of found property. (NotNull: if not found, exception but basically no way)
*/
String getIndexUserInitialPassword();
/**
* Get the value for the key 'index.field.favorite_count'. <br>
* The value is, e.g. favorite_count <br>
@ -8463,6 +8473,10 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
return get(FessConfig.INDEX_ID_DIGEST_ALGORITHM);
}
public String getIndexUserInitialPassword() {
return get(FessConfig.INDEX_USER_initial_password);
}
public String getIndexFieldFavoriteCount() {
return get(FessConfig.INDEX_FIELD_favorite_count);
}
@ -10786,6 +10800,7 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
defaultMap.put(FessConfig.INDEX_number_of_shards, "5");
defaultMap.put(FessConfig.INDEX_auto_expand_replicas, "0-1");
defaultMap.put(FessConfig.INDEX_ID_DIGEST_ALGORITHM, "SHA-512");
defaultMap.put(FessConfig.INDEX_USER_initial_password, "admin");
defaultMap.put(FessConfig.INDEX_FIELD_favorite_count, "favorite_count");
defaultMap.put(FessConfig.INDEX_FIELD_click_count, "click_count");
defaultMap.put(FessConfig.INDEX_FIELD_config_id, "config_id");

View file

@ -289,6 +289,7 @@ index.codec=default
index.number_of_shards=5
index.auto_expand_replicas=0-1
index.id.digest.algorithm=SHA-512
index.user.initial_password=admin
# field names
index.field.favorite_count=favorite_count

View file

@ -1,2 +1,2 @@
{"index":{"_index":"fess_user.user","_id":"YWRtaW4="}}
{"password":"8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918","surname":"admin","roles":["YWRtaW4=","Z3Vlc3Q="],"name":"admin"}
{"password":"${fess.index.initial_password}","surname":"admin","roles":["YWRtaW4=","Z3Vlc3Q="],"name":"admin"}