Skip to content

Commit 7bf4a87

Browse files
authored
Merge pull request DSpace#11656 from JohnnyMendesC/fix/10823-remove-insecure-jndi
Update LDAPAuthentication to Spring LDAP in order to remove insecure JNDI usage
2 parents 7d41584 + 8401ff2 commit 7bf4a87

7 files changed

Lines changed: 122 additions & 231 deletions

File tree

LICENSES_THIRD_PARTY

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ https://wiki.lyrasis.org/display/DSPACE/Code+Contribution+Guidelines
445445
* Spring Expression Language (SpEL) (org.springframework:spring-expression:6.2.7 - https://github.com/spring-projects/spring-framework)
446446
* Spring Commons Logging Bridge (org.springframework:spring-jcl:6.2.7 - https://github.com/spring-projects/spring-framework)
447447
* Spring JDBC (org.springframework:spring-jdbc:6.2.7 - https://github.com/spring-projects/spring-framework)
448+
* Spring LDAP Core (org.springframework.ldap:spring-ldap-core:3.2.15 - https://github.com/spring-projects/spring-ldap)
448449
* Spring Object/Relational Mapping (org.springframework:spring-orm:6.2.7 - https://github.com/spring-projects/spring-framework)
449450
* Spring TestContext Framework (org.springframework:spring-test:6.2.7 - https://github.com/spring-projects/spring-framework)
450451
* Spring Transaction (org.springframework:spring-tx:6.2.7 - https://github.com/spring-projects/spring-framework)

dspace-api/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,10 @@
379379
<version>${hibernate-validator.version}</version>
380380
</dependency>
381381

382+
<dependency>
383+
<groupId>org.springframework.ldap</groupId>
384+
<artifactId>spring-ldap-core</artifactId>
385+
</dependency>
382386
<dependency>
383387
<groupId>org.springframework</groupId>
384388
<artifactId>spring-orm</artifactId>

dspace-api/src/main/java/org/dspace/authenticate/LDAPAuthentication.java

Lines changed: 93 additions & 230 deletions
Large diffs are not rendered by default.

dspace-server-webapp/src/main/java/org/dspace/app/rest/utils/DSpaceKernelInitializer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public void initialize(final ConfigurableApplicationContext applicationContext)
8181
* Initially look for JNDI Resource called "java:/comp/env/dspace.dir".
8282
* If not found, use value provided in "dspace.dir" in Spring Environment
8383
*/
84+
// JNDI usage is safe here as it loads internal DSpace configuration, not user input.
8485
@SuppressWarnings("BanJNDI")
8586
private String getDSpaceHome(ConfigurableEnvironment environment) {
8687
// Load the "dspace.dir" property from Spring Boot's Configuration (application.properties)

dspace-server-webapp/src/test/resources/application-test.properties

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,8 @@
1616
## This file is found on classpath at src/test/resources/log4j2-test.xml
1717
logging.config = classpath:log4j2-test.xml
1818

19+
# Disable LDAP Health Check during tests to avoid external LDAP requirement
20+
management.health.ldap.enabled=false
21+
1922
# Our integration tests expect application to be deployed at the root path (/)
20-
server.servlet.context-path=/
23+
server.servlet.context-path=/

dspace-services/src/main/java/org/dspace/services/email/EmailServiceImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public Session getSession() {
6262
}
6363

6464
@PostConstruct
65+
// JNDI usage is safe here as it looks up a configured mail session resource, not user input.
6566
@SuppressWarnings("BanJNDI")
6667
public void init() {
6768
// See if there is already a Session in our environment

pom.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<!--=== GENERAL / DSPACE-API DEPENDENCIES ===-->
2121
<java.version>21</java.version>
2222
<spring.version>6.2.15</spring.version>
23+
<spring-ldap.version>3.3.5</spring-ldap.version>
2324
<spring-boot.version>3.5.10</spring-boot.version>
2425
<spring-security.version>6.5.7</spring-security.version> <!-- sync with version used by spring-boot-->
2526
<hibernate.version>6.4.10.Final</hibernate.version>
@@ -1223,6 +1224,23 @@
12231224
<version>${spring.version}</version>
12241225
</dependency>
12251226

1227+
<dependency>
1228+
<groupId>org.springframework.ldap</groupId>
1229+
<artifactId>spring-ldap-core</artifactId>
1230+
<version>${spring-ldap.version}</version>
1231+
</dependency>
1232+
<!-- Specify the version of micrometer to use. Solves dependency convergence issues in spring-ldap-core -->
1233+
<dependency>
1234+
<groupId>io.micrometer</groupId>
1235+
<artifactId>micrometer-core</artifactId>
1236+
<version>1.14.14</version>
1237+
</dependency>
1238+
<dependency>
1239+
<groupId>io.micrometer</groupId>
1240+
<artifactId>micrometer-observation</artifactId>
1241+
<version>1.14.14</version>
1242+
</dependency>
1243+
12261244
<dependency>
12271245
<artifactId>spring-tx</artifactId>
12281246
<groupId>org.springframework</groupId>

0 commit comments

Comments
 (0)