Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.

Commit e8df57e

Browse files
authored
[SECOPS-14788] (#190)
* Fix build.gradle * Upgrade * remove unused and deprecaded war * Fixes * Latest fixes :corssed_fingers: * Latest versions (dependabot) * Revert not needed changes * Use SQLDialiect form hibernate * Spring new version manages servlet * Update WebSecurityConfig.java * Update README.md
1 parent 2b3e74a commit e8df57e

23 files changed

+87
-252
lines changed

.github/workflows/gradle.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ jobs:
2020

2121
steps:
2222
- uses: actions/checkout@v2
23-
- name: Set up JDK 11
23+
- name: Set up JDK 17
2424
uses: actions/setup-java@v1
2525
with:
26-
java-version: 11.0
26+
java-version: 17.0
2727
- name: Grant execute permission for gradlew
2828
run: chmod +x gradlew
2929
- name: Build with Gradle

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ install:
44
./gradlew build
55

66
serve:
7-
./gradlew appRun
7+
./gradlew bootRun

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Implementations in other languages:
4141

4242
### Requirements
4343

44-
- [Java Development Kit](https://adoptopenjdk.net/) version 11 or later.
44+
- [Java Development Kit](https://adoptopenjdk.net/) version 17 or later.
4545
- A Twilio account - [sign up](https://www.twilio.com/try-twilio)
4646

4747
### Twilio Account Settings

build.gradle

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,53 @@
11
plugins {
22
id 'java'
3-
id 'org.gretty' version '3.0.4'
3+
id 'io.spring.dependency-management' version '1.1.7'
4+
id 'org.springframework.boot' version '3.3.11'
45
id 'idea'
5-
id 'war'
66
id 'groovy'
7-
id 'com.github.joselion.pretty-jupiter' version '1.3.4'
7+
id 'io.github.joselion.pretty-jupiter' version '3.5.0'
88
}
99

10-
sourceCompatibility = 1.8
11-
targetCompatibility = 1.8
12-
ext['springBootVer'] = '2.2.6.RELEASE'
13-
14-
15-
repositories {
16-
jcenter()
10+
java {
11+
toolchain {
12+
languageVersion = JavaLanguageVersion.of(17)
13+
}
14+
sourceCompatibility = JavaVersion.VERSION_17
15+
targetCompatibility = JavaVersion.VERSION_17
1716
}
1817

19-
gretty {
20-
springBootVersion = '2.2.6.RELEASE'
21-
springBoot = true
22-
servletContainer = 'jetty9.4'
23-
contextPath = ''
18+
repositories {
19+
mavenCentral()
2420
}
2521

2622
configurations {
2723
providedRuntime
2824
}
2925

3026
dependencies {
31-
implementation(group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1')
32-
implementation(group: 'javax.el', name:'javax.el-api', version:'3.0.0')
27+
implementation(group: 'jakarta.xml.bind', name: 'jakarta.xml.bind-api', version: '4.0.2')
28+
providedRuntime(group: 'jakarta.servlet', name:'jakarta.servlet-api', version:'6.1.0')
3329

3430
// Spring
35-
implementation(group:'org.springframework.boot', name:'spring-boot-starter-data-jpa', version:"${springBootVer}")
36-
implementation(group:'org.springframework.boot', name:'spring-boot-starter-security', version:"${springBootVer}")
31+
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
32+
implementation 'org.springframework.boot:spring-boot-starter-security'
33+
implementation 'org.springframework.boot:spring-boot-starter-validation'
34+
implementation 'org.springframework.boot:spring-boot-starter-web'
35+
3736
implementation(group:'net.rakugakibox.spring.boot', name:'logback-access-spring-boot-starter', version:'2.11.0')
3837

38+
implementation group: 'org.hibernate.orm', name: 'hibernate-community-dialects', version: '6.6.13.Final'
39+
3940
implementation(group:'com.authy', name:'authy-java', version:'1.5.1')
40-
implementation(group:'com.twilio.sdk', name:'twilio', version:'8.31.1')
41-
implementation(group:'org.xerial', name:'sqlite-jdbc', version:'3.41.2.2')
41+
implementation(group:'com.twilio.sdk', name:'twilio', version:'10.8.0')
42+
implementation(group:'org.xerial', name:'sqlite-jdbc', version:'3.49.1.0')
43+
implementation 'org.springframework.boot:spring-boot-starter-actuator'
4244

4345
testImplementation(group: 'junit', name:'junit', version:'4.13.2')
44-
testImplementation(group:'org.springframework.boot', name:'spring-boot-starter-test', version:"${springBootVer}")
46+
testImplementation 'org.springframework.boot:spring-boot-starter-test'
47+
testImplementation 'org.springframework.security:spring-security-test'
48+
4549
// Groovy
46-
testImplementation (group: 'org.apache.groovy', name: 'groovy-all', version: '4.0.15', ext: 'pom')
50+
testImplementation (group: 'org.apache.groovy', name: 'groovy-all', version: '4.0.26', ext: 'pom')
4751

4852
// Constraints
4953
constraints {
@@ -53,18 +57,19 @@ dependencies {
5357
}
5458

5559
// Spock
56-
testImplementation(group:'org.spockframework', name:'spock-core', version:'2.0-M4-groovy-3.0')
57-
testImplementation(group:'org.spockframework', name:'spock-spring', version:'2.0-M4-groovy-3.0')
60+
testImplementation(group:'org.spockframework', name:'spock-core', version:'2.4-M6-groovy-4.0')
61+
testImplementation(group:'org.spockframework', name:'spock-spring', version:'2.4-M6-groovy-4.0')
5862
testRuntimeOnly(group:'cglib', name:'cglib-nodep', version:'3.3.0')
63+
testRuntimeOnly('org.junit.platform:junit-platform-launcher')
5964
}
6065

6166
test {
6267
useJUnitPlatform()
6368
reports {
64-
junitXml.enabled = false
65-
html.enabled = false
69+
junitXml.required = false
70+
html.required = false
6671
}
6772
testLogging {
6873
exceptionFormat = "full"
6974
}
70-
}
75+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Thu Dec 17 10:00:49 ECT 2015
1+
#Tue May 06 10:00:42 ECT 2025
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
45
zipStoreBase=GRADLE_USER_HOME
56
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-bin.zip

src/main/java/com/twilio/accountsecurity/config/SQLiteDialect.java

Lines changed: 0 additions & 161 deletions
This file was deleted.

src/main/java/com/twilio/accountsecurity/config/WebSecurityConfig.java

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,31 @@
66
import org.springframework.context.annotation.Bean;
77
import org.springframework.context.annotation.Configuration;
88
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
9-
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
109
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
11-
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
1210
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
1311
import org.springframework.security.crypto.password.PasswordEncoder;
12+
import org.springframework.security.web.SecurityFilterChain;
1413
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
1514

1615

1716
@Configuration
1817
@EnableWebSecurity
19-
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
20-
21-
@Override
22-
protected void configure(HttpSecurity http) throws Exception {
23-
http.addFilterAfter(new TwoFAFilter(), UsernamePasswordAuthenticationFilter.class)
24-
.csrf().disable().authorizeRequests()
25-
.antMatchers("/protected/**", "/2fa/**").authenticated()
26-
.antMatchers("/", "/register/**", "/api/**", "/**.js", "/**.html").permitAll()
27-
.and()
28-
.logout().permitAll();
29-
}
18+
public class WebSecurityConfig {
3019

3120
@Autowired
3221
private UserDetailsServiceImpl userDetailsService;
33-
3422
@Autowired
3523
private PasswordEncoder encoder;
3624

37-
@Override
38-
protected void configure(AuthenticationManagerBuilder auth)
39-
throws Exception {
40-
auth.userDetailsService(userDetailsService);
41-
auth.authenticationProvider(authProvider());
25+
@Bean
26+
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
27+
http
28+
.addFilterAfter(new TwoFAFilter(), UsernamePasswordAuthenticationFilter.class)
29+
.authorizeRequests()
30+
.requestMatchers("/protected/**", "/2fa/**").authenticated()
31+
.requestMatchers("/", "/register/**", "/api/**", "/**.js", "/**.html").permitAll()
32+
.and().logout().permitAll();
33+
return http.build();
4234
}
4335

4436
@Bean

src/main/java/com/twilio/accountsecurity/controllers/LoginController.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
import org.springframework.web.bind.annotation.RequestMethod;
1212
import org.springframework.web.bind.annotation.RestController;
1313

14-
import javax.servlet.ServletException;
15-
import javax.servlet.http.HttpServletRequest;
16-
import javax.servlet.http.HttpServletResponse;
17-
import javax.validation.Valid;
14+
import jakarta.servlet.ServletException;
15+
import jakarta.servlet.http.HttpServletRequest;
16+
import jakarta.servlet.http.HttpServletResponse;
17+
import jakarta.validation.Valid;
1818
import java.io.IOException;
1919

2020
@RestController

src/main/java/com/twilio/accountsecurity/controllers/PhoneVerificationController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
import org.springframework.web.bind.annotation.RequestMethod;
1212
import org.springframework.web.bind.annotation.RestController;
1313

14-
import javax.servlet.http.HttpSession;
15-
import javax.validation.Valid;
14+
import jakarta.servlet.http.HttpSession;
15+
import jakarta.validation.Valid;
1616

1717
@RestController
1818
@RequestMapping(path = "/api/phone-verification")
@@ -26,7 +26,7 @@ public PhoneVerificationController(PhoneVerificationService phoneVerificationSer
2626
}
2727

2828
@RequestMapping(path = "start", method = RequestMethod.POST,
29-
consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
29+
consumes = MediaType.APPLICATION_JSON_VALUE)
3030
public ResponseEntity<?> start(@Valid @RequestBody PhoneVerificationStartRequest requestBody) {
3131
return runWithCatch(() -> {
3232
phoneVerificationService.start(

0 commit comments

Comments
 (0)