imbajin commented on code in PR #3334:
URL: https://github.com/apache/hugegraph/pull/3334#discussion_r4259361087
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/auth/StandardAuthenticator.java:
##########
@@ -202,8 +226,67 @@ public static void initAdminUserIfNeeded(String confFile)
throws Exception {
config.addProperty(INITING_STORE, true);
auth.setup(config);
if (auth.graph().backendStoreFeatures().supportsPersistence()) {
- auth.initAdminUser();
+ auth.initAdminUser(config);
+ }
+ }
+
+ /**
+ * The initial admin password for the bootstrap paths that cannot prompt.
+ * auth.admin_pa goes through the properties grammar, which trims it,
+ * processes backslash escapes and decodes it as ISO-8859-1, so
+ * auth.admin_pa_file takes precedence when both are set.
+ */
+ public static String initialAdminPassword(HugeConfig config) {
+ String file = config.get(ServerOptions.ADMIN_PA_FILE);
+ if (!file.isEmpty()) {
+ return readAdminPasswordFile(file);
+ }
+ return config.get(ServerOptions.ADMIN_PA);
+ }
+
+ private static String readAdminPasswordFile(String file) {
+ String option = ServerOptions.ADMIN_PA_FILE.name();
+ byte[] bytes;
+ // Bounded, so a path that points at a log or a device fails quickly
+ try (InputStream in = Files.newInputStream(Paths.get(file))) {
Review Comment:
⚠️ Important. Blocking: yes. Summary: Opening a FIFO here blocks until a
writer connects, so a bad password path can hang startup before the byte limit
is enforced. Evidence: `Files.newInputStream(Paths.get(file))` opens with
default blocking semantics. Please reject non-regular paths before opening
(following symlinks to mounted regular secret files), then keep the byte bound.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]