added adminAccount switch to ConfigAccounts_p servlet to switch on

protection of all pages; some refactoring as well
pull/1/head
orbiter 11 years ago
parent f8e998d660
commit 3c8d6e1eee

@ -55,6 +55,20 @@
</fieldset> </fieldset>
</form> </form>
</fieldset> </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> <fieldset><legend>User Accounts</legend>
<form action="ConfigAccounts_p.html" accept-charset="UTF-8"> <form action="ConfigAccounts_p.html" accept-charset="UTF-8">

@ -54,6 +54,11 @@ public class ConfigAccounts_p {
// admin password // admin password
boolean localhostAccess = sb.getConfigBool(SwitchboardConstants.ADMIN_ACCOUNT_FOR_LOCALHOST, false); 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")) { if (post != null && post.containsKey("setAdmin")) {
localhostAccess = post.get("access", "").equals("localhost"); localhostAccess = post.get("access", "").equals("localhost");
final String user = post.get("adminuser", ""); final String user = post.get("adminuser", "");
@ -108,6 +113,7 @@ public class ConfigAccounts_p {
prop.put("passwordNotSetWarning", 1); 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("localhost.checked", (localhostAccess) ? 1 : 0);
prop.put("account.checked", (localhostAccess) ? 0 : 1); prop.put("account.checked", (localhostAccess) ? 0 : 1);
prop.put("statusPassword", localhostAccess ? "0" : "1"); prop.put("statusPassword", localhostAccess ? "0" : "1");

@ -85,7 +85,7 @@ public class ConfigPortal {
sb.setConfig(SwitchboardConstants.INDEX_FORWARD, post.get(SwitchboardConstants.INDEX_FORWARD, "")); sb.setConfig(SwitchboardConstants.INDEX_FORWARD, post.get(SwitchboardConstants.INDEX_FORWARD, ""));
HTTPDFileHandler.indexForward = post.get(SwitchboardConstants.INDEX_FORWARD, ""); HTTPDFileHandler.indexForward = post.get(SwitchboardConstants.INDEX_FORWARD, "");
sb.setConfig("publicTopmenu", !post.containsKey("publicTopmenu") || post.getBoolean("publicTopmenu")); 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("search.options", post.getBoolean("search.options"));
sb.setConfig("interaction.userlogon.enabled", post.getBoolean("interaction.userlogon")); 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, config.getProperty(SwitchboardConstants.SEARCH_TARGET_SPECIAL,"_self"));
sb.setConfig(SwitchboardConstants.SEARCH_TARGET_SPECIAL_PATTERN, config.getProperty(SwitchboardConstants.SEARCH_TARGET_SPECIAL_PATTERN,"")); sb.setConfig(SwitchboardConstants.SEARCH_TARGET_SPECIAL_PATTERN, config.getProperty(SwitchboardConstants.SEARCH_TARGET_SPECIAL_PATTERN,""));
sb.setConfig("publicTopmenu", config.getProperty("publicTopmenu","true")); 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.navigation", config.getProperty("search.navigation","hosts,authors,namespace,topics"));
sb.setConfig("search.options", config.getProperty("search.options","true")); sb.setConfig("search.options", config.getProperty("search.options","true"));
sb.setConfig("interaction.userlogon.enabled", config.getProperty("interaction.userlogon.enabled","false")); 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.GREETING_SMALL_IMAGE, sb.getConfig(SwitchboardConstants.GREETING_SMALL_IMAGE, ""));
prop.putHTML(SwitchboardConstants.INDEX_FORWARD, sb.getConfig(SwitchboardConstants.INDEX_FORWARD, "")); prop.putHTML(SwitchboardConstants.INDEX_FORWARD, sb.getConfig(SwitchboardConstants.INDEX_FORWARD, ""));
prop.put("publicTopmenu", sb.getConfigBool("publicTopmenu", false) ? 1 : 0); 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("search.options", sb.getConfigBool("search.options", false) ? 1 : 0);
prop.put("interaction.userlogon", sb.getConfigBool("interaction.userlogon.enabled", false) ? 1 : 0); prop.put("interaction.userlogon", sb.getConfigBool("interaction.userlogon.enabled", false) ? 1 : 0);

@ -81,7 +81,7 @@ public class HostBrowser {
final boolean autoload = admin && sb.getConfigBool("browser.autoload", true); final boolean autoload = admin && sb.getConfigBool("browser.autoload", true);
final boolean load4everyone = sb.getConfigBool("browser.load4everyone", false); final boolean load4everyone = sb.getConfigBool("browser.load4everyone", false);
final boolean loadRight = autoload || load4everyone; // add config later 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(); final serverObjects prop = new serverObjects();

@ -99,7 +99,7 @@ public class yacysearch {
sb.localSearchLastAccess = System.currentTimeMillis(); sb.localSearchLastAccess = System.currentTimeMillis();
final boolean authorized = sb.verifyAuthentication(header); 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; boolean authenticated = sb.adminAuthenticated(header) >= 2;
if ( !authenticated ) { if ( !authenticated ) {

@ -84,7 +84,7 @@ public class Jetty8YaCySecurityHandler extends ConstraintSecurityHandler {
final boolean grantedForLocalhost = adminAccountGrantedForLocalhost && accessFromLocalhost; final boolean grantedForLocalhost = adminAccountGrantedForLocalhost && accessFromLocalhost;
boolean protectedPage = adminAccountNeededForAllPages || (pathInContext.indexOf("_p.") > 0); boolean protectedPage = adminAccountNeededForAllPages || (pathInContext.indexOf("_p.") > 0);
// check "/gsa" and "/solr" if not publicSearchpage // 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/"); protectedPage = pathInContext.startsWith("/solr/") || pathInContext.startsWith("/gsa/");
} }
//final boolean accountEmpty = adminAccountBase64MD5.length() == 0; //final boolean accountEmpty = adminAccountBase64MD5.length() == 0;

@ -40,6 +40,7 @@ import net.yacy.cora.protocol.HeaderFramework;
import net.yacy.cora.util.ConcurrentLog; import net.yacy.cora.util.ConcurrentLog;
import net.yacy.data.UserDB; import net.yacy.data.UserDB;
import net.yacy.search.Switchboard; import net.yacy.search.Switchboard;
import net.yacy.search.SwitchboardConstants;
import net.yacy.search.query.AccessTracker; import net.yacy.search.query.AccessTracker;
import net.yacy.search.query.QueryGoal; import net.yacy.search.query.QueryGoal;
import net.yacy.search.query.QueryModifier; import net.yacy.search.query.QueryModifier;
@ -102,7 +103,7 @@ public class GSAsearchServlet extends HttpServlet {
// --- handled by Servlet securityHandler // --- handled by Servlet securityHandler
// check if user is allowed to search (can be switched in /ConfigPortal.html) // 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; 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; // if (!searchAllowed) return null;
// create post // create post

@ -50,6 +50,8 @@ public final class SwitchboardConstants {
public static final String ADMIN_ACCOUNT_All_PAGES = "adminAccountAllPages"; public static final String ADMIN_ACCOUNT_All_PAGES = "adminAccountAllPages";
public static final String ADMIN_REALM = "adminRealm"; 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_SYNC = 0;
public static final int CRAWLJOB_STATUS = 1; public static final int CRAWLJOB_STATUS = 1;
// 20_dhtdistribution // 20_dhtdistribution

Loading…
Cancel
Save