--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.auth;
+
+public interface DevOpsPlatformSettings {
+
+ String getDevOpsPlatform();
+
+ boolean isProvisioningEnabled();
+
+ boolean isProjectVisibilitySynchronizationActivated();
+
+}
import org.sonar.api.config.Configuration;
import org.sonar.api.config.PropertyDefinition;
import org.sonar.api.server.ServerSide;
+import org.sonar.auth.DevOpsPlatformSettings;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
+import org.sonar.db.alm.setting.ALM;
import org.sonar.server.property.InternalProperties;
import static java.lang.String.format;
@ServerSide
@ComputeEngineSide
-public class GitHubSettings {
+public class GitHubSettings implements DevOpsPlatformSettings {
public static final String CLIENT_ID = "sonar.auth.github.clientId.secured";
public static final String CLIENT_SECRET = "sonar.auth.github.clientSecret.secured";
return format("%s to enable GitHub provisioning.", prefix);
}
+ @Override
+ public String getDevOpsPlatform() {
+ return ALM.GITHUB.getId();
+ }
+
+ @Override
public boolean isProvisioningEnabled() {
return isEnabled() && internalProperties.read(PROVISIONING).map(Boolean::parseBoolean).orElse(false);
}
return configuration.get(USER_CONSENT_FOR_PERMISSIONS_REQUIRED_AFTER_UPGRADE).isPresent();
}
+ @Override
public boolean isProjectVisibilitySynchronizationActivated() {
return configuration.getBoolean(PROVISION_VISIBILITY).orElse(true);
}
api 'com.github.scribejava:scribejava-core'
api 'com.google.code.gson:gson'
api project(':server:sonar-auth-common')
+ api project(':server:sonar-server-common')
compileOnlyApi 'com.google.code.findbugs:jsr305'
compileOnlyApi 'com.squareup.okhttp3:okhttp'
import org.sonar.api.ce.ComputeEngineSide;
import org.sonar.api.config.Configuration;
import org.sonar.api.config.PropertyDefinition;
+import org.sonar.auth.DevOpsPlatformSettings;
+import org.sonar.db.alm.setting.ALM;
import static java.lang.String.valueOf;
import static org.sonar.api.PropertyType.BOOLEAN;
import static org.sonar.api.PropertyType.PASSWORD;
@ComputeEngineSide
-public class GitLabSettings {
+public class GitLabSettings implements DevOpsPlatformSettings {
public static final String GITLAB_AUTH_ENABLED = "sonar.auth.gitlab.enabled";
public static final String GITLAB_AUTH_URL = "sonar.auth.gitlab.url";
return Set.of(configuration.getStringArray(GITLAB_AUTH_PROVISIONING_GROUPS));
}
+ @Override
+ public String getDevOpsPlatform() {
+ return ALM.GITLAB.getId();
+ }
+
+ @Override
public boolean isProvisioningEnabled() {
return isEnabled() && configuration.getBoolean(GITLAB_AUTH_PROVISIONING_ENABLED).orElse(false);
}
+ @Override
+ public boolean isProjectVisibilitySynchronizationActivated() {
+ return false;
+ }
+
static List<PropertyDefinition> definitions() {
return Arrays.asList(
PropertyDefinition.builder(GITLAB_AUTH_ENABLED)