Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

added adminAccount switch to ConfigAccounts_p servlet to switch on protection of all pages; some refactoring as well

orbiter3c8d6e1eee63
diff --git a/htroot/ConfigAccounts_p.html b/htroot/ConfigAccounts_p.html
index eb4287754..d2a390638 100644
--- a/htroot/ConfigAccounts_p.html
+++ b/htroot/ConfigAccounts_p.html
@@ -55,6 +55,20 @@
</fieldset>
</form>
</fieldset>
+
+ <fieldset><legend>Access Rules</legend>
+ <form action="ConfigAccounts_p.html" method="post" accept-charset="UTF-8">
+ <dl class="userConfig">
+ <dt>Protection of all pages: if set to on, access to all pages need authorization; if off, only pages with "_p" extension are protected.</dt>
+ <dd><input type="checkbox" name="adminAccountAllPages" data-size="small"#(adminAccountAllPages.checked)#:: checked="checked"#(/adminAccountAllPages.checked)#></dd>
+ <script>$("[name='adminAccountAllPages']").bootstrapSwitch();
+ $("[name='adminAccountAllPages']").bootstrapSwitch('onText', 'ON');
+ $("[name='adminAccountAllPages']").bootstrapSwitch('offText', 'OFF');</script>
+ <dt></dt>
+ <dd><input type="submit" name="setAccess" value="Set Access Rules" class="submitready"/></dd>
+ </dl>
+ </form>
+ </fieldset>
<fieldset><legend>User Accounts</legend>
<form action="ConfigAccounts_p.html" accept-charset="UTF-8">
diff --git a/htroot/ConfigAccounts_p.java b/htroot/ConfigAccounts_p.java
index ab69bd2e5..596cb3c42 100644
--- a/htroot/ConfigAccounts_p.java
+++ b/htroot/ConfigAccounts_p.java
@@ -54,6 +54,11 @@ public class ConfigAccounts_p {
// admin password
boolean localhostAccess = sb.getConfigBool(SwitchboardConstants.ADMIN_ACCOUNT_FOR_LOCALHOST, false);
+
+ if (post != null && post.containsKey("setAccess")) {
+ sb.setConfig(SwitchboardConstants.ADMIN_ACCOUNT_All_PAGES, post.getBoolean(SwitchboardConstants.ADMIN_ACCOUNT_All_PAGES));
+ }
+
if (post != null && post.containsKey("setAdmin")) {
localhostAccess = post.get("access", "").equals("localhost");
final String user = post.get("adminuser", "");
@@ -108,6 +113,7 @@ public class ConfigAccounts_p {
prop.put("passwordNotSetWarning", 1);
}
+ prop.put(SwitchboardConstants.ADMIN_ACCOUNT_All_PAGES + ".checked", sb.getConfigBool(SwitchboardConstants.ADMIN_ACCOUNT_All_PAGES, false) ? 1 : 0);
prop.put("localhost.checked", (localhostAccess) ? 1 : 0);
prop.put("account.checked", (localhostAccess) ? 0 : 1);
prop.put("statusPassword", localhostAccess ? "0" : "1");
diff --git a/htroot/ConfigPortal.java b/htroot/ConfigPortal.java
index 6a504d4ed..83abe30fa 100644
--- a/htroot/ConfigPortal.java
+++ b/htroot/ConfigPortal.java
@@ -85,7 +85,7 @@ public class ConfigPortal {
sb.setConfig(SwitchboardConstants.INDEX_FORWARD, post.get(SwitchboardConstants.INDEX_FORWARD, ""));
HTTPDFileHandler.indexForward = post.get(SwitchboardConstants.INDEX_FORWARD, "");
sb.setConfig("publicTopmenu", !post.containsKey("publicTopmenu") || post.getBoolean("publicTopmenu"));
- sb.setConfig("publicSearchpage", !post.containsKey("publicSearchpage") || post.getBoolean("publicSearchpage"));
+ sb.setConfig(SwitchboardConstants.PUBLIC_SEARCHPAGE, !post.containsKey(SwitchboardConstants.PUBLIC_SEARCHPAGE) || post.getBoolean(SwitchboardConstants.PUBLIC_SEARCHPAGE));
sb.setConfig("search.options", post.getBoolean("search.options"));
sb.setConfig("interaction.userlogon.enabled", post.getBoolean("interaction.userlogon"));
@@ -135,7 +135,7 @@ public class ConfigPortal {
sb.setConfig(SwitchboardConstants.SEARCH_TARGET_SPECIAL, config.getProperty(SwitchboardConstants.SEARCH_TARGET_SPECIAL,"_self"));
sb.setConfig(SwitchboardConstants.SEARCH_TARGET_SPECIAL_PATTERN, config.getProperty(SwitchboardConstants.SEARCH_TARGET_SPECIAL_PATTERN,""));
sb.setConfig("publicTopmenu", config.getProperty("publicTopmenu","true"));
- sb.setConfig("publicSearchpage", config.getProperty("publicSearchpage","true"));
+ sb.setConfig(SwitchboardConstants.PUBLIC_SEARCHPAGE, config.getProperty(SwitchboardConstants.PUBLIC_SEARCHPAGE,"true"));
sb.setConfig("search.navigation", config.getProperty("search.navigation","hosts,authors,namespace,topics"));
sb.setConfig("search.options", config.getProperty("search.options","true"));
sb.setConfig("interaction.userlogon.enabled", config.getProperty("interaction.userlogon.enabled","false"));
@@ -155,7 +155,7 @@ public class ConfigPortal {
prop.putHTML(SwitchboardConstants.GREETING_SMALL_IMAGE, sb.getConfig(SwitchboardConstants.GREETING_SMALL_IMAGE, ""));
prop.putHTML(SwitchboardConstants.INDEX_FORWARD, sb.getConfig(SwitchboardConstants.INDEX_FORWARD, ""));
prop.put("publicTopmenu", sb.getConfigBool("publicTopmenu", false) ? 1 : 0);
- prop.put("publicSearchpage", sb.getConfigBool("publicSearchpage", false) ? 1 : 0);
+ prop.put(SwitchboardConstants.PUBLIC_SEARCHPAGE, sb.getConfigBool(SwitchboardConstants.PUBLIC_SEARCHPAGE, false) ? 1 : 0);
prop.put("search.options", sb.getConfigBool("search.options", false) ? 1 : 0);
prop.put("interaction.userlogon", sb.getConfigBool("interaction.userlogon.enabled", false) ? 1 : 0);
diff --git a/htroot/HostBrowser.java b/htroot/HostBrowser.java
index f7cb97073..235447702 100644
--- a/htroot/HostBrowser.java
+++ b/htroot/HostBrowser.java
@@ -81,7 +81,7 @@ public class HostBrowser {
final boolean autoload = admin && sb.getConfigBool("browser.autoload", true);
final boolean load4everyone = sb.getConfigBool("browser.load4everyone", false);
final boolean loadRight = autoload || load4everyone; // add config later
- final boolean searchAllowed = sb.getConfigBool("publicSearchpage", true) || admin;
+ final boolean searchAllowed = sb.getConfigBool(SwitchboardConstants.PUBLIC_SEARCHPAGE, true) || admin;
final serverObjects prop = new serverObjects();
diff --git a/htroot/yacysearch.java b/htroot/yacysearch.java
index 1a55c868a..bc3167575 100644
--- a/htroot/yacysearch.java
+++ b/htroot/yacysearch.java
@@ -99,7 +99,7 @@ public class yacysearch {
sb.localSearchLastAccess = System.currentTimeMillis();
final boolean authorized = sb.verifyAuthentication(header);
- final boolean searchAllowed = sb.getConfigBool("publicSearchpage", true) || authorized;
+ final boolean searchAllowed = sb.getConfigBool(SwitchboardConstants.PUBLIC_SEARCHPAGE, true) || authorized;
boolean authenticated = sb.adminAuthenticated(header) >= 2;
if ( !authenticated ) {
diff --git a/source/net/yacy/http/Jetty8YaCySecurityHandler.java b/source/net/yacy/http/Jetty8YaCySecurityHandler.java
index 6f8a08692..7b002782c 100644
--- a/source/net/yacy/http/Jetty8YaCySecurityHandler.java
+++ b/source/net/yacy/http/Jetty8YaCySecurityHandler.java
@@ -84,7 +84,7 @@ public class Jetty8YaCySecurityHandler extends ConstraintSecurityHandler {
final boolean grantedForLocalhost = adminAccountGrantedForLocalhost && accessFromLocalhost;
boolean protectedPage = adminAccountNeededForAllPages || (pathInContext.indexOf("_p.") > 0);
// check "/gsa" and "/solr" if not publicSearchpage
- if (!protectedPage && !sb.getConfigBool("publicSearchpage", true)) {
+ if (!protectedPage && !sb.getConfigBool(SwitchboardConstants.PUBLIC_SEARCHPAGE, true)) {
protectedPage = pathInContext.startsWith("/solr/") || pathInContext.startsWith("/gsa/");
}
//final boolean accountEmpty = adminAccountBase64MD5.length() == 0;
diff --git a/source/net/yacy/http/servlets/GSAsearchServlet.java b/source/net/yacy/http/servlets/GSAsearchServlet.java
index fd143939b..8b65b677d 100644
--- a/source/net/yacy/http/servlets/GSAsearchServlet.java
+++ b/source/net/yacy/http/servlets/GSAsearchServlet.java
@@ -40,6 +40,7 @@ import net.yacy.cora.protocol.HeaderFramework;
import net.yacy.cora.util.ConcurrentLog;
import net.yacy.data.UserDB;
import net.yacy.search.Switchboard;
+import net.yacy.search.SwitchboardConstants;
import net.yacy.search.query.AccessTracker;
import net.yacy.search.query.QueryGoal;
import net.yacy.search.query.QueryModifier;
@@ -102,7 +103,7 @@ public class GSAsearchServlet extends HttpServlet {
// --- handled by Servlet securityHandler
// check if user is allowed to search (can be switched in /ConfigPortal.html)
boolean authenticated = header.isUserInRole(UserDB.AccessRight.ADMIN_RIGHT.toString()); //sb.adminAuthenticated(header) >= 2;
- // final boolean searchAllowed = authenticated || sb.getConfigBool("publicSearchpage", true);
+ // final boolean searchAllowed = authenticated || sb.getConfigBool(SwitchboardConstants.PUBLIC_SEARCHPAGE, true);
// if (!searchAllowed) return null;
// create post
diff --git a/source/net/yacy/search/SwitchboardConstants.java b/source/net/yacy/search/SwitchboardConstants.java
index fc6c91f77..17fa0812a 100644
--- a/source/net/yacy/search/SwitchboardConstants.java
+++ b/source/net/yacy/search/SwitchboardConstants.java
@@ -50,6 +50,8 @@ public final class SwitchboardConstants {
public static final String ADMIN_ACCOUNT_All_PAGES = "adminAccountAllPages";
public static final String ADMIN_REALM = "adminRealm";
+ public static final String PUBLIC_SEARCHPAGE = "publicSearchpage";
+
public static final int CRAWLJOB_SYNC = 0;
public static final int CRAWLJOB_STATUS = 1;
// 20_dhtdistribution