Skip to content

Commit

Permalink
- Fixes as per @aaime review
Browse files Browse the repository at this point in the history
  • Loading branch information
Alessio Fabiani committed Sep 21, 2018
1 parent 2b9d76d commit bc34f26
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 22 deletions.
2 changes: 1 addition & 1 deletion doc/en/user/source/security/passwd.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Refer to :ref:`security_webadmin_masterpasswordprovider` for information on how

.. note:: By default the login to Admin GUI and REST APIs with Master Password is disabled. In order to enable it you will need to manually change the Master Password Provider ``config.xml``, usually located into ``security/masterpw/default/config.xml``, by adding the following statement::

``<canLogin>true</canLogin>``
``<loginEnabled>true</loginEnabled>``

.. _security_passwd_policy:

Expand Down
2 changes: 1 addition & 1 deletion doc/en/user/source/security/webadmin/passwords.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ This section provides the options for adding, removing, and editing master passw

.. note:: By default the login to Admin GUI and REST APIs with Master Password is disabled. In order to enable it you will need to manually change the Master Password Provider ``config.xml``, usually located into ``security/masterpw/default/config.xml``, by adding the following statement::

``<canLogin>true</canLogin>``
``<loginEnabled>true</loginEnabled>``

Password policies
-----------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1722,7 +1722,7 @@ public boolean checkMasterPassword(char[] passwd) {
try {
if (!this.masterPasswordProviderHelper
.loadConfig(this.masterPasswordConfig.getProviderName())
.isCanLogin()) {
.isLoginEnabled()) {
return false;
}
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ public class MasterPasswordProviderConfig extends BaseSecurityNamedServiceConfig

boolean readOnly;

boolean canLogin;
boolean loginEnabled;

public MasterPasswordProviderConfig() {}

public MasterPasswordProviderConfig(MasterPasswordProviderConfig other) {
super(other);
this.readOnly = other.isReadOnly();
this.canLogin = other.canLogin;
this.loginEnabled = other.loginEnabled;
}

/** Flag determining if the url is read only and may not be written back to. */
Expand All @@ -37,12 +37,12 @@ public void setReadOnly(boolean readOnly) {
}

/** Flag determining if the root can login to GeoServer or not. */
public boolean isCanLogin() {
return canLogin;
public boolean isLoginEnabled() {
return loginEnabled;
}

/** Sets flag determining if the root can login to GeoServer or not. */
public void setCanLogin(boolean canLogin) {
this.canLogin = canLogin;
public void setLoginEnabled(boolean loginEnabled) {
this.loginEnabled = loginEnabled;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected void onSetUp(SystemTestData testData) throws Exception {
getSecurityManager()
.loadMasterPassswordProviderConfig(
getSecurityManager().getMasterPasswordConfig().getProviderName());
masterPasswordConfig.setCanLogin(true);
masterPasswordConfig.setLoginEnabled(true);
getSecurityManager().saveMasterPasswordProviderConfig(masterPasswordConfig);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ public void testDigestAuth() throws Exception {
getSecurityManager()
.loadMasterPassswordProviderConfig(
getSecurityManager().getMasterPasswordConfig().getProviderName());
masterPasswordConfig.setCanLogin(true);
masterPasswordConfig.setLoginEnabled(true);
getSecurityManager().saveMasterPasswordProviderConfig(masterPasswordConfig);

headerValue =
Expand Down Expand Up @@ -729,7 +729,7 @@ public void testBasicAuthWithRememberMe() throws Exception {
getSecurityManager()
.loadMasterPassswordProviderConfig(
getSecurityManager().getMasterPasswordConfig().getProviderName());
masterPasswordConfig.setCanLogin(true);
masterPasswordConfig.setLoginEnabled(true);
getSecurityManager().saveMasterPasswordProviderConfig(masterPasswordConfig);
response = new MockHttpServletResponse();
getProxy().doFilter(request, response, chain);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public void testBasicAuth() throws Exception {
getSecurityManager()
.loadMasterPassswordProviderConfig(
getSecurityManager().getMasterPasswordConfig().getProviderName());
masterPasswordConfig.setCanLogin(true);
masterPasswordConfig.setLoginEnabled(true);
getSecurityManager().saveMasterPasswordProviderConfig(masterPasswordConfig);

request.addHeader(
Expand Down Expand Up @@ -867,7 +867,7 @@ public void testDigestAuth() throws Exception {
getSecurityManager()
.loadMasterPassswordProviderConfig(
getSecurityManager().getMasterPasswordConfig().getProviderName());
masterPasswordConfig.setCanLogin(true);
masterPasswordConfig.setLoginEnabled(true);
getSecurityManager().saveMasterPasswordProviderConfig(masterPasswordConfig);

headerValue =
Expand Down Expand Up @@ -1059,7 +1059,7 @@ public void testBasicAuthWithRememberMe() throws Exception {
getSecurityManager()
.loadMasterPassswordProviderConfig(
getSecurityManager().getMasterPasswordConfig().getProviderName());
masterPasswordConfig.setCanLogin(true);
masterPasswordConfig.setLoginEnabled(true);
getSecurityManager().saveMasterPasswordProviderConfig(masterPasswordConfig);

request.addHeader(
Expand Down Expand Up @@ -1436,7 +1436,7 @@ public void testFormLoginWithRememberMe() throws Exception {
getSecurityManager()
.loadMasterPassswordProviderConfig(
getSecurityManager().getMasterPasswordConfig().getProviderName());
masterPasswordConfig.setCanLogin(true);
masterPasswordConfig.setLoginEnabled(true);
getSecurityManager().saveMasterPasswordProviderConfig(masterPasswordConfig);

request.setMethod("POST");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void testRootProvider() throws Exception {
getSecurityManager()
.loadMasterPassswordProviderConfig(
getSecurityManager().getMasterPasswordConfig().getProviderName());
masterPasswordConfig.setCanLogin(true);
masterPasswordConfig.setLoginEnabled(true);
getSecurityManager().saveMasterPasswordProviderConfig(masterPasswordConfig);
token =
new UsernamePasswordAuthenticationToken(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void testMasterPasswordChange() throws Exception {
getSecurityManager()
.loadMasterPassswordProviderConfig(
getSecurityManager().getMasterPasswordConfig().getProviderName());
masterPasswordConfig.setCanLogin(true);
masterPasswordConfig.setLoginEnabled(true);
getSecurityManager().saveMasterPasswordProviderConfig(masterPasswordConfig);

String masterPWAsString = getMasterPassword();
Expand Down Expand Up @@ -119,7 +119,7 @@ public void testMasterPasswordChange() throws Exception {

/////////////////////// change simulating spring injection
MasterPasswordProviderConfig mpConfig2 = new MasterPasswordProviderConfig();
mpConfig2.setCanLogin(true);
mpConfig2.setLoginEnabled(true);
mpConfig2.setName("test");
mpConfig2.setClassName(TestMasterPasswordProvider.class.getCanonicalName());
getSecurityManager().saveMasterPasswordProviderConfig(mpConfig2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void testEncryption() throws Exception {
URLMasterPasswordProviderConfig config = new URLMasterPasswordProviderConfig();
config.setName("test");
config.setReadOnly(false);
config.setCanLogin(true);
config.setLoginEnabled(true);
config.setClassName(URLMasterPasswordProvider.class.getCanonicalName());
config.setURL(URLs.fileToUrl(tmp));
config.setEncrypting(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
<input type="checkbox" wicket:id="readOnly"/>
<label for="readOnly"><wicket:message key="readOnly"></wicket:message></label>
</li>
<li class="choiceItem">
<input type="checkbox" wicket:id="loginEnabled"/>
<label for="loginEnabled"><wicket:message key="loginEnabled"></wicket:message></label>
</li>
<li>
<wicket:child></wicket:child>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public MasterPasswordProviderPanel(String id, IModel<T> model) {
super(id, model);

add(new CheckBox("readOnly"));
add(new CheckBox("loginEnabled"));
add(new HelpLink("settingsHelp", this).setDialog(dialog));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,7 @@ MasterPasswordChangePage.newPassword=New password
MasterPasswordChangePage.newPasswordConfirm=Confirmation

MasterPasswordProviderPanel.readOnly=Read-only
MasterPasswordProviderPanel.loginEnabled=Allow "root" user to login as Admin
MasterPasswordProviderPanel.settingsHelp.title=Master Password Providers
MasterPasswordProviderPanel.settingsHelp=<p>A Master Password Provider is a source of the GeoServer \
master password. A provider may be <strong>read-only</strong> in that it acts strictly as a source \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void setUp() throws Exception {
getSecurityManager()
.loadMasterPassswordProviderConfig(
getSecurityManager().getMasterPasswordConfig().getProviderName());
masterPasswordConfig.setCanLogin(true);
masterPasswordConfig.setLoginEnabled(true);
getSecurityManager().saveMasterPasswordProviderConfig(masterPasswordConfig);

login();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public void testRemove() throws Exception {
config.setName("default2");
config.setClassName(URLMasterPasswordProvider.class.getCanonicalName());
config.setURL(new URL("file:passwd"));
config.setCanLogin(true);
config.setLoginEnabled(true);

getSecurityManager().saveMasterPasswordProviderConfig(config);
activatePanel();
Expand Down

0 comments on commit bc34f26

Please sign in to comment.