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 Original file line 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:: .. 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: .. _security_passwd_policy:


Expand Down
2 changes: 1 addition & 1 deletion doc/en/user/source/security/webadmin/passwords.rst
Original file line number Original file line 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:: .. 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 Password policies
----------------- -----------------
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1722,7 +1722,7 @@ public boolean checkMasterPassword(char[] passwd) {
try { try {
if (!this.masterPasswordProviderHelper if (!this.masterPasswordProviderHelper
.loadConfig(this.masterPasswordConfig.getProviderName()) .loadConfig(this.masterPasswordConfig.getProviderName())
.isCanLogin()) { .isLoginEnabled()) {
return false; return false;
} }
} catch (IOException e) { } catch (IOException e) {
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ public class MasterPasswordProviderConfig extends BaseSecurityNamedServiceConfig


boolean readOnly; boolean readOnly;


boolean canLogin; boolean loginEnabled;


public MasterPasswordProviderConfig() {} public MasterPasswordProviderConfig() {}


public MasterPasswordProviderConfig(MasterPasswordProviderConfig other) { public MasterPasswordProviderConfig(MasterPasswordProviderConfig other) {
super(other); super(other);
this.readOnly = other.isReadOnly(); 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. */ /** 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. */ /** Flag determining if the root can login to GeoServer or not. */
public boolean isCanLogin() { public boolean isLoginEnabled() {
return canLogin; return loginEnabled;
} }


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


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


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


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


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


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


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


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


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


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


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


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


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


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

0 comments on commit bc34f26

Please sign in to comment.