mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-04 20:28:00 +08:00
Rename "ActiveDirectory" to "ExternalAuthentication" or something. #PL-4801
This commit is contained in:
parent
22dceaa6ff
commit
f4e8ad4a14
@ -28,7 +28,7 @@ public interface ServerConfig extends Config {
|
||||
|
||||
/**
|
||||
* @return Password used by LoginService.loginTrusted() method.
|
||||
* Trusted client may login without providing a user password. This is used by ActiveDirectory integration.
|
||||
* Trusted client may login without providing a user password. This is used for external authentication.
|
||||
*
|
||||
* <p>Must be equal to password set for the same property on the client.</p>
|
||||
*/
|
||||
|
@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2008-2013 Haulmont. All rights reserved.
|
||||
* Use is subject to license terms, see http://www.cuba-platform.com/license for details.
|
||||
*/
|
||||
package com.haulmont.cuba.web.auth;
|
||||
|
||||
import com.haulmont.cuba.core.global.AppBeans;
|
||||
import com.haulmont.cuba.core.global.Configuration;
|
||||
|
||||
/**
|
||||
* @author krivopustov
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ActiveDirectoryHelper {
|
||||
|
||||
public static boolean useActiveDirectory() {
|
||||
Configuration configuration = AppBeans.get(Configuration.NAME);
|
||||
WebAuthConfig config = configuration.getConfig(WebAuthConfig.class);
|
||||
return config.getUseActiveDirectory();
|
||||
}
|
||||
}
|
@ -12,7 +12,7 @@ import javax.annotation.ManagedBean;
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Simple factory bean for creation {@link CubaAuthProvider} by class from {@link WebAuthConfig#getActiveDirectoryAuthClass()}.<br/>
|
||||
* Simple factory bean for creation {@link CubaAuthProvider} by class from {@link WebAuthConfig#getExternalAuthenticationProviderClass()}.<br/>
|
||||
* CAUTION: We do not use placeholder in class parameter for bean due to DEBUG errors on Spring context start.
|
||||
*
|
||||
* @author artamonov
|
||||
@ -29,7 +29,7 @@ public class CubaAuthProviderFactory {
|
||||
|
||||
public CubaAuthProvider createAuthProvider() {
|
||||
WebAuthConfig authConfig = configuration.getConfig(WebAuthConfig.class);
|
||||
String providerClassName = authConfig.getActiveDirectoryAuthClass();
|
||||
String providerClassName = authConfig.getExternalAuthenticationProviderClass();
|
||||
|
||||
try {
|
||||
ClassLoader classLoader = applicationContext.getClassLoader();
|
||||
|
@ -11,7 +11,7 @@ package com.haulmont.cuba.web.auth;
|
||||
*/
|
||||
public interface DomainAliasesResolver {
|
||||
|
||||
public static final String NAME = "cuba_DomainResolver";
|
||||
String NAME = "cuba_DomainResolver";
|
||||
|
||||
String getDomainName(String alias);
|
||||
}
|
@ -9,20 +9,20 @@ import com.haulmont.cuba.security.global.LoginException;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Interface to be implemented by middleware connection objects supporting ActiveDirectory integration.
|
||||
* Interface to be implemented by middleware connection objects supporting external authentication.
|
||||
*
|
||||
* @author krokhin
|
||||
* @version $Id$
|
||||
*/
|
||||
public interface ActiveDirectoryConnection {
|
||||
public interface ExternallyAuthenticatedConnection {
|
||||
|
||||
String ACTIVE_DIRECTORY_USER_SESSION_ATTRIBUTE = "LOGGED_IN_WITH_ACTIVE_DIRECTORY";
|
||||
String EXTERNAL_AUTH_USER_SESSION_ATTRIBUTE = "LOGGED_IN_WITH_EXTERNAL_AUTHENTICATION";
|
||||
|
||||
/**
|
||||
* Log in to the system using ActiveDirectory integration.
|
||||
* Log in to the system after external authentication.
|
||||
* @param login user login name
|
||||
* @param locale user locale
|
||||
* @throws LoginException in case of unsuccessful login due to wrong credentials or other issues
|
||||
*/
|
||||
void loginActiveDirectory(String login, Locale locale) throws LoginException;
|
||||
void loginAfterExternalAuthentication(String login, Locale locale) throws LoginException;
|
||||
}
|
@ -30,22 +30,22 @@ public interface WebAuthConfig extends Config {
|
||||
String getActiveDirectoryAliases();
|
||||
|
||||
/**
|
||||
* @return Whether to use the ActiveDirectory authentication
|
||||
* @return Whether to use an external authentication
|
||||
*/
|
||||
@Property("cuba.web.useActiveDirectory")
|
||||
@Property("cuba.web.ExternalAuthentication")
|
||||
@DefaultBoolean(false)
|
||||
boolean getUseActiveDirectory();
|
||||
boolean getExternalAuthentication();
|
||||
|
||||
/**
|
||||
* @return ActiveDirectory authentification provider
|
||||
* @return external authentification provider
|
||||
*/
|
||||
@Property("cuba.web.activeDirectoryAuthClass")
|
||||
@Property("cuba.web.externalAuthenticationProviderClass")
|
||||
@DefaultString("com.haulmont.cuba.web.auth.LdapAuthProvider")
|
||||
String getActiveDirectoryAuthClass();
|
||||
String getExternalAuthenticationProviderClass();
|
||||
|
||||
/**
|
||||
* @return Password used by LoginService.loginTrusted() method.
|
||||
* Trusted client may login without providing a user password. This is used by ActiveDirectory integration.
|
||||
* Trusted client may login without providing a user password. This is used for external authentication.
|
||||
*
|
||||
* <p>Must be equal to password set for the same property on the CORE.</p>
|
||||
*/
|
||||
|
@ -15,7 +15,6 @@ import com.haulmont.cuba.gui.theme.ThemeConstants;
|
||||
import com.haulmont.cuba.gui.theme.ThemeConstantsRepository;
|
||||
import com.haulmont.cuba.security.app.UserSessionService;
|
||||
import com.haulmont.cuba.security.global.NoUserSessionException;
|
||||
import com.haulmont.cuba.web.auth.ActiveDirectoryHelper;
|
||||
import com.haulmont.cuba.web.auth.RequestContext;
|
||||
import com.haulmont.cuba.web.auth.WebAuthConfig;
|
||||
import com.haulmont.cuba.web.exception.ExceptionHandlers;
|
||||
@ -206,7 +205,7 @@ public abstract class App {
|
||||
MessageTools messageTools = AppBeans.get(MessageTools.NAME);
|
||||
locale = messageTools.getDefaultLocale();
|
||||
|
||||
if (ActiveDirectoryHelper.useActiveDirectory()) {
|
||||
if (webAuthConfig.getExternalAuthentication()) {
|
||||
principal = RequestContext.get().getRequest().getUserPrincipal();
|
||||
}
|
||||
}
|
||||
|
@ -12,8 +12,7 @@ import com.haulmont.cuba.gui.config.WindowConfig;
|
||||
import com.haulmont.cuba.gui.config.WindowInfo;
|
||||
import com.haulmont.cuba.security.entity.User;
|
||||
import com.haulmont.cuba.security.global.LoginException;
|
||||
import com.haulmont.cuba.web.auth.ActiveDirectoryConnection;
|
||||
import com.haulmont.cuba.web.auth.ActiveDirectoryHelper;
|
||||
import com.haulmont.cuba.web.auth.ExternallyAuthenticatedConnection;
|
||||
import com.vaadin.server.VaadinService;
|
||||
import com.vaadin.server.VaadinSession;
|
||||
import com.vaadin.server.WrappedSession;
|
||||
@ -25,7 +24,7 @@ import java.util.Map;
|
||||
|
||||
/**
|
||||
* Default {@link App} implementation that shows {@link LoginWindow} on start.
|
||||
* Supports SSO through integration with ActiveDirectory.
|
||||
* Supports SSO through external authentication.
|
||||
*
|
||||
* @author gorodnov
|
||||
* @version $Id$
|
||||
@ -117,7 +116,7 @@ public class DefaultApp extends App implements ConnectionListener, UserSubstitut
|
||||
* Perform actions after successful login
|
||||
*/
|
||||
protected void afterLoggedIn() {
|
||||
if (!webAuthConfig.getUseActiveDirectory()) {
|
||||
if (!webAuthConfig.getExternalAuthentication()) {
|
||||
UserSessionSource sessionSource = AppBeans.get(UserSessionSource.NAME);
|
||||
final User user = sessionSource.getUserSession().getUser();
|
||||
// Change password on logon
|
||||
@ -148,12 +147,12 @@ public class DefaultApp extends App implements ConnectionListener, UserSubstitut
|
||||
protected boolean loginOnStart() {
|
||||
if (tryLoginOnStart &&
|
||||
principal != null
|
||||
&& ActiveDirectoryHelper.useActiveDirectory()) {
|
||||
&& webAuthConfig.getExternalAuthentication()) {
|
||||
|
||||
String userName = principal.getName();
|
||||
log.debug("Trying to login ActiveDirectory as " + userName);
|
||||
log.debug("Trying to login after external authentication as " + userName);
|
||||
try {
|
||||
((ActiveDirectoryConnection) connection).loginActiveDirectory(userName, locale);
|
||||
((ExternallyAuthenticatedConnection) connection).loginAfterExternalAuthentication(userName, locale);
|
||||
|
||||
return true;
|
||||
} catch (LoginException e) {
|
||||
|
@ -11,8 +11,7 @@ import com.haulmont.cuba.core.global.ClientType;
|
||||
import com.haulmont.cuba.core.global.Configuration;
|
||||
import com.haulmont.cuba.security.global.LoginException;
|
||||
import com.haulmont.cuba.security.global.UserSession;
|
||||
import com.haulmont.cuba.web.auth.ActiveDirectoryConnection;
|
||||
import com.haulmont.cuba.web.auth.ActiveDirectoryHelper;
|
||||
import com.haulmont.cuba.web.auth.ExternallyAuthenticatedConnection;
|
||||
import com.haulmont.cuba.web.auth.WebAuthConfig;
|
||||
|
||||
import java.util.Locale;
|
||||
@ -24,7 +23,7 @@ import java.util.Map;
|
||||
* @author gorodnov
|
||||
* @version $Id$
|
||||
*/
|
||||
public class DefaultConnection extends AbstractConnection implements ActiveDirectoryConnection {
|
||||
public class DefaultConnection extends AbstractConnection implements ExternallyAuthenticatedConnection {
|
||||
|
||||
protected Configuration configuration = AppBeans.get(Configuration.NAME);
|
||||
|
||||
@ -77,7 +76,7 @@ public class DefaultConnection extends AbstractConnection implements ActiveDirec
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loginActiveDirectory(String login, Locale locale) throws LoginException {
|
||||
public void loginAfterExternalAuthentication(String login, Locale locale) throws LoginException {
|
||||
if (locale == null) {
|
||||
throw new IllegalArgumentException("Locale is null");
|
||||
}
|
||||
@ -89,7 +88,7 @@ public class DefaultConnection extends AbstractConnection implements ActiveDirec
|
||||
if (session == null) {
|
||||
throw new IllegalStateException("Null session after login");
|
||||
}
|
||||
session.setAttribute(ACTIVE_DIRECTORY_USER_SESSION_ATTRIBUTE, true);
|
||||
session.setAttribute(EXTERNAL_AUTH_USER_SESSION_ATTRIBUTE, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -114,7 +113,7 @@ public class DefaultConnection extends AbstractConnection implements ActiveDirec
|
||||
@Override
|
||||
public String logout() {
|
||||
super.logout();
|
||||
return ActiveDirectoryHelper.useActiveDirectory() ? "login" : "";
|
||||
return configuration.getConfig(WebAuthConfig.class).getExternalAuthentication() ? "login" : "";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -13,10 +13,10 @@ import com.haulmont.cuba.security.app.UserManagementService;
|
||||
import com.haulmont.cuba.security.entity.User;
|
||||
import com.haulmont.cuba.security.global.LoginException;
|
||||
import com.haulmont.cuba.security.global.UserSession;
|
||||
import com.haulmont.cuba.web.auth.ActiveDirectoryConnection;
|
||||
import com.haulmont.cuba.web.auth.ActiveDirectoryHelper;
|
||||
import com.haulmont.cuba.web.auth.ExternallyAuthenticatedConnection;
|
||||
import com.haulmont.cuba.web.auth.CubaAuthProvider;
|
||||
import com.haulmont.cuba.web.auth.DomainAliasesResolver;
|
||||
import com.haulmont.cuba.web.auth.WebAuthConfig;
|
||||
import com.haulmont.cuba.web.gui.components.WebComponentsHelper;
|
||||
import com.haulmont.cuba.web.toolkit.VersionedThemeResource;
|
||||
import com.haulmont.cuba.web.toolkit.ui.CubaButton;
|
||||
@ -79,12 +79,12 @@ public class LoginWindow extends UIView {
|
||||
|
||||
protected Messages messages = AppBeans.get(Messages.NAME);
|
||||
|
||||
protected Configuration configuration = AppBeans.get(Configuration.NAME);
|
||||
|
||||
public LoginWindow(AppUI ui) {
|
||||
log.trace("Creating " + this);
|
||||
this.ui = ui;
|
||||
|
||||
Configuration configuration = AppBeans.get(Configuration.NAME);
|
||||
|
||||
globalConfig = configuration.getConfig(GlobalConfig.class);
|
||||
webConfig = configuration.getConfig(WebConfig.class);
|
||||
locales = globalConfig.getAvailableLocales();
|
||||
@ -354,7 +354,7 @@ public class LoginWindow extends UIView {
|
||||
}
|
||||
localesSelect.setValue(selected);
|
||||
|
||||
if (ActiveDirectoryHelper.useActiveDirectory()) {
|
||||
if (configuration.getConfig(WebAuthConfig.class).getExternalAuthentication()) {
|
||||
loginField.setValue(app.getPrincipal() == null ? "" : app.getPrincipal().getName());
|
||||
passwordField.setValue("");
|
||||
} else {
|
||||
@ -408,13 +408,13 @@ public class LoginWindow extends UIView {
|
||||
|
||||
if (loginByRememberMe && rememberMeAllowed) {
|
||||
loginByRememberMe(login, password, locale);
|
||||
} else if (ActiveDirectoryHelper.useActiveDirectory()) {
|
||||
// try to login as AD user, fallback to regular authentication
|
||||
} else if (configuration.getConfig(WebAuthConfig.class).getExternalAuthentication()) {
|
||||
// try to login as externally authenticated user, fallback to regular authentication
|
||||
// we use resolved locale for error messages
|
||||
if (loginActiveDirectory(login, password, resolvedLocale)) {
|
||||
if (authenticateExternally(login, password, resolvedLocale)) {
|
||||
login = convertLoginString(login);
|
||||
|
||||
((ActiveDirectoryConnection) connection).loginActiveDirectory(login, locale);
|
||||
((ExternallyAuthenticatedConnection) connection).loginAfterExternalAuthentication(login, locale);
|
||||
} else {
|
||||
login(login, passwordEncryption.getPlainHash(password), locale);
|
||||
}
|
||||
@ -437,12 +437,12 @@ public class LoginWindow extends UIView {
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean loginActiveDirectory(String login, String passwordValue, Locale locale) {
|
||||
protected boolean authenticateExternally(String login, String passwordValue, Locale locale) {
|
||||
CubaAuthProvider authProvider = AppBeans.get(CubaAuthProvider.NAME);
|
||||
try {
|
||||
authProvider.authenticate(login, passwordValue, locale);
|
||||
} catch (Exception e) {
|
||||
log.debug("Login to AD failed", e);
|
||||
log.debug("External authentication failed", e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -26,7 +26,7 @@ import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import java.util.*;
|
||||
|
||||
import static com.haulmont.cuba.web.auth.ActiveDirectoryConnection.ACTIVE_DIRECTORY_USER_SESSION_ATTRIBUTE;
|
||||
import static com.haulmont.cuba.web.auth.ExternallyAuthenticatedConnection.EXTERNAL_AUTH_USER_SESSION_ATTRIBUTE;
|
||||
|
||||
/**
|
||||
* @author krivopustov
|
||||
@ -125,7 +125,7 @@ public class SettingsWindow extends AbstractWindow {
|
||||
}
|
||||
);
|
||||
if (!user.equals(userSession.getCurrentOrSubstitutedUser())
|
||||
|| Boolean.TRUE.equals(userSession.getAttribute(ACTIVE_DIRECTORY_USER_SESSION_ATTRIBUTE))) {
|
||||
|| Boolean.TRUE.equals(userSession.getAttribute(EXTERNAL_AUTH_USER_SESSION_ATTRIBUTE))) {
|
||||
changePasswordBtn.setEnabled(false);
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ public class UserEditorCompanion implements UserEditor.Companion {
|
||||
|
||||
@Override
|
||||
public void initPasswordField(PasswordField passwordField) {
|
||||
passwordField.setRequired(!config.getUseActiveDirectory());
|
||||
passwordField.setRequired(!config.getExternalAuthentication());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,9 +5,6 @@
|
||||
|
||||
@include=com.haulmont.cuba.gui
|
||||
|
||||
activeDirectory.invalidName=Invalid Active Directory user name: %s
|
||||
activeDirectory.unknownDomain=Active Directory configuration doesn't contain domain %s
|
||||
activeDirectory.authenticationError=Active Directory authentication failed: %s
|
||||
menu-config.sys$Category.browse=Dynamic Attributes
|
||||
menu-config.serverLog=Server Log
|
||||
menu-config.jsupload=JS Upload Test
|
||||
|
@ -4,20 +4,17 @@
|
||||
#
|
||||
@include = com.haulmont.cuba.gui
|
||||
|
||||
activeDirectory.unknownDomain = La configuration du répertoire actif ne contient pas le domaine %s
|
||||
menu-config.sys$Category.browse = Catégories
|
||||
sessionExpiredErrorCaption = Session expirée
|
||||
outOfSyncMessage = Quelque chose nous a désynchronisé avec le serveur.<br/>Faites attention à toute information non sauvegardée, puis <u>cliquez ici</u> pour resynchroniser.
|
||||
communicationErrorCaption = Problème de communication
|
||||
menu-config.sys$SendingMessage.browse = Historique email
|
||||
activeDirectory.invalidName = Nom d'utilisateur non valide dans le répertoire actif : %s
|
||||
sessionExpiredErrorMessage = Veillez à toute information non sauvegardée, puis <u>cliquez ici</u> pour continuer.
|
||||
internalErrorCaption = Erreur interne
|
||||
outOfSyncCaption = Désynchronisé avec le serveur
|
||||
uiBlockingMessage = Veuillez patienter
|
||||
communicationErrorMessage = Veillez à toutes les informations non sauvegardées, et <u>cliquez ici</u> pour continuer.
|
||||
internalErrorMessage = Veuillez avertir l'administrateur.<br/>Faites attention à toute information non sauvegardée, puis <u>cliquez ici</u> pour continuer.
|
||||
activeDirectory.authenticationError = L'authentification sur le répertoire actif a échoué : %s
|
||||
menu-config.serverLog = Journal du serveur
|
||||
menu-config.printDomain = Modèle de données
|
||||
lookupItemClickAction = Sélectionner
|
||||
|
@ -5,9 +5,6 @@
|
||||
|
||||
@include=com.haulmont.cuba.gui
|
||||
|
||||
activeDirectory.invalidName=Неверное имя пользователя Active Directory: %s
|
||||
activeDirectory.unknownDomain=Конфигурация Active Directory не содержит описания домена %s
|
||||
activeDirectory.authenticationError=Ошибка аутентификации в Active Directory : %s
|
||||
menu-config.sys$Category.browse=Динамические атрибуты
|
||||
menu-config.serverLog=Журнал сервера
|
||||
menu-config.printDomain=Модель данных
|
||||
|
@ -7,8 +7,8 @@ package com.haulmont.cuba.web.sys;
|
||||
import com.haulmont.cuba.core.global.AppBeans;
|
||||
import com.haulmont.cuba.core.global.Configuration;
|
||||
import com.haulmont.cuba.web.WebConfig;
|
||||
import com.haulmont.cuba.web.auth.ActiveDirectoryHelper;
|
||||
import com.haulmont.cuba.web.auth.CubaAuthProvider;
|
||||
import com.haulmont.cuba.web.auth.WebAuthConfig;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -32,7 +32,8 @@ public class CubaHttpFilter implements Filter {
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
if (ActiveDirectoryHelper.useActiveDirectory()) {
|
||||
Configuration configuration = AppBeans.get(Configuration.NAME);
|
||||
if (configuration.getConfig(WebAuthConfig.class).getExternalAuthentication()) {
|
||||
try {
|
||||
authProvider = AppBeans.get(CubaAuthProvider.NAME);
|
||||
authProvider.init(filterConfig);
|
||||
@ -40,7 +41,6 @@ public class CubaHttpFilter implements Filter {
|
||||
throw new ServletException(e);
|
||||
}
|
||||
// Fill bypassUrls
|
||||
Configuration configuration = AppBeans.get(Configuration.NAME);
|
||||
String urls = configuration.getConfig(WebConfig.class).getCubaHttpFilterBypassUrls();
|
||||
String[] strings = urls.split("[, ]");
|
||||
for (String string : strings) {
|
||||
|
@ -65,11 +65,9 @@ cuba.httpSessionExpirationTimeoutSec=1800
|
||||
cuba.trustedClientPassword=MLdWm1Ik4NmM
|
||||
cuba.passwordEncryptionModule=cuba_Sha1EncryptionModule
|
||||
|
||||
# ActiveDirectory integration settings
|
||||
cuba.web.useActiveDirectory=false
|
||||
|
||||
cuba.web.activeDirectoryAuthClass=com.haulmont.cuba.web.auth.LdapAuthProvider
|
||||
cuba.web.activeDirectoryAliases=
|
||||
# External authentication settings
|
||||
cuba.web.ExternalAuthentication=false
|
||||
cuba.web.externalAuthenticationProviderClass=com.haulmont.cuba.web.auth.LdapAuthProvider
|
||||
|
||||
# Default user accout to show in login dialog. Comment out for production mode.
|
||||
cuba.web.loginDialogDefaultUser=admin
|
||||
|
Loading…
Reference in New Issue
Block a user