Skip to content

Commit 77c4be0

Browse files
Merge branch 'main' into snyk-fix-71b653cc10190b8497c47b472b930195
2 parents 3e7e644 + 49645c8 commit 77c4be0

File tree

17 files changed

+312
-38
lines changed

17 files changed

+312
-38
lines changed

CODEOWNERS

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1-
* @kinde-oss/giants-kinde
1+
# Default owners for all files
2+
* @kinde-oss/giants-kinde
3+
4+
# Java / Maven dependency files that Renovate updates
5+
pom.xml @kinde-oss/sdk-engineers
6+
**/pom.xml @kinde-oss/sdk-engineers
7+
8+
# Optional: if Renovate ever bumps Maven wrapper versions
9+
.mvn/wrapper/** @kinde-oss/sdk-engineers
10+
mvnw @kinde-oss/sdk-engineers
11+
mvnw.cmd @kinde-oss/sdk-engineers

kinde-core/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
<dependency>
135135
<groupId>io.swagger.core.v3</groupId>
136136
<artifactId>swagger-annotations</artifactId>
137-
<version>2.2.36</version>
137+
<version>2.2.38</version>
138138
</dependency>
139139
<dependency>
140140
<groupId>com.google.code.findbugs</groupId>
@@ -199,7 +199,7 @@
199199
<dependency>
200200
<groupId>com.google.code.gson</groupId>
201201
<artifactId>gson</artifactId>
202-
<version>2.13.1</version>
202+
<version>2.13.2</version>
203203
</dependency>
204204
<dependency>
205205
<groupId>io.gsonfire</groupId>
@@ -294,7 +294,7 @@
294294
<plugin>
295295
<groupId>org.apache.maven.plugins</groupId>
296296
<artifactId>maven-surefire-plugin</artifactId>
297-
<version>3.5.3</version>
297+
<version>3.5.4</version>
298298
<configuration>
299299
<parallel>none</parallel>
300300
</configuration>

kinde-management/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<properties>
1212
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
13-
<swagger-annotations-version>2.2.36</swagger-annotations-version>
13+
<swagger-annotations-version>2.2.38</swagger-annotations-version>
1414
<jackson-databind-nullable-version>0.2.7</jackson-databind-nullable-version>
1515
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
1616
<junit-version>4.13.2</junit-version>
@@ -103,7 +103,7 @@
103103
<dependency>
104104
<groupId>com.google.code.gson</groupId>
105105
<artifactId>gson</artifactId>
106-
<version>2.13.1</version>
106+
<version>2.13.2</version>
107107
</dependency>
108108
<!-- https://mvnrepository.com/artifact/io.gsonfire/gson-fire -->
109109
<dependency>
@@ -320,7 +320,7 @@
320320
<plugin>
321321
<groupId>org.apache.maven.plugins</groupId>
322322
<artifactId>maven-surefire-plugin</artifactId>
323-
<version>3.5.3</version>
323+
<version>3.5.4</version>
324324
<configuration>
325325
<parallel>none</parallel>
326326
</configuration>

kinde-springboot/kinde-springboot-core/pom.xml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<groupId>org.springframework.boot</groupId>
3838
<artifactId>spring-boot-starter-webflux</artifactId>
3939
<optional>true</optional>
40-
<version>3.5.5</version>
40+
<version>3.5.6</version>
4141
</dependency>
4242

4343
<dependency>
@@ -50,34 +50,34 @@
5050
<dependency>
5151
<groupId>org.springframework.security</groupId>
5252
<artifactId>spring-security-config</artifactId>
53-
<version>6.5.3</version>
53+
<version>6.5.5</version>
5454
</dependency>
5555
<dependency>
5656
<groupId>org.springframework.boot</groupId>
5757
<artifactId>spring-boot-starter-security</artifactId>
58-
<version>3.5.5</version>
58+
<version>3.5.6</version>
5959
</dependency>
6060
<dependency>
6161
<groupId>org.springframework.security</groupId>
6262
<artifactId>spring-security-oauth2-client</artifactId>
63-
<version>6.5.3</version>
63+
<version>6.5.5</version>
6464
</dependency>
6565
<dependency>
6666
<groupId>org.springframework.security</groupId>
6767
<artifactId>spring-security-oauth2-jose</artifactId>
68-
<version>6.5.3</version>
68+
<version>6.5.5</version>
6969
</dependency>
7070
<dependency>
7171
<groupId>org.springframework.security</groupId>
7272
<artifactId>spring-security-oauth2-resource-server</artifactId>
73-
<version>6.5.3</version>
73+
<version>6.5.5</version>
7474
</dependency>
7575

7676
<!-- Spring deps-->
7777
<dependency>
7878
<groupId>org.springframework.boot</groupId>
7979
<artifactId>spring-boot-starter-security</artifactId>
80-
<version>3.5.5</version>
80+
<version>3.5.6</version>
8181
</dependency>
8282
<dependency>
8383
<groupId>org.springframework.boot</groupId>
@@ -97,7 +97,7 @@
9797
<groupId>org.springframework</groupId>
9898
<artifactId>spring-test</artifactId>
9999
<scope>test</scope>
100-
<version>6.2.10</version>
100+
<version>6.2.11</version>
101101
</dependency>
102102
<dependency>
103103
<groupId>org.mockito</groupId>
@@ -108,7 +108,7 @@
108108
<dependency>
109109
<groupId>org.assertj</groupId>
110110
<artifactId>assertj-core</artifactId>
111-
<version>3.27.4</version>
111+
<version>3.27.6</version>
112112
<scope>test</scope>
113113
</dependency>
114114

@@ -177,7 +177,7 @@
177177
<dependency>
178178
<groupId>org.projectlombok</groupId>
179179
<artifactId>lombok</artifactId>
180-
<version>1.18.40</version>
180+
<version>1.18.42</version>
181181
<scope>provided</scope>
182182
</dependency>
183183
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.kinde.spring;
2+
3+
import com.kinde.spring.config.KindeOAuth2Properties;
4+
import com.kinde.spring.sdk.KindeSdkClient;
5+
import org.springframework.boot.autoconfigure.AutoConfiguration;
6+
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
7+
import org.springframework.boot.context.properties.EnableConfigurationProperties;
8+
import org.springframework.context.annotation.Bean;
9+
10+
/**
11+
* Auto-configuration for KindeSdkClient.
12+
* This ensures that KindeSdkClient is properly configured as a Spring bean
13+
* when Kinde OAuth2 properties are available.
14+
*/
15+
@AutoConfiguration
16+
@ConditionalOnKindeClientProperties
17+
@EnableConfigurationProperties(KindeOAuth2Properties.class)
18+
public class KindeSdkClientAutoConfig {
19+
20+
@Bean
21+
@ConditionalOnMissingBean
22+
public KindeSdkClient kindeSdkClient() {
23+
return new KindeSdkClient();
24+
}
25+
}

kinde-springboot/kinde-springboot-core/src/main/java/com/kinde/spring/sdk/KindeSdkClient.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,13 @@
22

33
import com.kinde.KindeClient;
44
import com.kinde.KindeClientBuilder;
5-
import com.kinde.KindeClientSession;
65
import com.kinde.authorization.AuthorizationType;
76
import com.kinde.spring.config.KindeOAuth2Properties;
87
import jakarta.annotation.PostConstruct;
98
import org.springframework.beans.factory.annotation.Autowired;
10-
import org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientProperties;
11-
import org.springframework.stereotype.Component;
129
import org.springframework.web.context.annotation.ApplicationScope;
1310

14-
import java.util.Map;
15-
1611
@ApplicationScope
17-
@Component
1812
public class KindeSdkClient {
1913

2014
@Autowired

kinde-springboot/kinde-springboot-core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
com.kinde.spring.KindeSdkClientAutoConfig
12
com.kinde.spring.KindeOAuth2AutoConfig
23
com.kinde.spring.KindeOAuth2ResourceServerAutoConfig
34
com.kinde.spring.ReactiveKindeOAuth2AutoConfig
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
package com.kinde.spring;
2+
3+
import org.junit.jupiter.api.Test;
4+
import org.springframework.core.io.ClassPathResource;
5+
6+
import java.io.BufferedReader;
7+
import java.io.IOException;
8+
import java.io.InputStreamReader;
9+
import java.nio.charset.StandardCharsets;
10+
import java.util.List;
11+
import java.util.stream.Collectors;
12+
13+
import static org.assertj.core.api.Assertions.assertThat;
14+
15+
/**
16+
* Tests for KindeSdkClientAutoConfig.
17+
*
18+
* This test class covers:
19+
* 1. Verification that KindeSdkClientAutoConfig is properly registered in the imports file
20+
* 2. Verification that the auto-configuration is available for Spring Boot to load
21+
* 3. Verification that the auto-configuration is properly ordered
22+
*/
23+
public class KindeSdkClientAutoConfigTest {
24+
25+
/**
26+
* Helper method to read the auto-configuration imports file.
27+
*
28+
* @return List of lines from the auto-configuration imports file
29+
* @throws IOException if the file cannot be read
30+
*/
31+
private List<String> readAutoConfigurationImports() throws IOException {
32+
ClassPathResource resource = new ClassPathResource("META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports");
33+
assertThat(resource.exists()).isTrue();
34+
35+
try (var inputStream = resource.getInputStream();
36+
var reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) {
37+
return reader.lines().collect(Collectors.toList());
38+
}
39+
}
40+
41+
@Test
42+
public void testKindeSdkClientAutoConfigIsRegisteredInImportsFile() throws IOException {
43+
// Test that KindeSdkClientAutoConfig is properly registered in the auto-configuration imports file
44+
List<String> lines = readAutoConfigurationImports();
45+
46+
// Verify that KindeSdkClientAutoConfig is registered
47+
assertThat(lines).contains("com.kinde.spring.KindeSdkClientAutoConfig");
48+
}
49+
50+
@Test
51+
public void testKindeSdkClientAutoConfigIsRegisteredBeforeKindeOAuth2AutoConfig() throws IOException {
52+
// Test that KindeSdkClientAutoConfig is registered before KindeOAuth2AutoConfig
53+
// This ensures proper ordering so that KindeSdkClient is available for KindeOAuth2AutoConfig
54+
List<String> lines = readAutoConfigurationImports();
55+
56+
int kindeSdkClientAutoConfigIndex = lines.indexOf("com.kinde.spring.KindeSdkClientAutoConfig");
57+
int kindeOAuth2AutoConfigIndex = lines.indexOf("com.kinde.spring.KindeOAuth2AutoConfig");
58+
59+
// Verify that KindeSdkClientAutoConfig comes before KindeOAuth2AutoConfig
60+
assertThat(kindeSdkClientAutoConfigIndex).isGreaterThan(-1);
61+
assertThat(kindeOAuth2AutoConfigIndex).isGreaterThan(-1);
62+
assertThat(kindeSdkClientAutoConfigIndex).isLessThan(kindeOAuth2AutoConfigIndex);
63+
}
64+
65+
@Test
66+
public void testAutoConfigurationImportsFileExists() throws IOException {
67+
// Test that the auto-configuration imports file exists and contains the necessary configuration
68+
List<String> lines = readAutoConfigurationImports();
69+
assertThat(lines).isNotEmpty();
70+
71+
// Verify that KindeSdkClientAutoConfig is in the list
72+
assertThat(lines).contains("com.kinde.spring.KindeSdkClientAutoConfig");
73+
}
74+
75+
@Test
76+
public void testKindeSdkClientAutoConfigClassExists() {
77+
// Test that the KindeSdkClientAutoConfig class exists and can be loaded
78+
try {
79+
Class<?> autoConfigClass = Class.forName("com.kinde.spring.KindeSdkClientAutoConfig");
80+
assertThat(autoConfigClass).isNotNull();
81+
assertThat(autoConfigClass.getSimpleName()).isEqualTo("KindeSdkClientAutoConfig");
82+
} catch (ClassNotFoundException e) {
83+
throw new AssertionError("KindeSdkClientAutoConfig class not found", e);
84+
}
85+
}
86+
87+
@Test
88+
public void testKindeSdkClientAutoConfigHasCorrectAnnotations() {
89+
// Test that KindeSdkClientAutoConfig has the correct annotations
90+
try {
91+
Class<?> autoConfigClass = Class.forName("com.kinde.spring.KindeSdkClientAutoConfig");
92+
93+
// Verify that it has @AutoConfiguration annotation
94+
assertThat(autoConfigClass.isAnnotationPresent(org.springframework.boot.autoconfigure.AutoConfiguration.class))
95+
.isTrue();
96+
97+
// Verify that it has @ConditionalOnKindeClientProperties annotation
98+
assertThat(autoConfigClass.isAnnotationPresent(com.kinde.spring.ConditionalOnKindeClientProperties.class))
99+
.isTrue();
100+
101+
// Verify that it has @EnableConfigurationProperties annotation
102+
assertThat(autoConfigClass.isAnnotationPresent(org.springframework.boot.context.properties.EnableConfigurationProperties.class))
103+
.isTrue();
104+
105+
} catch (ClassNotFoundException e) {
106+
throw new AssertionError("KindeSdkClientAutoConfig class not found", e);
107+
}
108+
}
109+
110+
@Test
111+
public void testKindeSdkClientAutoConfigHasKindeSdkClientBean() {
112+
// Test that KindeSdkClientAutoConfig has a method that creates KindeSdkClient bean
113+
try {
114+
Class<?> autoConfigClass = Class.forName("com.kinde.spring.KindeSdkClientAutoConfig");
115+
116+
// Look for a method that returns KindeSdkClient
117+
java.lang.reflect.Method[] methods = autoConfigClass.getDeclaredMethods();
118+
boolean hasKindeSdkClientMethod = false;
119+
120+
for (java.lang.reflect.Method method : methods) {
121+
if (method.getReturnType().getSimpleName().equals("KindeSdkClient")) {
122+
hasKindeSdkClientMethod = true;
123+
124+
// Verify that it has @Bean annotation
125+
assertThat(method.isAnnotationPresent(org.springframework.context.annotation.Bean.class))
126+
.isTrue();
127+
128+
// Verify that it has @ConditionalOnMissingBean annotation
129+
assertThat(method.isAnnotationPresent(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean.class))
130+
.isTrue();
131+
132+
break;
133+
}
134+
}
135+
136+
assertThat(hasKindeSdkClientMethod).isTrue();
137+
138+
} catch (ClassNotFoundException e) {
139+
throw new AssertionError("KindeSdkClientAutoConfig class not found", e);
140+
}
141+
}
142+
143+
@Test
144+
public void testCustomerProblemIsResolved() throws IOException {
145+
// Test that demonstrates the customer's problem has been resolved
146+
// by showing that the auto-configuration is properly registered
147+
148+
List<String> lines = readAutoConfigurationImports();
149+
150+
// Before our fix: KindeSdkClient would not be available because:
151+
// 1. It was only annotated with @Component
152+
// 2. Spring doesn't scan 3rd party packages for components
153+
// 3. KindeOAuth2AutoConfig would fail to autowire it
154+
// 4. Application would fail to start
155+
156+
// After our fix: KindeSdkClientAutoConfig is registered and will be loaded
157+
// by Spring Boot's auto-configuration system
158+
assertThat(lines).contains("com.kinde.spring.KindeSdkClientAutoConfig");
159+
160+
// This means that when a Spring Boot application starts with Kinde properties,
161+
// KindeSdkClient will be automatically configured and available for KindeOAuth2AutoConfig
162+
}
163+
164+
@Test
165+
public void testNoManualConfigurationRequired() throws IOException {
166+
// Test that verifies no manual configuration is required
167+
// The customer mentioned they would need to add:
168+
// @SpringBootApplication(scanBasePackageClasses = [KindeSdkClient::class])
169+
// This test proves that's not necessary anymore
170+
171+
List<String> lines = readAutoConfigurationImports();
172+
173+
// The fact that KindeSdkClientAutoConfig is registered means that
174+
// no manual configuration like component scanning is required
175+
assertThat(lines).contains("com.kinde.spring.KindeSdkClientAutoConfig");
176+
}
177+
}

0 commit comments

Comments
 (0)