File tree Expand file tree Collapse file tree 6 files changed +11
-10
lines changed
java/org/springframework/grpc/sample
test/java/org/springframework/grpc/sample
spring-grpc-server-spring-boot-autoconfigure/src/main/java/org/springframework/boot/grpc/server/autoconfigure/security Expand file tree Collapse file tree 6 files changed +11
-10
lines changed Original file line number Diff line number Diff line change 77import org .springframework .context .annotation .Bean ;
88import org .springframework .grpc .server .GlobalServerInterceptor ;
99import org .springframework .grpc .server .security .GrpcSecurity ;
10- import org .springframework .security .config .annotation .authentication .configuration .EnableGlobalAuthentication ;
1110import org .springframework .security .core .userdetails .User ;
1211import org .springframework .security .provisioning .InMemoryUserDetailsManager ;
1312
1413import io .grpc .Metadata ;
1514import io .grpc .ServerInterceptor ;
1615
1716@ SpringBootApplication
18- @ EnableGlobalAuthentication
1917class GrpcServerApplication {
2018
2119 public static final Metadata .Key <String > USER_KEY = Metadata .Key .of ("X-USER" , Metadata .ASCII_STRING_MARSHALLER );
Original file line number Diff line number Diff line change 11spring.application.name =grpc-server
22logging.level.org.springframework.security =debug
3-
4- debug =true
Original file line number Diff line number Diff line change 77import java .util .concurrent .atomic .AtomicReference ;
88
99import org .awaitility .Awaitility ;
10- import org .junit .jupiter .api .Disabled ;
1110import org .junit .jupiter .api .Test ;
1211import org .springframework .beans .factory .annotation .Autowired ;
1312import org .springframework .beans .factory .annotation .Qualifier ;
@@ -55,10 +54,9 @@ void contextLoads() {
5554 }
5655
5756 @ Test
58- @ Disabled ("Code is coming back PERMISSION_DENIED NOT UNAUTHENTICATED" )
5957 void unauthenticated () {
6058 assertThatExceptionOfType (StatusRuntimeException .class )
61- .isThrownBy (() -> basic . streamHello (HelloRequest .newBuilder ().setName ("Alien" ).build ()). next ( ))
59+ .isThrownBy (() -> stub . sayHello (HelloRequest .newBuilder ().setName ("Alien" ).build ()))
6260 .extracting ("status.code" )
6361 .isEqualTo (Code .UNAUTHENTICATED );
6462 }
Original file line number Diff line number Diff line change 66 <parent >
77 <groupId >org.springframework.boot</groupId >
88 <artifactId >spring-boot-starter-parent</artifactId >
9- <version >3.5.5 </version >
9+ <version >4.0.0-RC2 </version >
1010 <relativePath /> <!-- lookup parent from repository -->
1111 </parent >
1212 <groupId >org.springframework.grpc</groupId >
5959 </dependency >
6060 <dependency >
6161 <groupId >org.springframework.grpc</groupId >
62- <artifactId >spring-grpc-test</artifactId >
62+ <artifactId >spring-grpc-test-spring-boot-autoconfigure</artifactId >
63+ <scope >test</scope >
64+ </dependency >
65+ <dependency >
66+ <groupId >org.springframework.boot</groupId >
67+ <artifactId >spring-boot-starter-test</artifactId >
6368 <scope >test</scope >
6469 </dependency >
6570 </dependencies >
Original file line number Diff line number Diff line change 2121 <module >grpc-reactive</module >
2222 <module >grpc-secure</module >
2323 <module >grpc-server</module >
24- <!-- <module>grpc-server-kotlin</module> -- >
24+ <module >grpc-server-kotlin</module >
2525 <module >grpc-server-netty-shaded</module >
2626 <module >grpc-tomcat</module >
2727<!-- <module>grpc-tomcat-secure</module>-->
Original file line number Diff line number Diff line change 4343import org .springframework .security .config .ObjectPostProcessor ;
4444import org .springframework .security .config .annotation .authentication .builders .AuthenticationManagerBuilder ;
4545import org .springframework .security .config .annotation .authentication .configuration .AuthenticationConfiguration ;
46+ import org .springframework .security .config .annotation .authentication .configuration .EnableGlobalAuthentication ;
4647import org .springframework .security .web .SecurityFilterChain ;
4748
4849import io .grpc .internal .GrpcUtil ;
@@ -78,6 +79,7 @@ GrpcExceptionHandler accessExceptionHandler() {
7879 @ ConditionalOnBean (ObjectPostProcessor .class )
7980 @ ConditionalOnGrpcNativeServer
8081 @ Configuration (proxyBeanMethods = false )
82+ @ EnableGlobalAuthentication
8183 static class GrpcNativeSecurityConfigurerConfiguration {
8284
8385 @ Bean
You can’t perform that action at this time.
0 commit comments