From 84883fbc44f3778f6e053d2d19cde410946d263e Mon Sep 17 00:00:00 2001 From: Binal Patel Date: Mon, 26 Jan 2026 15:22:10 -0800 Subject: [PATCH 1/4] Update properties. Add Graph properties to context during server startup. --- gradle.properties | 4 ++ server/configs/application.properties | 8 ++- server/configs/pg.properties | 9 ++- .../src/org/labkey/embedded/LabKeyServer.java | 56 +++++++++++++++++++ .../LabKeyTomcatServletWebServerFactory.java | 42 ++++++++++++-- 5 files changed, 111 insertions(+), 8 deletions(-) diff --git a/gradle.properties b/gradle.properties index 06ab5786ec..68c5a74330 100644 --- a/gradle.properties +++ b/gradle.properties @@ -88,6 +88,10 @@ npmWorkDirectory=.node angusActivationVersion=2.0.3 angusMailVersion=2.0.5 +# Microsoft libraries for sending OAuth2-authenticated notification emails via the Microsoft Graph API +azureIdentityVersion=1.18.1 +microsoftGraphVersion=6.59.0 + annotationsVersion=15.0 antVersion=1.10.13 diff --git a/server/configs/application.properties b/server/configs/application.properties index a07a9873ad..365ce22ce9 100644 --- a/server/configs/application.properties +++ b/server/configs/application.properties @@ -72,7 +72,7 @@ context.encryptionKey=@@encryptionKey@@ #server.tomcat.max-part-header-size=512 #server.tomcat.max-connections=250 -## SMTP configuration +## SMTP configuration - if using this, comment out Microsoft Graph configuration mail.smtpHost=@@smtpHost@@ mail.smtpPort=@@smtpPort@@ mail.smtpUser=@@smtpUser@@ @@ -82,6 +82,12 @@ mail.smtpUser=@@smtpUser@@ #mail.smtpSocketFactoryClass=@@smtpSocketFactoryClass@@ #mail.smtpAuth=@@smtpAuth@@ +## Microsoft Graph configuration - if using this, comment out SMTP configuration +#mail.graph.tenantId=@@graphTenantId@@ +#mail.graph.fromAddress=@@graphFromAddress@@ +#mail.graph.clientId=@@graphClientId@@ +#mail.graph.clientSecret=@@graphClientSecret@@ + # Optional - JMS configuration for remote ActiveMQ message management for distributed pipeline jobs # https://www.labkey.org/Documentation/wiki-page.view?name=jmsQueue #context.resources.jms.ConnectionFactory.type=org.apache.activemq.ActiveMQConnectionFactory diff --git a/server/configs/pg.properties b/server/configs/pg.properties index a97050471e..330c93612d 100644 --- a/server/configs/pg.properties +++ b/server/configs/pg.properties @@ -5,7 +5,12 @@ smtpHost=localhost smtpUser=Anonymous smtpPort=25 -databaseDefault=labkey +#graphTenantId= +#graphFromAddress= +#graphClientId= +#graphClientSecret= + +databaseDefault=develop2 databaseBootstrap=labkey2 databaseDefaultHost=localhost databaseDefaultPort=5432 @@ -13,7 +18,7 @@ databaseDefaultPort=5432 jdbcDriverClassName=org.postgresql.Driver jdbcURL=jdbc:postgresql://${jdbcHost}:${jdbcPort}/${jdbcDatabase}${jdbcURLParameters} jdbcUser=postgres -jdbcPassword=sasa +jdbcPassword=labkey2024 # key for the encrypted property store and other potentially sensitive content encryptionKey=defaultKey diff --git a/server/embedded/src/org/labkey/embedded/LabKeyServer.java b/server/embedded/src/org/labkey/embedded/LabKeyServer.java index 7e74ccc801..5f6b3dab1a 100644 --- a/server/embedded/src/org/labkey/embedded/LabKeyServer.java +++ b/server/embedded/src/org/labkey/embedded/LabKeyServer.java @@ -158,6 +158,12 @@ public MailProperties smtpSource() return new MailProperties(); } + @Bean + public GraphMailProperties graphSource() + { + return new GraphMailProperties(); + } + @Bean public CSPFilterProperties cspSource() { @@ -850,6 +856,56 @@ public void setSmtpAuth(String smtpAuth) } } + @Configuration + @ConfigurationProperties("mail.graph") + public static class GraphMailProperties + { + private String tenantId; + private String clientId; + private String clientSecret; + private String fromAddress; + + public String getTenantId() + { + return tenantId; + } + + public void setTenantId(String tenantId) + { + this.tenantId = tenantId; + } + + public String getClientId() + { + return clientId; + } + + public void setClientId(String clientId) + { + this.clientId = clientId; + } + + public String getClientSecret() + { + return clientSecret; + } + + public void setClientSecret(String clientSecret) + { + this.clientSecret = clientSecret; + } + + public String getFromAddress() + { + return fromAddress; + } + + public void setFromAddress(String fromAddress) + { + this.fromAddress = fromAddress; + } + } + @Configuration @ConfigurationProperties("csp") public static class CSPFilterProperties diff --git a/server/embedded/src/org/labkey/embedded/LabKeyTomcatServletWebServerFactory.java b/server/embedded/src/org/labkey/embedded/LabKeyTomcatServletWebServerFactory.java index ba31b633ef..0c5f870704 100644 --- a/server/embedded/src/org/labkey/embedded/LabKeyTomcatServletWebServerFactory.java +++ b/server/embedded/src/org/labkey/embedded/LabKeyTomcatServletWebServerFactory.java @@ -155,8 +155,9 @@ protected TomcatWebServer getTomcatWebServer(Tomcat tomcat) // Add extra resources to context (e.g. LDAP, JMS) addExtraContextResources(contextProperties, context); - // Add the SMTP config + // Add the mail transport config (SMTP or Microsoft Graph) addSmtpProperties(context); + addGraphProperties(context); // Add the encryption key(s) context.addParameter("EncryptionKey", contextProperties.getEncryptionKey()); @@ -409,10 +410,18 @@ private void addSmtpProperties(StandardContext context) // Get session/mail properties LabKeyServer.MailProperties mailProps = _server.smtpSource(); - context.addParameter("mail.smtp.host", mailProps.getSmtpHost()); - context.addParameter("mail.smtp.user", mailProps.getSmtpUser()); - context.addParameter("mail.smtp.port", mailProps.getSmtpPort()); - + if (mailProps.getSmtpHost() != null) + { + context.addParameter("mail.smtp.host", mailProps.getSmtpHost()); + } + if (mailProps.getSmtpUser() != null) + { + context.addParameter("mail.smtp.user", mailProps.getSmtpUser()); + } + if (mailProps.getSmtpPort() != null) + { + context.addParameter("mail.smtp.port", mailProps.getSmtpPort()); + } if (mailProps.getSmtpFrom() != null) { context.addParameter("mail.smtp.from", mailProps.getSmtpFrom()); @@ -434,4 +443,27 @@ private void addSmtpProperties(StandardContext context) context.addParameter("mail.smtp.auth", mailProps.getSmtpAuth()); } } + + private void addGraphProperties(StandardContext context) + { + // Get Microsoft Graph mail properties + LabKeyServer.GraphMailProperties graphProps = _server.graphSource(); + + if (graphProps.getTenantId() != null) + { + context.addParameter("mail.graph.tenantId", graphProps.getTenantId()); + } + if (graphProps.getClientId() != null) + { + context.addParameter("mail.graph.clientId", graphProps.getClientId()); + } + if (graphProps.getClientSecret() != null) + { + context.addParameter("mail.graph.clientSecret", graphProps.getClientSecret()); + } + if (graphProps.getFromAddress() != null) + { + context.addParameter("mail.graph.fromAddress", graphProps.getFromAddress()); + } + } } From a46aa6e6e97c0c448bffff4587d6b0d9316b5f5a Mon Sep 17 00:00:00 2001 From: Binal Patel Date: Mon, 26 Jan 2026 15:24:57 -0800 Subject: [PATCH 2/4] Update properties --- server/configs/pg.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/configs/pg.properties b/server/configs/pg.properties index 330c93612d..6eb19e954b 100644 --- a/server/configs/pg.properties +++ b/server/configs/pg.properties @@ -10,7 +10,7 @@ smtpPort=25 #graphClientId= #graphClientSecret= -databaseDefault=develop2 +databaseDefault=labkey databaseBootstrap=labkey2 databaseDefaultHost=localhost databaseDefaultPort=5432 @@ -18,7 +18,7 @@ databaseDefaultPort=5432 jdbcDriverClassName=org.postgresql.Driver jdbcURL=jdbc:postgresql://${jdbcHost}:${jdbcPort}/${jdbcDatabase}${jdbcURLParameters} jdbcUser=postgres -jdbcPassword=labkey2024 +jdbcPassword=sasa # key for the encrypted property store and other potentially sensitive content -encryptionKey=defaultKey +encryptionKey=defaultKey \ No newline at end of file From ef5bcd63492fdd204b8a0413bd31b4e0c49fba81 Mon Sep 17 00:00:00 2001 From: Binal Patel Date: Tue, 27 Jan 2026 21:29:51 -0800 Subject: [PATCH 3/4] Remove unused dependencies. --- gradle.properties | 4 ---- 1 file changed, 4 deletions(-) diff --git a/gradle.properties b/gradle.properties index 68c5a74330..06ab5786ec 100644 --- a/gradle.properties +++ b/gradle.properties @@ -88,10 +88,6 @@ npmWorkDirectory=.node angusActivationVersion=2.0.3 angusMailVersion=2.0.5 -# Microsoft libraries for sending OAuth2-authenticated notification emails via the Microsoft Graph API -azureIdentityVersion=1.18.1 -microsoftGraphVersion=6.59.0 - annotationsVersion=15.0 antVersion=1.10.13 From 9623f4820259e4881794c623a8ffc534aea137cb Mon Sep 17 00:00:00 2001 From: Binal Patel Date: Mon, 2 Feb 2026 21:50:39 -0800 Subject: [PATCH 4/4] Dependencies and versions --- gradle.properties | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gradle.properties b/gradle.properties index 3e7b9e41d0..f7af6d9b07 100644 --- a/gradle.properties +++ b/gradle.properties @@ -88,6 +88,13 @@ npmWorkDirectory=.node angusActivationVersion=2.0.3 angusMailVersion=2.0.5 +# Microsoft libraries for sending OAuth2-authenticated notification emails via the Microsoft Graph API +azureIdentityVersion=1.18.1 +microsoftGraphVersion=6.59.0 + +# Mockito is used for unit testing the Microsoft Graph transport provider (GraphTransportProvider.TestCase) +mockitoVersion=5.14.2 + annotationsVersion=15.0 antVersion=1.10.13