This is an automated email from the ASF dual-hosted git repository.
solomax pushed a commit to branch 4.0.x
in repository https://gitbox.apache.org/repos/asf/openmeetings.git
The following commit(s) were added to refs/heads/4.0.x by this push:
new f2e995f [OPENMEETINGS-1952] correct allow.register are being checked
f2e995f is described below
commit f2e995fe25c079d80ad76de1a66d60e627e7b93e
Author: Maxim Solodovnik <[email protected]>
AuthorDate: Tue Oct 9 13:24:17 2018 +0700
[OPENMEETINGS-1952] correct allow.register are being checked
---
.../openmeetings/core/remote/MobileService.java | 12 ++++-----
.../db/dao/basic/ConfigurationDao.java | 30 ++++++++++++++++++++++
.../openmeetings/db/dao/server/OAuth2Dao.java | 6 +++++
.../openmeetings/util/OpenmeetingsVariables.java | 27 +++++++++++++++++++
.../apache/openmeetings/web/app/UserManager.java | 7 +++--
.../web/pages/auth/RegisterDialog.java | 1 -
.../openmeetings/web/pages/auth/SignInPage.java | 4 +--
.../openmeetings/webservice/UserWebService.java | 4 +++
8 files changed, 80 insertions(+), 11 deletions(-)
diff --git
a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/MobileService.java
b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/MobileService.java
index ed85d9c..35288da 100644
---
a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/MobileService.java
+++
b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/MobileService.java
@@ -22,12 +22,12 @@ import static
org.apache.openmeetings.db.util.LocaleHelper.getCountryName;
import static org.apache.openmeetings.util.OmException.UNKNOWN;
import static
org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_EMAIL_VERIFICATION;
import static
org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_MYROOMS_ENABLED;
-import static
org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_REGISTER_FRONTEND;
-import static
org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_REGISTER_OAUTH;
import static org.apache.openmeetings.util.OpenmeetingsVariables.PARAM_STATUS;
import static org.apache.openmeetings.util.OpenmeetingsVariables.PARAM_USER_ID;
import static org.apache.openmeetings.util.OpenmeetingsVariables.getBaseUrl;
import static
org.apache.openmeetings.util.OpenmeetingsVariables.getWebAppRootKey;
+import static
org.apache.openmeetings.util.OpenmeetingsVariables.isAllowRegisterFrontend;
+import static
org.apache.openmeetings.util.OpenmeetingsVariables.isAllowRegisterOauth;
import static org.apache.openmeetings.util.Version.getVersion;
import java.io.Serializable;
@@ -120,8 +120,8 @@ public class MobileService {
public Map<String, Object> checkServer() {
Map<String, Object> result = new HashMap<>();
- result.put("allowSelfRegister",
cfgDao.getBool(CONFIG_REGISTER_FRONTEND, false));
- result.put("allowOauthRegister",
cfgDao.getBool(CONFIG_REGISTER_OAUTH, false));
+ result.put("allowSelfRegister", isAllowRegisterFrontend());
+ result.put("allowOauthRegister", isAllowRegisterOauth());
return result;
}
@@ -140,7 +140,7 @@ public class MobileService {
public Map<String, Object> loginGoogle(Map<String, String> umap) {
Map<String, Object> result = getResult();
try {
- if (cfgDao.getBool(CONFIG_REGISTER_OAUTH, false)) {
+ if (isAllowRegisterOauth()) {
User u = userManager.loginOAuth(new
OAuthUser(umap), 2); //TODO hardcoded
result = login(u, result);
}
@@ -153,7 +153,7 @@ public class MobileService {
public Map<String, Object> registerUser(Map<String, String> umap) {
Map<String, Object> result = getResult();
try {
- if (cfgDao.getBool(CONFIG_REGISTER_FRONTEND, false)) {
+ if (isAllowRegisterFrontend()) {
String login = umap.get("login");
String email = umap.get("email");
String lastname = umap.get("lastname");
diff --git
a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/basic/ConfigurationDao.java
b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/basic/ConfigurationDao.java
index 1349204..e9d93b1 100644
---
a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/basic/ConfigurationDao.java
+++
b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/basic/ConfigurationDao.java
@@ -49,6 +49,9 @@ import static
org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_MP4_AUDI
import static
org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_MP4_AUDIO_RATE;
import static
org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_MP4_VIDEO_PRESET;
import static
org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_PASS_MIN_LENGTH;
+import static
org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_REGISTER_FRONTEND;
+import static
org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_REGISTER_OAUTH;
+import static
org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_REGISTER_SOAP;
import static
org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_REST_ALLOW_ORIGIN;
import static
org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_SIP_ENABLED;
import static
org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_SIP_EXTEN_CONTEXT;
@@ -71,6 +74,9 @@ import static
org.apache.openmeetings.util.OpenmeetingsVariables.USER_PASSWORD_M
import static
org.apache.openmeetings.util.OpenmeetingsVariables.getRoomSettings;
import static
org.apache.openmeetings.util.OpenmeetingsVariables.getWebAppRootKey;
import static
org.apache.openmeetings.util.OpenmeetingsVariables.getWicketApplicationName;
+import static
org.apache.openmeetings.util.OpenmeetingsVariables.setAllowRegisterFrontend;
+import static
org.apache.openmeetings.util.OpenmeetingsVariables.setAllowRegisterOauth;
+import static
org.apache.openmeetings.util.OpenmeetingsVariables.setAllowRegisterSoap;
import static
org.apache.openmeetings.util.OpenmeetingsVariables.setApplicationName;
import static
org.apache.openmeetings.util.OpenmeetingsVariables.setAudioBitrate;
import static org.apache.openmeetings.util.OpenmeetingsVariables.setAudioRate;
@@ -394,6 +400,15 @@ public class ConfigurationDao implements
IDataProviderDao<Configuration> {
case CONFIG_CHAT_SEND_ON_ENTER:
reloadChatSendOnEnter();
break;
+ case CONFIG_REGISTER_FRONTEND:
+ reloadAllowRegisterFront();
+ break;
+ case CONFIG_REGISTER_SOAP:
+ reloadAllowRegisterSoap();
+ break;
+ case CONFIG_REGISTER_OAUTH:
+ reloadAllowRegisterOauth();
+ break;
}
return entity;
}
@@ -497,6 +512,18 @@ public class ConfigurationDao implements
IDataProviderDao<Configuration> {
setChatSenndOnEnter(getBool(CONFIG_CHAT_SEND_ON_ENTER, false));
}
+ private void reloadAllowRegisterFront() {
+ setAllowRegisterFrontend(getBool(CONFIG_REGISTER_FRONTEND,
false));
+ }
+
+ private void reloadAllowRegisterSoap() {
+ setAllowRegisterSoap(getBool(CONFIG_REGISTER_SOAP, false));
+ }
+
+ private void reloadAllowRegisterOauth() {
+ setAllowRegisterOauth(getBool(CONFIG_REGISTER_OAUTH, false));
+ }
+
public void reinit() {
reloadMaxUpload();
reloadCrypt();
@@ -518,6 +545,9 @@ public class ConfigurationDao implements
IDataProviderDao<Configuration> {
reloadFnameMinLength();
reloadLnameMinLength();
reloadChatSendOnEnter();
+ reloadAllowRegisterFront();
+ reloadAllowRegisterSoap();
+ reloadAllowRegisterOauth();
}
private JSONObject reloadRoomSettings() {
diff --git
a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/server/OAuth2Dao.java
b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/server/OAuth2Dao.java
index 1d3633b..8ad578c 100644
---
a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/server/OAuth2Dao.java
+++
b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/server/OAuth2Dao.java
@@ -18,6 +18,9 @@
*/
package org.apache.openmeetings.db.dao.server;
+import static
org.apache.openmeetings.util.OpenmeetingsVariables.isAllowRegisterOauth;
+
+import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -39,6 +42,9 @@ public class OAuth2Dao implements
IDataProviderDao<OAuthServer> {
private EntityManager em;
public List<OAuthServer> getActive() {
+ if (!isAllowRegisterOauth()) {
+ return new ArrayList<>();
+ }
TypedQuery<OAuthServer> query =
em.createNamedQuery("getEnabledOAuthServers", OAuthServer.class);
return query.getResultList();
}
diff --git
a/openmeetings-util/src/main/java/org/apache/openmeetings/util/OpenmeetingsVariables.java
b/openmeetings-util/src/main/java/org/apache/openmeetings/util/OpenmeetingsVariables.java
index 66be625..ad462c9 100644
---
a/openmeetings-util/src/main/java/org/apache/openmeetings/util/OpenmeetingsVariables.java
+++
b/openmeetings-util/src/main/java/org/apache/openmeetings/util/OpenmeetingsVariables.java
@@ -145,6 +145,9 @@ public class OpenmeetingsVariables {
private static int minFnameLength = USER_LOGIN_MINIMUM_LENGTH;
private static int minLnameLength = USER_LOGIN_MINIMUM_LENGTH;
private static boolean chatSendOnEnter = false;
+ private static boolean allowRegisterFrontend = false;
+ private static boolean allowRegisterSoap = false;
+ private static boolean allowRegisterOauth = false;
private OpenmeetingsVariables() {}
@@ -343,4 +346,28 @@ public class OpenmeetingsVariables {
public static void setChatSenndOnEnter(boolean sendOnEnter) {
chatSendOnEnter = sendOnEnter;
}
+
+ public static boolean isAllowRegisterFrontend() {
+ return allowRegisterFrontend;
+ }
+
+ public static void setAllowRegisterFrontend(boolean allow) {
+ allowRegisterFrontend = allow;
+ }
+
+ public static boolean isAllowRegisterSoap() {
+ return allowRegisterSoap;
+ }
+
+ public static void setAllowRegisterSoap(boolean allow) {
+ allowRegisterSoap = allow;
+ }
+
+ public static boolean isAllowRegisterOauth() {
+ return allowRegisterOauth;
+ }
+
+ public static void setAllowRegisterOauth(boolean allow) {
+ allowRegisterOauth = allow;
+ }
}
diff --git
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/UserManager.java
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/UserManager.java
index 1df4fc9..849dedb4 100644
---
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/UserManager.java
+++
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/UserManager.java
@@ -23,12 +23,12 @@ import static
org.apache.openmeetings.db.util.TimezoneUtil.getTimeZone;
import static org.apache.openmeetings.util.OmException.UNKNOWN;
import static org.apache.openmeetings.util.OmFileHelper.HIBERNATE;
import static
org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_EMAIL_VERIFICATION;
-import static
org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_REGISTER_SOAP;
import static org.apache.openmeetings.util.OpenmeetingsVariables.getBaseUrl;
import static
org.apache.openmeetings.util.OpenmeetingsVariables.getDefaultGroup;
import static
org.apache.openmeetings.util.OpenmeetingsVariables.getDefaultLang;
import static
org.apache.openmeetings.util.OpenmeetingsVariables.getMinLoginLength;
import static
org.apache.openmeetings.util.OpenmeetingsVariables.getWebAppRootKey;
+import static
org.apache.openmeetings.util.OpenmeetingsVariables.isAllowRegisterFrontend;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
@@ -112,7 +112,7 @@ public class UserManager implements IUserManager {
String firstname, String email, String country, long
languageId, String tzId) {
try {
// Checks if FrontEndUsers can register
- if (cfgDao.getBool(CONFIG_REGISTER_SOAP, false)) {
+ if (isAllowRegisterFrontend()) {
User u = getNewUserInstance(null);
u.setFirstname(firstname);
u.setLogin(login);
@@ -128,11 +128,14 @@ public class UserManager implements IUserManager {
Object user = registerUser(u, password, null);
if (user instanceof User && sendConfirmation())
{
+ log.debug("User created, confirmation
should be sent");
return -40L;
}
+ log.debug("User creation result: {}", user);
return user;
} else {
+ log.warn("Frontend registering is disabled");
return "error.reg.disabled";
}
} catch (Exception e) {
diff --git
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/pages/auth/RegisterDialog.java
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/pages/auth/RegisterDialog.java
index 872c278..41e616d 100644
---
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/pages/auth/RegisterDialog.java
+++
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/pages/auth/RegisterDialog.java
@@ -195,7 +195,6 @@ public class RegisterDialog extends
NonClosableDialog<String> {
} catch (Exception e) {
log.error("[registerUser]", e);
}
-
confirmRegistration.open(target);
}
diff --git
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/pages/auth/SignInPage.java
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/pages/auth/SignInPage.java
index 3e42312..f0f10bd 100644
---
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/pages/auth/SignInPage.java
+++
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/pages/auth/SignInPage.java
@@ -20,9 +20,9 @@ package org.apache.openmeetings.web.pages.auth;
import static java.nio.charset.StandardCharsets.UTF_8;
import static
org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_IGNORE_BAD_SSL;
-import static
org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_REGISTER_FRONTEND;
import static org.apache.openmeetings.util.OpenmeetingsVariables.getBaseUrl;
import static
org.apache.openmeetings.util.OpenmeetingsVariables.getWebAppRootKey;
+import static
org.apache.openmeetings.util.OpenmeetingsVariables.isAllowRegisterFrontend;
import static org.apache.openmeetings.web.app.Application.getBean;
import static org.apache.openmeetings.web.app.Application.urlForPage;
@@ -135,7 +135,7 @@ public class SignInPage extends BaseInitedPage {
}
static boolean allowRegister() {
- return
getBean(ConfigurationDao.class).getBool(CONFIG_REGISTER_FRONTEND, false);
+ return isAllowRegisterFrontend();
}
static boolean allowOAuthLogin() {
diff --git
a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/UserWebService.java
b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/UserWebService.java
index 55345d4..e2033bd 100644
---
a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/UserWebService.java
+++
b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/UserWebService.java
@@ -22,6 +22,7 @@ import static
org.apache.openmeetings.db.dto.basic.ServiceResult.UNKNOWN;
import static
org.apache.openmeetings.util.OpenmeetingsVariables.getDefaultGroup;
import static
org.apache.openmeetings.util.OpenmeetingsVariables.getDefaultTimezone;
import static
org.apache.openmeetings.util.OpenmeetingsVariables.getWebAppRootKey;
+import static
org.apache.openmeetings.util.OpenmeetingsVariables.isAllowRegisterSoap;
import static org.apache.openmeetings.webservice.Constants.TNS;
import static org.apache.openmeetings.webservice.Constants.USER_SERVICE_NAME;
import static
org.apache.openmeetings.webservice.Constants.USER_SERVICE_PORT_NAME;
@@ -154,6 +155,9 @@ public class UserWebService extends BaseWebService {
{
return performCall(sid, User.Right.Soap, sd -> {
UserDao userDao = getUserDao();
+ if (!isAllowRegisterSoap()) {
+ throw new ServiceException("Soap register is
denied in Settings");
+ }
User testUser =
userDao.getExternalUser(user.getExternalId(), user.getExternalType());
if (testUser != null) {