120 Commits

Author SHA1 Message Date
Dave Syer
08988c042f Add default service config to GrpcClientProperties
Ensure that it doesn't conflict with health service configuration.

Also ensure random port is used in all tests.

Fixes gh-171 (as far as we can)
2025-06-16 09:22:23 +01:00
Chris Bono
171f2556df Fixes to allow non-test inprocess channels
- Fix @LocalGrpcPort to ignore the inprocess factory port
- Don't set load balancer policy for inprocess channel factory

Signed-off-by: Chris Bono <chris.bono@gmail.com>
2025-06-09 16:01:38 +01:00
Chris Bono
a087eac776 Add support for in-process outside of tests
This commit allows the usage of inprocess server and channel factories
outside of tests.

Resolves #144

Signed-off-by: Chris Bono <chris.bono@gmail.com>
2025-06-09 16:01:38 +01:00
Dave Syer
f1b8bfacb4 Merge two classes into one
Fixes gh-166
2025-05-29 13:13:32 +01:00
Alexey Genus
6403bd96fa Implement CoroutineStubFactory
Signed-off-by: Alexey Genus <genus.alexey@gmail.com>
2025-05-16 09:20:44 +01:00
Dave Syer
2d3ddfca12 Remove redundant annotation 2025-05-08 15:58:42 +01:00
Dave Syer
132fd2c364 Use new class in condition 2025-04-17 15:13:28 +01:00
Tran Ngoc Nhan
eeb625b452 Remove obsolete code
Signed-off-by: Tran Ngoc Nhan <ngocnhan.tran1996@gmail.com>
2025-04-09 14:41:21 +01:00
Schuyler Metcalf
a99ac62fe9 Fixes issue with maxIncomingMessageSize not being set correctly for clients
Signed-off-by: Schuyler Metcalf <schuyler.metcalf@hey.com>
2025-04-08 13:00:46 +01:00
Dave Syer
07e9e14d26 More care taken with starting netty server in webapp 2025-04-04 15:32:19 +01:00
Dave Syer
a39904ca1c Add a test 2025-04-04 13:49:24 +01:00
Dave Syer
a86db67db9 Add extra defensive condition 2025-04-03 15:43:10 +01:00
Dave Syer
28465263d7 Clarify bundle meaning 2025-04-03 13:30:53 +01:00
Dave Syer
d93ad2b865 Add more detail about disabling the servlet 2025-04-03 13:22:04 +01:00
Dave Syer
a3d7ba643d Split bean registration and creation for stubs
GrpcClientRegistry was responsible for both, which causes lifecycle
issues when users don't follow recommendations. This change
pushes the bean registration firmly down a level into an
ImportBeanDefinitionRegistrar. Also helps with AOT because the AOT
processor only runs the IBDR at build time.
2025-04-03 12:09:23 +01:00
Dave Syer
8b26b8f262 Rename annotation to mirror Spring HTTP interfaces 2025-03-26 08:30:01 +00:00
Dave Syer
55bd93958a Rename client annotations 2025-03-26 08:23:11 +00:00
Dave Syer
582b59a7a6 Add registrar to autoconfig 2025-03-25 07:11:24 +00:00
Dave Syer
e4fa0f83df Check if csrf protection is already disabled
If the user has explicitly disabled CSRF protection in a custom
SecurityFilterChain, we should be able to back off and not try
to disable it just for the gRPC endpoints (accidentally switching
it back on for the other endpoints).

Fixes gh-142
2025-03-24 10:09:43 +00:00
Dave Syer
6198fe04d8 Add reactive version of servlet request matchers 2025-03-18 14:56:06 +00:00
Sergei Batsura
b004ba6559 Added defaultDeadline client property
Signed-off-by: Sergei Batsura <batsura.sa@gmail.com>
[resolves #136]
2025-03-13 12:36:20 +00:00
Dave Syer
d8995bb59a Add support for @EnableGrpcClients
Automatic bean definition registration for stubs

Fixes #91
2025-03-07 08:56:30 +00:00
Dave Syer
f580197169 Fix bugs in security autoconfig conditions 2025-03-06 14:52:20 +00:00
Dave Syer
24f7d20c2f Add some logging when services registered 2025-03-03 10:01:40 +00:00
Dave Syer
ebf9caa44d Add config property for http2 by default 2025-03-03 09:26:06 +00:00
Dave Syer
6853d2dad4 There may be more than one security configuration
In an app with servlets *and* a native gRPC server for instance,
the global AuthenticationManagerBuilder (the @Bean) should be
treated as a parent for the one used by GrpcSecurity. It's the
same in HttpSecurity. Slightly more complicated than necessary
when there is only native gRPC security, but at least it now
works, and makes it easier to introduce multiple GrpcSecurity
instances in future if necessary (like with HttpSecurity it
could be a prototype).
2025-02-24 16:23:43 +00:00
Dave Syer
dee423953f Add condition to guard security servlet config 2025-02-24 14:04:33 +00:00
Chris Bono
b04b6ca1ac Add ConditionalOnGrpcServerEnabled flag
This adds a coarse-grained conditional guard that will disable the
server autoconfiguration if `spring.grpc.server.enabled` is set to
false or `BindableService` class is not available on the classpath.

Signed-off-by: Chris Bono <chris.bono@gmail.com>
2025-02-24 12:42:06 +00:00
Chris Bono
2790a8a027 Add ConditionalOnGrpcClientEnabled flag
This adds a coarse-grained conditional guard that will disable the
client autoconfiguration if `spring.grpc.client.enabled` is set to
false or the `io.grpc:grpc-stub` module is not on the classpath.

Signed-off-by: Chris Bono <chris.bono@gmail.com>
2025-02-24 12:42:06 +00:00
Chris Bono
c3b7d77e41 Update description for servlet server config prop
Signed-off-by: Chris Bono <chris.bono@gmail.com>
2025-02-12 10:09:45 -06:00
Chris Bono
f398c85ac0 Rename security csrf property to include 'server'
This renames the `spring.grpc.security.csrf.enabled` property
to `spring.grpc.server.security.csrf.enabled` to signal that
it is a server configuration property.

Signed-off-by: Chris Bono <chris.bono@gmail.com>
2025-02-12 06:23:40 +00:00
Chris Bono
52751046f3 Remove conditional guard for spring.grpc.server.reactive.enabled
This removes the `@ConditionalOnProperty` guard that was in place to force a
native gRPC server to be used when the running application is a Reactive
based web application. This is not needed because a Reactive based web
application can not be used as Servlet gRPC server.

Signed-off-by: Chris Bono <chris.bono@gmail.com>
2025-02-12 06:23:40 +00:00
Chris Bono
9a970cafa5 Adds missing config props metadata
This adds the following entries to additional-spring-configuration-metadata.json:

- `spring.grpc.security.csrf.enabled`
- `spring.grpc.server.servlet.enabled`

They are not present in first class `@ConfigurationProperties` so need to be
manually added.

Signed-off-by: Chris Bono <chris.bono@gmail.com>
2025-02-12 06:23:40 +00:00
Dave Syer
cb58f10116 Allow default channel address to be carried through 2025-02-05 13:11:58 +00:00
Dave Syer
c13369e6db Add some oauth2 configuration and sample code 2025-01-28 09:00:48 +00:00
Dave Syer
ff40f5b323 Add authorize requests filters 2025-01-28 08:57:56 +00:00
Бацура Сергей Александрович
aa809aaf8a Fixed typo in GrpcClientProperties
Signed-off-by: Sergei Batsura <batsura.sa@gmail.com>
2025-01-27 10:17:45 -06:00
Dave Syer
be643c3627 Disable CSRF for Servlet apps by default 2025-01-24 09:06:04 +00:00
Dave Syer
cfe1ca9a57 Add some convenience methods to GrpcServiceDiscoverer 2025-01-16 17:28:29 +00:00
Chris Bono
87e26c378e Move named channel back into autoconfigure module
This commit moves the channel config ("NamedChannel") back to
autoconfigure module as the effort to move to core turns out to
be more trouble than it is worth at this time.

Fixes #92
2025-01-13 08:18:11 +00:00
Dave Syer
6dc5d85509 Wrist slapped 2025-01-08 09:53:45 +00:00
Dave Syer
d9731500fa Use GrpcUtil to create shared executor 2025-01-07 16:39:19 +00:00
Dave Syer
6cc3a2ab89 Use GrpcServiceDiscoverer in GrpcServletRequestMatcher 2025-01-07 09:14:59 +00:00
Dave Syer
f1a8299887 Add support for request matchers 2025-01-07 09:14:59 +00:00
Dave Syer
abcf83e8cc Make Spring Security work in a Tomcat app 2025-01-07 09:14:59 +00:00
Chris Bono
c936d6a876 Move NamedChannel model to core module (#89)
This commit introduces the NamedChannelRegistry which allows
moving the NamedChannel model to the core package and decouples
it from the client properties.
2025-01-06 21:19:07 -06:00
Dave Syer
bca2eff2b0 Upgrade grpc-java to 1.69.0 2025-01-06 16:30:51 +00:00
Chris Bono
b08e11ad39 Improve channel factory API
This commit improves the GrpcChannelFactory createChannel API by
introducing `ChannelBuilderOptions` that can be specified during
channel creation.

Additionally, concrete Netty channel factory implementations have
been added as well as adding type to the GrpcChannelBuilderCustomizer
which helps match customizers to channel factories.
2025-01-03 22:04:28 +00:00
Dave Syer
b3271be918 Add explicit support for running on separate port
If the user wants a second port for gRPC that should be possible
(and was the only way with the old ecosystem projects). This change
adds a webflux sample and support for
spring.grpc.server.{servlet,reactive}.enabled to be explicitly
"false" to disable the embedded services.

N.B. embedded services are not yet supported in webflux so the flag
has no effect, except to disable gRPC completely if it is "true".
2024-12-23 15:02:45 +00:00
Jonas Bjørge Andersen
4149ed552e Add autoconfiguration for client side observation interceptor
[resolves #51]

Signed-off-by: Jonas Bjørge Andersen <dev@jonasandersen.no>
2024-12-20 08:00:47 +00:00