gnodet opened a new pull request, #31135: URL: https://github.com/apache/camel/pull/31135
## Summary Adds an `oauthProfile` URI option to the `camel-http` producer. When set, a bearer token is resolved per exchange via a named camel-oauth profile and injected as an `Authorization: Bearer` header before each outbound HTTP request. Requires `camel-oauth` on the classpath. ## Root Cause `OAuthProfileAwareHttpEndpoint` (introduced in 4.21) only covers the **consumer** side — incoming token validation for servlet/jetty/platform-http endpoints. No producer-side bearer token injection existed for `camel-http`. ## Fix - **`HttpEndpoint`**: new `@UriParam oauthProfile` field (label `producer,security`) with getter/setter. - **`HttpProducer.process()`**: before calling `executeMethod()`, resolves `OAuthHelper.resolveOAuthToken(context, profileName)` per exchange and sets `Authorization: Bearer <token>` on the request. Token resolution is lazy (via `camel-oauth`'s cached client_credentials grant, refreshed automatically on expiry). - **`OAuth2ClientConfigurer`**: extracted `isTargetAuthority(HttpRequest, URI)` as a package-private static — reused by `HttpProducer` to guard against leaking the token to redirect targets on a different authority (same protection the `oauth2*` options already have via the HTTP client interceptor chain). - **Generated files** (`HttpEndpointConfigurer`, `HttpEndpointUriFactory`, `http.json`, `https.json`) regenerated. ## Tests - `HttpOAuthProfileProducerTest.theBearerTokenIsInjectedForTheNamedProfile` — integration test against a real embedded HTTP server; a `StubOAuthClientAuthenticationFactory` registered via the service loader returns a deterministic token without calling a real IdP. Asserts the `Authorization: Bearer stub-token-for-myprofile` header reaches the server. - `HttpOAuthProfileProducerTest.theBearerTokenIsNotAttachedToADifferentAuthority` — unit test for `OAuth2ClientConfigurer.isTargetAuthority()`: same host+port → true, different host → false, different port → false. Fixes CAMEL-27122 --- _Hermes Agent (Claude Sonnet 4.6) on behalf of Guillaume Nodet_ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
