mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 14:35:45 +01:00
add user converter to global configuration
This commit is contained in:
@@ -181,6 +181,14 @@ public class ScmConfiguration implements Configuration {
|
||||
@XmlElement(name = "xsrf-protection")
|
||||
private boolean enabledXsrfProtection = true;
|
||||
|
||||
/**
|
||||
* Enables user converter.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
@XmlElement(name = "user-converter")
|
||||
private boolean enabledUserConverter = false;
|
||||
|
||||
@XmlElement(name = "namespace-strategy")
|
||||
private String namespaceStrategy = "UsernameNamespaceStrategy";
|
||||
|
||||
@@ -227,6 +235,7 @@ public class ScmConfiguration implements Configuration {
|
||||
this.namespaceStrategy = other.namespaceStrategy;
|
||||
this.loginInfoUrl = other.loginInfoUrl;
|
||||
this.releaseFeedUrl = other.releaseFeedUrl;
|
||||
this.enabledUserConverter = other.enabledUserConverter;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -367,6 +376,17 @@ public class ScmConfiguration implements Configuration {
|
||||
return enabledXsrfProtection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the user converter is enabled.
|
||||
*
|
||||
* @return {@code true} if the user converter is enabled
|
||||
* The user converter automatically converts an internal user to external on their first login using an external system like ldap
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public boolean isEnabledUserConverter() {
|
||||
return enabledUserConverter;
|
||||
}
|
||||
|
||||
public boolean isEnableProxy() {
|
||||
return enableProxy;
|
||||
}
|
||||
@@ -524,6 +544,16 @@ public class ScmConfiguration implements Configuration {
|
||||
this.enabledXsrfProtection = enabledXsrfProtection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set {@code true} to enable user converter.
|
||||
*
|
||||
* @param enabledUserConverter {@code true} to enable user converter
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public void setEnabledUserConverter(boolean enabledUserConverter) {
|
||||
this.enabledUserConverter = enabledUserConverter;
|
||||
}
|
||||
|
||||
public void setNamespaceStrategy(String namespaceStrategy) {
|
||||
this.namespaceStrategy = namespaceStrategy;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ export type Config = {
|
||||
pluginUrl: string;
|
||||
loginAttemptLimitTimeout: number;
|
||||
enabledXsrfProtection: boolean;
|
||||
enabledUserConverter: boolean;
|
||||
namespaceStrategy: string;
|
||||
loginInfoUrl: string;
|
||||
releaseFeedUrl: string;
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
"plugin-url": "Plugin Center URL",
|
||||
"release-feed-url": "Release Feed URL",
|
||||
"enabled-xsrf-protection": "XSRF Protection aktivieren",
|
||||
"enabled-user-converter": "Benutzer Konverter aktivieren",
|
||||
"namespace-strategy": "Namespace Strategie",
|
||||
"login-info-url": "Login Info URL"
|
||||
},
|
||||
@@ -79,6 +80,7 @@
|
||||
"proxyUserHelpText": "Der Benutzername für die Proxy Server Anmeldung.",
|
||||
"proxyExcludesHelpText": "Glob patterns für Hostnamen, die von den Proxy-Einstellungen ausgeschlossen werden sollen.",
|
||||
"enableXsrfProtectionHelpText": "Xsrf Cookie Protection aktivieren. Hinweis: Dieses Feature befindet sich noch im Experimentalstatus.",
|
||||
"enabledUserConverterHelpText": "Benutzer Konverter aktivieren. Interne Benutzer werden beim Einloggen über ein Fremdsystem zu externen Benutzern konvertiert.",
|
||||
"nameSpaceStrategyHelpText": "Strategie für Namespaces.",
|
||||
"loginInfoUrlHelpText": "URL zu der Login Information (Plugin und Feature Tipps auf der Login Seite). Um die Login Information zu deaktivieren, kann das Feld leer gelassen werden."
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
"plugin-url": "Plugin Center URL",
|
||||
"release-feed-url": "Release Feed URL",
|
||||
"enabled-xsrf-protection": "Enabled XSRF Protection",
|
||||
"enabled-user-converter": "Enabled User Converter",
|
||||
"namespace-strategy": "Namespace Strategy",
|
||||
"login-info-url": "Login Info URL"
|
||||
},
|
||||
@@ -79,6 +80,7 @@
|
||||
"proxyUserHelpText": "The username for the proxy server authentication.",
|
||||
"proxyExcludesHelpText": "Glob patterns for hostnames, which should be excluded from proxy settings.",
|
||||
"enableXsrfProtectionHelpText": "Enable XSRF Cookie Protection. Note: This feature is still experimental.",
|
||||
"enabledUserConverterHelpText": "Enable User Converter. Internal users will automatically be converted to external on their first login using an external system.",
|
||||
"nameSpaceStrategyHelpText": "The namespace strategy.",
|
||||
"loginInfoUrlHelpText": "URL to login information (plugin and feature tips at login page). If this is omitted, no login information will be displayed."
|
||||
}
|
||||
|
||||
@@ -72,6 +72,7 @@ class ConfigForm extends React.Component<Props, State> {
|
||||
pluginUrl: "",
|
||||
loginAttemptLimitTimeout: 0,
|
||||
enabledXsrfProtection: true,
|
||||
enabledUserConverter: false,
|
||||
namespaceStrategy: "",
|
||||
loginInfoUrl: "",
|
||||
_links: {}
|
||||
@@ -145,6 +146,7 @@ class ConfigForm extends React.Component<Props, State> {
|
||||
pluginUrl={config.pluginUrl}
|
||||
releaseFeedUrl={config.releaseFeedUrl}
|
||||
enabledXsrfProtection={config.enabledXsrfProtection}
|
||||
enabledUserConverter={config.enabledUserConverter}
|
||||
namespaceStrategy={config.namespaceStrategy}
|
||||
onChange={(isValid, changedValue, name) => this.onChange(isValid, changedValue, name)}
|
||||
hasUpdatePermission={configUpdatePermission}
|
||||
|
||||
@@ -37,6 +37,7 @@ type Props = WithTranslation & {
|
||||
pluginUrl: string;
|
||||
releaseFeedUrl: string;
|
||||
enabledXsrfProtection: boolean;
|
||||
enabledUserConverter: boolean;
|
||||
namespaceStrategy: string;
|
||||
namespaceStrategies?: NamespaceStrategies;
|
||||
onChange: (p1: boolean, p2: any, p3: string) => void;
|
||||
@@ -52,6 +53,7 @@ class GeneralSettings extends React.Component<Props> {
|
||||
pluginUrl,
|
||||
releaseFeedUrl,
|
||||
enabledXsrfProtection,
|
||||
enabledUserConverter,
|
||||
anonymousMode,
|
||||
namespaceStrategy,
|
||||
hasUpdatePermission,
|
||||
@@ -129,7 +131,7 @@ class GeneralSettings extends React.Component<Props> {
|
||||
</div>
|
||||
</div>
|
||||
<div className="columns">
|
||||
<div className="column">
|
||||
<div className="column is-half">
|
||||
<InputField
|
||||
label={t("general-settings.release-feed-url")}
|
||||
onChange={this.handleReleaseFeedUrlChange}
|
||||
@@ -138,6 +140,16 @@ class GeneralSettings extends React.Component<Props> {
|
||||
helpText={t("help.releaseFeedUrlHelpText")}
|
||||
/>
|
||||
</div>
|
||||
<div className="column is-half">
|
||||
<Checkbox
|
||||
label={t("general-settings.enabled-user-converter")}
|
||||
onChange={this.handleEnabledUserConverterChange}
|
||||
checked={enabledUserConverter}
|
||||
title={t("general-settings.enabled-user-converter")}
|
||||
disabled={!hasUpdatePermission}
|
||||
helpText={t("help.enabledUserConverterHelpText")}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
@@ -152,6 +164,9 @@ class GeneralSettings extends React.Component<Props> {
|
||||
handleEnabledXsrfProtectionChange = (value: boolean) => {
|
||||
this.props.onChange(true, value, "enabledXsrfProtection");
|
||||
};
|
||||
handleEnabledUserConverterChange = (value: boolean) => {
|
||||
this.props.onChange(true, value, "enabledUserConverter");
|
||||
};
|
||||
handleAnonymousMode = (value: string) => {
|
||||
this.props.onChange(true, value, "anonymousMode");
|
||||
};
|
||||
|
||||
@@ -56,6 +56,7 @@ public class ConfigDto extends HalRepresentation {
|
||||
private String pluginUrl;
|
||||
private long loginAttemptLimitTimeout;
|
||||
private boolean enabledXsrfProtection;
|
||||
private boolean enabledUserConverter;
|
||||
private String namespaceStrategy;
|
||||
private String loginInfoUrl;
|
||||
private String releaseFeedUrl;
|
||||
|
||||
@@ -34,6 +34,7 @@ import sonia.scm.security.AnonymousMode;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.MockitoAnnotations.initMocks;
|
||||
|
||||
@@ -42,9 +43,7 @@ public class ConfigDtoToScmConfigurationMapperTest {
|
||||
@InjectMocks
|
||||
private ConfigDtoToScmConfigurationMapperImpl mapper;
|
||||
|
||||
private String[] expectedUsers = {"trillian", "arthur"};
|
||||
private String[] expectedGroups = {"admin", "plebs"};
|
||||
private String[] expectedExcludes = {"ex", "clude"};
|
||||
private final String[] expectedExcludes = {"ex", "clude"};
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
@@ -73,6 +72,7 @@ public class ConfigDtoToScmConfigurationMapperTest {
|
||||
assertEquals("https://plug.ins", config.getPluginUrl());
|
||||
assertEquals(40, config.getLoginAttemptLimitTimeout());
|
||||
assertTrue(config.isEnabledXsrfProtection());
|
||||
assertFalse(config.isEnabledUserConverter());
|
||||
assertEquals("username", config.getNamespaceStrategy());
|
||||
assertEquals("https://scm-manager.org/login-info", config.getLoginInfoUrl());
|
||||
}
|
||||
@@ -113,6 +113,7 @@ public class ConfigDtoToScmConfigurationMapperTest {
|
||||
configDto.setEnabledXsrfProtection(true);
|
||||
configDto.setNamespaceStrategy("username");
|
||||
configDto.setLoginInfoUrl("https://scm-manager.org/login-info");
|
||||
configDto.setEnabledUserConverter(false);
|
||||
|
||||
return configDto;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user