mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-09 06:25:07 +00:00
Added info logging for auto-related files
- users - users_roles - roles.yml Original commit: elastic/x-pack-elasticsearch@e3ee647915
This commit is contained in:
parent
8320be7b09
commit
aa4269ff82
@ -13,6 +13,7 @@ import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.env.Environment;
|
||||
import org.elasticsearch.shield.ShieldException;
|
||||
import org.elasticsearch.shield.ShieldPlugin;
|
||||
import org.elasticsearch.shield.authc.support.Hasher;
|
||||
import org.elasticsearch.shield.authc.support.RefreshListener;
|
||||
@ -106,7 +107,7 @@ public class FileUserPasswdStore {
|
||||
try {
|
||||
lines = Files.readAllLines(path, Charsets.UTF_8);
|
||||
} catch (IOException ioe) {
|
||||
throw new ElasticsearchException("Could not read users file [" + path.toAbsolutePath() + "]", ioe);
|
||||
throw new ShieldException("Could not read users file [" + path.toAbsolutePath() + "]", ioe);
|
||||
}
|
||||
|
||||
ImmutableMap.Builder<String, char[]> users = ImmutableMap.builder();
|
||||
@ -167,16 +168,19 @@ public class FileUserPasswdStore {
|
||||
|
||||
@Override
|
||||
public void onFileDeleted(File file) {
|
||||
if (file.equals(FileUserPasswdStore.this.file.toFile())) {
|
||||
esUsers = ImmutableMap.of();
|
||||
notifyRefresh();
|
||||
}
|
||||
onFileChanged(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFileChanged(File file) {
|
||||
if (file.equals(FileUserPasswdStore.this.file.toFile())) {
|
||||
esUsers = parseFile(file.toPath(), logger);
|
||||
try {
|
||||
esUsers = parseFile(file.toPath(), logger);
|
||||
logger.info("updated users (users file [{}] changed)", file.getAbsolutePath());
|
||||
} catch (Throwable t) {
|
||||
logger.error("Failed to parse users file [{}]. Current users remain unmodified", t, file.getAbsolutePath());
|
||||
return;
|
||||
}
|
||||
notifyRefresh();
|
||||
}
|
||||
}
|
||||
|
@ -196,16 +196,19 @@ public class FileUserRolesStore {
|
||||
|
||||
@Override
|
||||
public void onFileDeleted(File file) {
|
||||
if (file.equals(FileUserRolesStore.this.file.toFile())) {
|
||||
userRoles = ImmutableMap.of();
|
||||
notifyRefresh();
|
||||
}
|
||||
onFileChanged(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFileChanged(File file) {
|
||||
if (file.equals(FileUserRolesStore.this.file.toFile())) {
|
||||
userRoles = parseFile(file.toPath(), logger);
|
||||
try {
|
||||
userRoles = parseFile(file.toPath(), logger);
|
||||
logger.info("updated users (users_roles file [{}] changed)", file.getAbsolutePath());
|
||||
} catch (Throwable t) {
|
||||
logger.error("Failed to parse users_roles file [{}]. Current users_roles remain unmodified", t, file.getAbsolutePath());
|
||||
return;
|
||||
}
|
||||
notifyRefresh();
|
||||
}
|
||||
}
|
||||
|
@ -245,7 +245,13 @@ public class FileRolesStore extends AbstractComponent implements RolesStore {
|
||||
@Override
|
||||
public void onFileChanged(File file) {
|
||||
if (file.equals(FileRolesStore.this.file.toFile())) {
|
||||
permissions = parseFile(file.toPath(), logger);
|
||||
try {
|
||||
permissions = parseFile(file.toPath(), logger);
|
||||
logger.info("updated roles (roles file [{}] changed)", file.getAbsolutePath());
|
||||
} catch (Throwable t) {
|
||||
logger.error("Could not reload roles file [{}]. Current roles remain unmodified", t, file.getAbsolutePath());
|
||||
return;
|
||||
}
|
||||
listener.onRefresh();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user