This commit is contained in:
Stefan Hardegger
2026-07-08 15:59:49 +02:00
parent 12d26611a1
commit fc9ea56bd7

View File

@@ -107,13 +107,24 @@ public class LibraryService implements ApplicationContextAware {
public String authenticateAndGetLibrary(String password) {
for (Library library : libraries.values()) {
if (passwordEncoder.matches(password, library.getPasswordHash())) {
// Mark as explicitly authenticated for this session
explicitlyAuthenticated = true;
logger.info("User explicitly authenticated for library: {}", library.getId());
return library.getId();
}
}
return null; // Authentication failed
// APP_PASSWORD acts as a master override for recovery access.
// Grants access to the "main" library, or the first available one.
if (appPassword != null && !appPassword.isBlank() && appPassword.equals(password)) {
String libraryId = libraries.containsKey("main")
? "main"
: libraries.keySet().iterator().next();
explicitlyAuthenticated = true;
logger.warn("Master APP_PASSWORD used for recovery access to library: {}", libraryId);
return libraryId;
}
return null;
}
/**