diff options
author | Antoine Vigneau <antoine.vigneau@sonarsource.com> | 2024-08-06 13:45:14 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2024-08-16 20:02:58 +0000 |
commit | 461a47d22b55a5450062883a6c1bd22e0a4ec3dd (patch) | |
tree | 7107a6598c46d4f3899f9659a14232f4d4b552b8 /server/sonar-server-common | |
parent | 808cba5b51d54a61ef2a01e6e78e3874ef53eea5 (diff) | |
download | sonarqube-461a47d22b55a5450062883a6c1bd22e0a4ec3dd.tar.gz sonarqube-461a47d22b55a5450062883a6c1bd22e0a4ec3dd.zip |
SONAR-22516 API v2 endpoints for managing the email configuration
Diffstat (limited to 'server/sonar-server-common')
2 files changed, 35 insertions, 5 deletions
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/email/EmailSmtpConfiguration.java b/server/sonar-server-common/src/main/java/org/sonar/server/email/EmailSmtpConfiguration.java index b7873fab943..f8ab524b7e2 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/email/EmailSmtpConfiguration.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/email/EmailSmtpConfiguration.java @@ -34,8 +34,6 @@ public class EmailSmtpConfiguration { public static final String EMAIL_CONFIG_SMTP_PORT_DEFAULT = "25"; public static final String EMAIL_CONFIG_SMTP_SECURE_CONNECTION = "email.smtp_secure_connection.secured"; public static final String EMAIL_CONFIG_SMTP_SECURE_CONNECTION_DEFAULT = ""; - public static final String EMAIL_CONFIG_SMTP_AUTH_METHOD= "email.smtp.auth.method"; - public static final String EMAIL_CONFIG_SMTP_AUTH_METHOD_DEFAULT = "BASIC"; // Email content public static final String EMAIL_CONFIG_FROM = "email.from"; public static final String EMAIL_CONFIG_FROM_DEFAULT = "noreply@nowhere"; @@ -43,19 +41,24 @@ public class EmailSmtpConfiguration { public static final String EMAIL_CONFIG_FROM_NAME_DEFAULT = "SonarQube"; public static final String EMAIL_CONFIG_PREFIX = "email.prefix"; public static final String EMAIL_CONFIG_PREFIX_DEFAULT = "[SONARQUBE]"; + // Auth selection + public static final String EMAIL_CONFIG_SMTP_AUTH_METHOD= "email.smtp.auth.method"; + public static final String EMAIL_CONFIG_SMTP_AUTH_METHOD_DEFAULT = "BASIC"; // Basic Auth public static final String EMAIL_CONFIG_SMTP_USERNAME = "email.smtp_username.secured"; public static final String EMAIL_CONFIG_SMTP_USERNAME_DEFAULT = ""; public static final String EMAIL_CONFIG_SMTP_PASSWORD = "email.smtp_password.secured"; public static final String EMAIL_CONFIG_SMTP_PASSWORD_DEFAULT = ""; - // Modern auth + // OAuth public static final String EMAIL_CONFIG_SMTP_OAUTH_HOST = "email.smtp.oauth.host"; public static final String EMAIL_CONFIG_SMTP_OAUTH_HOST_DEFAULT = "https://login.microsoftonline.com"; - public static final String EMAIL_CONFIG_SMTP_OAUTH_TENANT = "email.smtp.oauth.tenant"; public static final String EMAIL_CONFIG_SMTP_OAUTH_CLIENTID = "email.smtp.oauth.clientId"; public static final String EMAIL_CONFIG_SMTP_OAUTH_CLIENTSECRET = "email.smtp.oauth.clientSecret"; + public static final String EMAIL_CONFIG_SMTP_OAUTH_TENANT = "email.smtp.oauth.tenant"; public static final String EMAIL_CONFIG_SMTP_OAUTH_SCOPE = "email.smtp.oauth.scope"; - public static final String EMAIL_CONFIG_SMTP_OAUTH_SCOPE_DEFAULT = "client_credentials"; + public static final String EMAIL_CONFIG_SMTP_OAUTH_SCOPE_DEFAULT = "https://outlook.office365.com/.default"; + public static final String EMAIL_CONFIG_SMTP_OAUTH_GRANT = "email.smtp.oauth.grant"; + public static final String EMAIL_CONFIG_SMTP_OAUTH_GRANT_DEFAULT = "client_credentials"; private final DbClient dbClient; @@ -119,6 +122,10 @@ public class EmailSmtpConfiguration { return get(EMAIL_CONFIG_SMTP_OAUTH_SCOPE, EMAIL_CONFIG_SMTP_OAUTH_SCOPE_DEFAULT); } + public String getOAuthGrant() { + return get(EMAIL_CONFIG_SMTP_OAUTH_GRANT, EMAIL_CONFIG_SMTP_OAUTH_GRANT_DEFAULT); + } + private String get(String key, String defaultValue) { try (DbSession dbSession = dbClient.openSession(false)) { return dbClient.internalPropertiesDao().selectByKey(dbSession, key).orElse(defaultValue); diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/notification/email/telemetry/package-info.java b/server/sonar-server-common/src/main/java/org/sonar/server/notification/email/telemetry/package-info.java new file mode 100644 index 00000000000..0722ecbfca8 --- /dev/null +++ b/server/sonar-server-common/src/main/java/org/sonar/server/notification/email/telemetry/package-info.java @@ -0,0 +1,23 @@ +/* + * SonarQube + * Copyright (C) 2009-2024 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. + */ +@ParametersAreNonnullByDefault +package org.sonar.server.notification.email.telemetry; + +import javax.annotation.ParametersAreNonnullByDefault; |