Skip to content

Commit 833058b

Browse files
authored
Merge pull request #383 from yidongnan/feature/graalvm/part1
Change auto configs to use `@Configuration(proxyBeanMethods = false)`
2 parents b56a9bf + 2cc341b commit 833058b

File tree

24 files changed

+44
-39
lines changed

24 files changed

+44
-39
lines changed

examples/cloud-grpc-client/src/main/java/net/devh/boot/grpc/examples/cloud/client/GlobalClientInterceptorConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import net.devh.boot.grpc.client.interceptor.GlobalClientInterceptorConfigurer;
2626

2727
@Order(Ordered.LOWEST_PRECEDENCE)
28-
@Configuration
28+
@Configuration(proxyBeanMethods = false)
2929
public class GlobalClientInterceptorConfiguration {
3030

3131
@Bean

examples/cloud-grpc-server/src/main/java/net/devh/boot/grpc/examples/cloud/server/GlobalInterceptorConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
import net.devh.boot.grpc.server.interceptor.GlobalServerInterceptorConfigurer;
2424

25-
@Configuration
25+
@Configuration(proxyBeanMethods = false)
2626
public class GlobalInterceptorConfiguration {
2727

2828
@Bean

examples/local-grpc-client/src/main/java/net/devh/boot/grpc/examples/local/client/GlobalClientInterceptorConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import net.devh.boot.grpc.client.interceptor.GlobalClientInterceptorConfigurer;
2626

2727
@Order(Ordered.LOWEST_PRECEDENCE)
28-
@Configuration
28+
@Configuration(proxyBeanMethods = false)
2929
public class GlobalClientInterceptorConfiguration {
3030

3131
@Bean

examples/local-grpc-server/src/main/java/net/devh/boot/grpc/examples/local/server/GlobalInterceptorConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import net.devh.boot.grpc.server.interceptor.GlobalServerInterceptorConfigurer;
2424
import net.devh.boot.grpc.server.interceptor.GlobalServerInterceptorRegistry;
2525

26-
@Configuration
26+
@Configuration(proxyBeanMethods = false)
2727
public class GlobalInterceptorConfiguration {
2828

2929
@Bean

examples/security-grpc-bearerAuth-client/src/main/java/net/devh/boot/grpc/examples/security/client/SecurityConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*
2929
* @author Gregor Eeckels ([email protected])
3030
*/
31-
@Configuration
31+
@Configuration(proxyBeanMethods = false)
3232
public class SecurityConfiguration {
3333

3434
// This token will usually be created by a login endpoint (e.g. from Keycloak).

examples/security-grpc-bearerAuth-server/src/main/java/net/devh/boot/grpc/examples/security/server/SecurityConfiguration.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
*
4141
* @author Gregor Eeckels ([email protected])
4242
*/
43-
@Configuration
43+
@Configuration(proxyBeanMethods = false)
4444
// proxyTargetClass is required, if you use annotation driven security!
4545
// However, you will receive a warning that GrpcServerService#bindService() method is final.
4646
// You cannot avoid that warning (without massive amount of work), but it is safe to ignore it.
@@ -51,9 +51,11 @@
5151
public class SecurityConfiguration {
5252

5353
@Bean
54-
JwtAuthenticationConverter jwtAuthenticationConverter() {
54+
JwtAuthenticationConverter jwtAuthenticationConverter(
55+
final KeyCloakGrantedAuthoritiesConverter keyCloakGrantedAuthoritiesConverter) {
56+
5557
final JwtAuthenticationConverter converter = new JwtAuthenticationConverter();
56-
converter.setJwtGrantedAuthoritiesConverter(keyCloakGrantedAuthoritiesConverter());
58+
converter.setJwtGrantedAuthoritiesConverter(keyCloakGrantedAuthoritiesConverter);
5759
return converter;
5860
}
5961

@@ -63,26 +65,26 @@ KeyCloakGrantedAuthoritiesConverter keyCloakGrantedAuthoritiesConverter() {
6365
}
6466

6567
@Bean
66-
JwtAuthenticationProvider jwtAuthenticationProvider() {
68+
JwtAuthenticationProvider jwtAuthenticationProvider(final JwtAuthenticationConverter jwtAuthenticationConverter) {
6769
final JwtAuthenticationProvider provider = new JwtAuthenticationProvider(jwtDecoder());
68-
provider.setJwtAuthenticationConverter(jwtAuthenticationConverter());
70+
provider.setJwtAuthenticationConverter(jwtAuthenticationConverter);
6971
return provider;
7072
}
7173

7274
@Bean
7375
/*
7476
* Add the authentication providers to the manager.
7577
*/
76-
AuthenticationManager authenticationManager() {
78+
AuthenticationManager authenticationManager(final JwtAuthenticationProvider jwtAuthenticationProvider) {
7779
final List<AuthenticationProvider> providers = new ArrayList<>();
78-
providers.add(jwtAuthenticationProvider());
80+
providers.add(jwtAuthenticationProvider);
7981
return new ProviderManager(providers);
8082
}
8183

8284
@Bean
8385
// Configure which authentication types you support.
8486
GrpcAuthenticationReader authenticationReader() {
85-
return new BearerAuthenticationReader(accessToken -> new BearerTokenAuthenticationToken(accessToken));
87+
return new BearerAuthenticationReader(BearerTokenAuthenticationToken::new);
8688
}
8789

8890
@Bean

examples/security-grpc-client/src/main/java/net/devh/boot/grpc/examples/security/client/SecurityConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* @author Daniel Theuke ([email protected])
3333
* @see CallCredentialsHelper
3434
*/
35-
@Configuration
35+
@Configuration(proxyBeanMethods = false)
3636
public class SecurityConfiguration {
3737

3838
@Value("${auth.username}")

examples/security-grpc-server/src/main/java/net/devh/boot/grpc/examples/security/server/SecurityConfiguration.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
*
4747
* @author Daniel Theuke ([email protected])
4848
*/
49-
@Configuration
49+
@Configuration(proxyBeanMethods = false)
5050
// proxyTargetClass is required, if you use annotation driven security!
5151
// However, you will receive a warning that GrpcServerService#bindService() method is final.
5252
// You cannot avoid that warning (without massive amount of work), but it is safe to ignore it.
@@ -65,17 +65,17 @@ PasswordEncoder passwordEncoder() {
6565

6666
@Bean
6767
// This could be your database lookup. There are some complete implementations in spring-security-web.
68-
UserDetailsService userDetailsService() {
68+
UserDetailsService userDetailsService(final PasswordEncoder passwordEncoder) {
6969
return username -> {
7070
log.debug("Searching user: {}", username);
7171
switch (username) {
7272
case "guest": {
73-
return new User(username, passwordEncoder().encode(username + "Password"), Collections.emptyList());
73+
return new User(username, passwordEncoder.encode(username + "Password"), Collections.emptyList());
7474
}
7575
case "user": {
7676
final List<SimpleGrantedAuthority> authorities =
7777
Arrays.asList(new SimpleGrantedAuthority("ROLE_GREET"));
78-
return new User(username, passwordEncoder().encode(username + "Password"), authorities);
78+
return new User(username, passwordEncoder.encode(username + "Password"), authorities);
7979
}
8080
default: {
8181
throw new UsernameNotFoundException("Could not find user!");
@@ -87,18 +87,21 @@ UserDetailsService userDetailsService() {
8787
@Bean
8888
// One of your authentication providers.
8989
// They ensure that the credentials are valid and populate the user's authorities.
90-
DaoAuthenticationProvider daoAuthenticationProvider() {
90+
DaoAuthenticationProvider daoAuthenticationProvider(
91+
final UserDetailsService userDetailsService,
92+
final PasswordEncoder passwordEncoder) {
93+
9194
final DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
92-
provider.setUserDetailsService(userDetailsService());
93-
provider.setPasswordEncoder(passwordEncoder());
95+
provider.setUserDetailsService(userDetailsService);
96+
provider.setPasswordEncoder(passwordEncoder);
9497
return provider;
9598
}
9699

97100
@Bean
98101
// Add the authentication providers to the manager.
99-
AuthenticationManager authenticationManager() {
102+
AuthenticationManager authenticationManager(final DaoAuthenticationProvider daoAuthenticationProvider) {
100103
final List<AuthenticationProvider> providers = new ArrayList<>();
101-
providers.add(daoAuthenticationProvider());
104+
providers.add(daoAuthenticationProvider);
102105
return new ProviderManager(providers);
103106
}
104107

grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/autoconfigure/GrpcClientAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
* @author Michael ([email protected])
5858
* @since 5/17/16
5959
*/
60-
@Configuration
60+
@Configuration(proxyBeanMethods = false)
6161
@EnableConfigurationProperties
6262
@AutoConfigureAfter(name = "org.springframework.cloud.client.CommonsClientAutoConfiguration",
6363
value = GrpcCommonCodecAutoConfiguration.class)

grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/autoconfigure/GrpcClientHealthAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
*
3636
* @author Daniel Theuke ([email protected])
3737
*/
38-
@Configuration
38+
@Configuration(proxyBeanMethods = false)
3939
@AutoConfigureAfter(GrpcClientAutoConfiguration.class)
4040
@ConditionalOnClass(name = "org.springframework.boot.actuate.health.HealthIndicator")
4141
public class GrpcClientHealthAutoConfiguration {

0 commit comments

Comments
 (0)