mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 06:25: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")
|
@XmlElement(name = "xsrf-protection")
|
||||||
private boolean enabledXsrfProtection = true;
|
private boolean enabledXsrfProtection = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables user converter.
|
||||||
|
*
|
||||||
|
* @since 2.8.0
|
||||||
|
*/
|
||||||
|
@XmlElement(name = "user-converter")
|
||||||
|
private boolean enabledUserConverter = false;
|
||||||
|
|
||||||
@XmlElement(name = "namespace-strategy")
|
@XmlElement(name = "namespace-strategy")
|
||||||
private String namespaceStrategy = "UsernameNamespaceStrategy";
|
private String namespaceStrategy = "UsernameNamespaceStrategy";
|
||||||
|
|
||||||
@@ -227,6 +235,7 @@ public class ScmConfiguration implements Configuration {
|
|||||||
this.namespaceStrategy = other.namespaceStrategy;
|
this.namespaceStrategy = other.namespaceStrategy;
|
||||||
this.loginInfoUrl = other.loginInfoUrl;
|
this.loginInfoUrl = other.loginInfoUrl;
|
||||||
this.releaseFeedUrl = other.releaseFeedUrl;
|
this.releaseFeedUrl = other.releaseFeedUrl;
|
||||||
|
this.enabledUserConverter = other.enabledUserConverter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -367,6 +376,17 @@ public class ScmConfiguration implements Configuration {
|
|||||||
return enabledXsrfProtection;
|
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() {
|
public boolean isEnableProxy() {
|
||||||
return enableProxy;
|
return enableProxy;
|
||||||
}
|
}
|
||||||
@@ -524,6 +544,16 @@ public class ScmConfiguration implements Configuration {
|
|||||||
this.enabledXsrfProtection = enabledXsrfProtection;
|
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) {
|
public void setNamespaceStrategy(String namespaceStrategy) {
|
||||||
this.namespaceStrategy = namespaceStrategy;
|
this.namespaceStrategy = namespaceStrategy;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ export type Config = {
|
|||||||
pluginUrl: string;
|
pluginUrl: string;
|
||||||
loginAttemptLimitTimeout: number;
|
loginAttemptLimitTimeout: number;
|
||||||
enabledXsrfProtection: boolean;
|
enabledXsrfProtection: boolean;
|
||||||
|
enabledUserConverter: boolean;
|
||||||
namespaceStrategy: string;
|
namespaceStrategy: string;
|
||||||
loginInfoUrl: string;
|
loginInfoUrl: string;
|
||||||
releaseFeedUrl: string;
|
releaseFeedUrl: string;
|
||||||
|
|||||||
@@ -48,6 +48,7 @@
|
|||||||
"plugin-url": "Plugin Center URL",
|
"plugin-url": "Plugin Center URL",
|
||||||
"release-feed-url": "Release Feed URL",
|
"release-feed-url": "Release Feed URL",
|
||||||
"enabled-xsrf-protection": "XSRF Protection aktivieren",
|
"enabled-xsrf-protection": "XSRF Protection aktivieren",
|
||||||
|
"enabled-user-converter": "Benutzer Konverter aktivieren",
|
||||||
"namespace-strategy": "Namespace Strategie",
|
"namespace-strategy": "Namespace Strategie",
|
||||||
"login-info-url": "Login Info URL"
|
"login-info-url": "Login Info URL"
|
||||||
},
|
},
|
||||||
@@ -79,6 +80,7 @@
|
|||||||
"proxyUserHelpText": "Der Benutzername für die Proxy Server Anmeldung.",
|
"proxyUserHelpText": "Der Benutzername für die Proxy Server Anmeldung.",
|
||||||
"proxyExcludesHelpText": "Glob patterns für Hostnamen, die von den Proxy-Einstellungen ausgeschlossen werden sollen.",
|
"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.",
|
"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.",
|
"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."
|
"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",
|
"plugin-url": "Plugin Center URL",
|
||||||
"release-feed-url": "Release Feed URL",
|
"release-feed-url": "Release Feed URL",
|
||||||
"enabled-xsrf-protection": "Enabled XSRF Protection",
|
"enabled-xsrf-protection": "Enabled XSRF Protection",
|
||||||
|
"enabled-user-converter": "Enabled User Converter",
|
||||||
"namespace-strategy": "Namespace Strategy",
|
"namespace-strategy": "Namespace Strategy",
|
||||||
"login-info-url": "Login Info URL"
|
"login-info-url": "Login Info URL"
|
||||||
},
|
},
|
||||||
@@ -79,6 +80,7 @@
|
|||||||
"proxyUserHelpText": "The username for the proxy server authentication.",
|
"proxyUserHelpText": "The username for the proxy server authentication.",
|
||||||
"proxyExcludesHelpText": "Glob patterns for hostnames, which should be excluded from proxy settings.",
|
"proxyExcludesHelpText": "Glob patterns for hostnames, which should be excluded from proxy settings.",
|
||||||
"enableXsrfProtectionHelpText": "Enable XSRF Cookie Protection. Note: This feature is still experimental.",
|
"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.",
|
"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."
|
"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: "",
|
pluginUrl: "",
|
||||||
loginAttemptLimitTimeout: 0,
|
loginAttemptLimitTimeout: 0,
|
||||||
enabledXsrfProtection: true,
|
enabledXsrfProtection: true,
|
||||||
|
enabledUserConverter: false,
|
||||||
namespaceStrategy: "",
|
namespaceStrategy: "",
|
||||||
loginInfoUrl: "",
|
loginInfoUrl: "",
|
||||||
_links: {}
|
_links: {}
|
||||||
@@ -145,6 +146,7 @@ class ConfigForm extends React.Component<Props, State> {
|
|||||||
pluginUrl={config.pluginUrl}
|
pluginUrl={config.pluginUrl}
|
||||||
releaseFeedUrl={config.releaseFeedUrl}
|
releaseFeedUrl={config.releaseFeedUrl}
|
||||||
enabledXsrfProtection={config.enabledXsrfProtection}
|
enabledXsrfProtection={config.enabledXsrfProtection}
|
||||||
|
enabledUserConverter={config.enabledUserConverter}
|
||||||
namespaceStrategy={config.namespaceStrategy}
|
namespaceStrategy={config.namespaceStrategy}
|
||||||
onChange={(isValid, changedValue, name) => this.onChange(isValid, changedValue, name)}
|
onChange={(isValid, changedValue, name) => this.onChange(isValid, changedValue, name)}
|
||||||
hasUpdatePermission={configUpdatePermission}
|
hasUpdatePermission={configUpdatePermission}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ type Props = WithTranslation & {
|
|||||||
pluginUrl: string;
|
pluginUrl: string;
|
||||||
releaseFeedUrl: string;
|
releaseFeedUrl: string;
|
||||||
enabledXsrfProtection: boolean;
|
enabledXsrfProtection: boolean;
|
||||||
|
enabledUserConverter: boolean;
|
||||||
namespaceStrategy: string;
|
namespaceStrategy: string;
|
||||||
namespaceStrategies?: NamespaceStrategies;
|
namespaceStrategies?: NamespaceStrategies;
|
||||||
onChange: (p1: boolean, p2: any, p3: string) => void;
|
onChange: (p1: boolean, p2: any, p3: string) => void;
|
||||||
@@ -52,6 +53,7 @@ class GeneralSettings extends React.Component<Props> {
|
|||||||
pluginUrl,
|
pluginUrl,
|
||||||
releaseFeedUrl,
|
releaseFeedUrl,
|
||||||
enabledXsrfProtection,
|
enabledXsrfProtection,
|
||||||
|
enabledUserConverter,
|
||||||
anonymousMode,
|
anonymousMode,
|
||||||
namespaceStrategy,
|
namespaceStrategy,
|
||||||
hasUpdatePermission,
|
hasUpdatePermission,
|
||||||
@@ -129,7 +131,7 @@ class GeneralSettings extends React.Component<Props> {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="columns">
|
<div className="columns">
|
||||||
<div className="column">
|
<div className="column is-half">
|
||||||
<InputField
|
<InputField
|
||||||
label={t("general-settings.release-feed-url")}
|
label={t("general-settings.release-feed-url")}
|
||||||
onChange={this.handleReleaseFeedUrlChange}
|
onChange={this.handleReleaseFeedUrlChange}
|
||||||
@@ -138,6 +140,16 @@ class GeneralSettings extends React.Component<Props> {
|
|||||||
helpText={t("help.releaseFeedUrlHelpText")}
|
helpText={t("help.releaseFeedUrlHelpText")}
|
||||||
/>
|
/>
|
||||||
</div>
|
</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>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -152,6 +164,9 @@ class GeneralSettings extends React.Component<Props> {
|
|||||||
handleEnabledXsrfProtectionChange = (value: boolean) => {
|
handleEnabledXsrfProtectionChange = (value: boolean) => {
|
||||||
this.props.onChange(true, value, "enabledXsrfProtection");
|
this.props.onChange(true, value, "enabledXsrfProtection");
|
||||||
};
|
};
|
||||||
|
handleEnabledUserConverterChange = (value: boolean) => {
|
||||||
|
this.props.onChange(true, value, "enabledUserConverter");
|
||||||
|
};
|
||||||
handleAnonymousMode = (value: string) => {
|
handleAnonymousMode = (value: string) => {
|
||||||
this.props.onChange(true, value, "anonymousMode");
|
this.props.onChange(true, value, "anonymousMode");
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ public class ConfigDto extends HalRepresentation {
|
|||||||
private String pluginUrl;
|
private String pluginUrl;
|
||||||
private long loginAttemptLimitTimeout;
|
private long loginAttemptLimitTimeout;
|
||||||
private boolean enabledXsrfProtection;
|
private boolean enabledXsrfProtection;
|
||||||
|
private boolean enabledUserConverter;
|
||||||
private String namespaceStrategy;
|
private String namespaceStrategy;
|
||||||
private String loginInfoUrl;
|
private String loginInfoUrl;
|
||||||
private String releaseFeedUrl;
|
private String releaseFeedUrl;
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import sonia.scm.security.AnonymousMode;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.MockitoAnnotations.initMocks;
|
import static org.mockito.MockitoAnnotations.initMocks;
|
||||||
|
|
||||||
@@ -42,9 +43,7 @@ public class ConfigDtoToScmConfigurationMapperTest {
|
|||||||
@InjectMocks
|
@InjectMocks
|
||||||
private ConfigDtoToScmConfigurationMapperImpl mapper;
|
private ConfigDtoToScmConfigurationMapperImpl mapper;
|
||||||
|
|
||||||
private String[] expectedUsers = {"trillian", "arthur"};
|
private final String[] expectedExcludes = {"ex", "clude"};
|
||||||
private String[] expectedGroups = {"admin", "plebs"};
|
|
||||||
private String[] expectedExcludes = {"ex", "clude"};
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void init() {
|
public void init() {
|
||||||
@@ -73,6 +72,7 @@ public class ConfigDtoToScmConfigurationMapperTest {
|
|||||||
assertEquals("https://plug.ins", config.getPluginUrl());
|
assertEquals("https://plug.ins", config.getPluginUrl());
|
||||||
assertEquals(40, config.getLoginAttemptLimitTimeout());
|
assertEquals(40, config.getLoginAttemptLimitTimeout());
|
||||||
assertTrue(config.isEnabledXsrfProtection());
|
assertTrue(config.isEnabledXsrfProtection());
|
||||||
|
assertFalse(config.isEnabledUserConverter());
|
||||||
assertEquals("username", config.getNamespaceStrategy());
|
assertEquals("username", config.getNamespaceStrategy());
|
||||||
assertEquals("https://scm-manager.org/login-info", config.getLoginInfoUrl());
|
assertEquals("https://scm-manager.org/login-info", config.getLoginInfoUrl());
|
||||||
}
|
}
|
||||||
@@ -113,6 +113,7 @@ public class ConfigDtoToScmConfigurationMapperTest {
|
|||||||
configDto.setEnabledXsrfProtection(true);
|
configDto.setEnabledXsrfProtection(true);
|
||||||
configDto.setNamespaceStrategy("username");
|
configDto.setNamespaceStrategy("username");
|
||||||
configDto.setLoginInfoUrl("https://scm-manager.org/login-info");
|
configDto.setLoginInfoUrl("https://scm-manager.org/login-info");
|
||||||
|
configDto.setEnabledUserConverter(false);
|
||||||
|
|
||||||
return configDto;
|
return configDto;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user