This is an automated email from the ASF dual-hosted git repository.
oscerd pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git
The following commit(s) were added to refs/heads/main by this push:
new 8a3862568 chore: http-sink and http-source take a bearer token and
okStatusCodeRange (#3170) (#3198)
8a3862568 is described below
commit 8a3862568b9ca3b86d385a8261f453625e0bb87d
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Nov 18 15:12:32 2026 +0100
chore: http-sink and http-source take a bearer token and okStatusCodeRange
(#3170) (#3198)
Both Kamelets get two optional options of the HTTP component:
- `authBearerToken`: a static token such as an API key, sent as
`Authorization: Bearer <token>`. It is a secret (format: password,
credentials descriptor) and is passed as RAW() so that characters
such as `+`, `/` and `=` are sent as they are. Camel uses it only
with `authMethod: Bearer`, and sends it on the first request only
with `authenticationPreemptive: true`; the descriptions say so.
- `okStatusCodeRange`: the status codes that do not fail the message
(http-sink) or that are sent as a message (http-source), such as
`200-299,404`. A pattern rejects spaces, which Camel cannot parse.
Both use optional placeholders without a default, so with the options
unset the endpoint URI is the same as before.
A trust store is not added as an option. The only endpoint option for
it is `sslContextParameters`, and a bean that the template always
creates would change the calls with the options unset: camel-http
turns every `http://` address into `https://` when
`sslContextParameters` is set, and SSLContextParameters applies its own
protocol and cipher filters. The descriptions and the pages instead
say how to trust a private certificate authority with the `camel.ssl.*`
application properties and
`camel.component.https.useGlobalSslContextParameters=true`, which works
with these Kamelets today.
The authMethod description now lists Bearer and Digest, and no longer
calls it a comma-separated list, which Camel does not read. The pages
of both Kamelets no longer send readers to the deprecated secured
variants: they have a table of the login options, and examples for the
token, okStatusCodeRange and the trust store.
Co-authored-by: Claude Opus 5.5 <[email protected]>
---
.../ROOT/partials/http-sink-description.adoc | 72 ++++++++++++++++++++-
.../ROOT/partials/http-source-description.adoc | 75 +++++++++++++++++++++-
kamelets/http-sink.kamelet.yaml | 21 +++++-
kamelets/http-source.kamelet.yaml | 21 +++++-
.../main/resources/META-INF/kamelets-index.json | 4 +-
.../main/resources/kamelets/http-sink.kamelet.yaml | 21 +++++-
.../resources/kamelets/http-source.kamelet.yaml | 21 +++++-
7 files changed, 215 insertions(+), 20 deletions(-)
diff --git a/docs/modules/ROOT/partials/http-sink-description.adoc
b/docs/modules/ROOT/partials/http-sink-description.adoc
index ac3042ff2..c1481d936 100644
--- a/docs/modules/ROOT/partials/http-sink-description.adoc
+++ b/docs/modules/ROOT/partials/http-sink-description.adoc
@@ -8,10 +8,76 @@ Supports all standard HTTP methods: GET, POST (default), PUT,
DELETE, HEAD, OPTI
- **URL**: The target HTTP or HTTPS endpoint where data will be sent
-=== Usage
+=== Logging In
-This Kamelet forwards data to HTTP or HTTPS endpoints without authentication.
For secured endpoints requiring authentication, use the HTTP Secured Sink
Kamelet instead.
+The login options are all optional. Without them, the requests are sent
without a login.
+
+[width="100%",cols="2,3,3",options="header"]
+|===
+| Login | Options | When the credentials are sent
+| Basic or Digest
+| `authUsername`, `authPassword`
+| After the service answers 401 and asks for them. With
`authenticationPreemptive: true`, Basic credentials are sent with the first
request.
+| Static token, such as an API key
+| `authMethod: Bearer`, `authBearerToken`
+| After the service answers 401 with a `WWW-Authenticate: Bearer` header. With
`authenticationPreemptive: true`, with the first request, which most APIs need.
+| OAuth 2.0 client credentials
+| `oauth2ClientId`, `oauth2ClientSecret`, `oauth2TokenEndpoint`, optionally
`oauth2Scope`
+| With every request: the Kamelet gets a token from `oauth2TokenEndpoint` and
sends it as a Bearer token.
+|===
+
+For example, to call an API that takes a static token:
+
+[source,yaml]
+----
+- route:
+ from:
+ uri: "kamelet:timer-source"
+ parameters:
+ message: '{"status": "ok"}'
+ steps:
+ - to:
+ uri: "kamelet:http-sink"
+ parameters:
+ url: "https://api.example.com/v1/events"
+ authMethod: Bearer
+ authBearerToken: "{{api.token}}"
+ authenticationPreemptive: true
+----
+
+The token is sent as the header `Authorization: Bearer` followed by the token.
+
+=== Status Codes That Do Not Fail
+
+A response with a status code outside `okStatusCodeRange` fails the message.
When the option is not set, it is `200-299`, so a status code of 300 or higher
fails the message. Some APIs answer a normal case with another code, such as
404 when a record does not exist, or 409 when it exists already. List those
codes together with the 2xx codes:
+
+[source,yaml]
+----
+- to:
+ uri: "kamelet:http-sink"
+ parameters:
+ url: "https://api.example.com/v1/customers"
+ okStatusCodeRange: "200-299,409"
+----
+
+The response code is then in the `CamelHttpResponseCode` header, and the body
is the response of the service. Setting only `409` would make a 200 response
fail.
+
+=== Trusting a Private Certificate Authority
+
+The certificate of an `https://` service is checked against the certificate
authorities that Java trusts. A service whose certificate is signed by a
private certificate authority fails with `PKIX path building failed`.
+
+With Camel JBang or Camel Main, put the certificate of the authority in a
trust store, for example with `keytool -importcert -file ca.crt -keystore
truststore.p12 -storetype PKCS12`, and set these application properties:
+
+[source,properties]
+----
+camel.ssl.enabled = true
+camel.ssl.trustStore = file:/etc/certs/truststore.p12
+camel.ssl.trustStorePassword = changeit
+camel.component.https.useGlobalSslContextParameters = true
+----
+
+That trust store then replaces the one of Java for every `https://` call of
the application, so it must also hold the authorities of any public service the
application calls. The `http://` calls are not changed.
=== Headers
-The Kamelet automatically sets the HTTP method header and removes any existing
CamelHttpUri header to prevent conflicts.
\ No newline at end of file
+The Kamelet sets the HTTP method from the `method` option, and removes the
headers that could change where the message is sent, such as `CamelHttpUri`.
The other headers of the message are sent as HTTP headers.
diff --git a/docs/modules/ROOT/partials/http-source-description.adoc
b/docs/modules/ROOT/partials/http-source-description.adoc
index f3320e1f7..7655c6eca 100644
--- a/docs/modules/ROOT/partials/http-source-description.adoc
+++ b/docs/modules/ROOT/partials/http-source-description.adoc
@@ -8,9 +8,23 @@ The HTTP Source Kamelet periodically fetches data from an HTTP
endpoint. It supp
- **Period**: The interval between fetches in milliseconds (default: 10000)
- **Content Type**: The Accept header content type for the request (default:
"application/json")
-=== Authentication
-
-This is the basic HTTP source kamelet without authentication. For secured HTTP
endpoints requiring authentication, use the HTTP Secured Source kamelet instead.
+=== Logging In
+
+The login options are all optional. Without them, the requests are sent
without a login.
+
+[width="100%",cols="2,3,3",options="header"]
+|===
+| Login | Options | When the credentials are sent
+| Basic or Digest
+| `authUsername`, `authPassword`
+| After the service answers 401 and asks for them. With
`authenticationPreemptive: true`, Basic credentials are sent with the first
request.
+| Static token, such as an API key
+| `authMethod: Bearer`, `authBearerToken`
+| After the service answers 401 with a `WWW-Authenticate: Bearer` header. With
`authenticationPreemptive: true`, with the first request, which most APIs need.
+| OAuth 2.0 client credentials
+| `oauth2ClientId`, `oauth2ClientSecret`, `oauth2TokenEndpoint`, optionally
`oauth2Scope`
+| With every request: the Kamelet gets a token from `oauth2TokenEndpoint` and
sends it as a Bearer token.
+|===
=== Output Format
@@ -66,6 +80,61 @@ The Kamelet outputs the HTTP response body and preserves any
HTTP headers from t
This example polls the endpoint every 5 seconds for status updates.
+=== Example with a Static Token
+
+[source,yaml]
+----
+- route:
+ from:
+ uri: "kamelet:http-source"
+ parameters:
+ url: "https://api.example.com/v1/orders/status"
+ period: 60000
+ authMethod: Bearer
+ authBearerToken: "{{api.token}}"
+ authenticationPreemptive: true
+ steps:
+ - to:
+ uri: "kamelet:log-sink"
+----
+
+The token is sent as the header `Authorization: Bearer` followed by the token.
+
+=== Status Codes That Send a Message
+
+Only a response with a status code in `okStatusCodeRange` is sent as a
message. When the option is not set, it is `200-299`: a response with a status
code of 300 or higher sends no message, the error is logged, and the address is
fetched again at the next period. To also receive the responses with another
code, such as 404 while a resource does not exist yet, list it together with
the 2xx codes:
+
+[source,yaml]
+----
+- route:
+ from:
+ uri: "kamelet:http-source"
+ parameters:
+ url: "https://api.example.com/v1/reports/today"
+ okStatusCodeRange: "200-299,404"
+ steps:
+ - to:
+ uri: "kamelet:log-sink"
+----
+
+The `CamelHttpResponseCode` header of the message then tells a 404 from a 200.
Setting only `404` would stop the 200 responses.
+
+=== Trusting a Private Certificate Authority
+
+The certificate of an `https://` service is checked against the certificate
authorities that Java trusts. A service whose certificate is signed by a
private certificate authority fails with `PKIX path building failed`.
+
+With Camel JBang or Camel Main, put the certificate of the authority in a
trust store, for example with `keytool -importcert -file ca.crt -keystore
truststore.p12 -storetype PKCS12`, and set these application properties:
+
+[source,properties]
+----
+camel.ssl.enabled = true
+camel.ssl.trustStore = file:/etc/certs/truststore.p12
+camel.ssl.trustStorePassword = changeit
+camel.component.https.useGlobalSslContextParameters = true
+----
+
+That trust store then replaces the one of Java for every `https://` call of
the application, so it must also hold the authorities of any public service the
application calls. The `http://` calls are not changed.
+
=== Scheduling Behavior
The kamelet uses a timer to periodically fetch data from the specified URL.
The timer starts immediately when the route starts and repeats at the
configured interval. Each request includes the specified Accept header to
indicate the expected content type.
\ No newline at end of file
diff --git a/kamelets/http-sink.kamelet.yaml b/kamelets/http-sink.kamelet.yaml
index 742fcb171..99a0abc90 100644
--- a/kamelets/http-sink.kamelet.yaml
+++ b/kamelets/http-sink.kamelet.yaml
@@ -39,7 +39,7 @@ spec:
Output: when it is used inside a route, the body afterwards is the
response of the service.
- Good to know: a response with a status code of 300 or higher fails the
message. The address and the method come only from the options; headers on the
message cannot change where it is sent. Log in either with `authUsername` and
`authPassword`, or with `oauth2ClientId`, `oauth2ClientSecret` and
`oauth2TokenEndpoint`: the Kamelet then gets a token from that URL and sends it
as a Bearer token. Without `authenticationPreemptive`, the user and password
are sent only after the service as [...]
+ Good to know: a response with a status code outside `okStatusCodeRange`,
which is `200-299` when it is not set, fails the message. The address and the
method come only from the options; headers on the message cannot change where
it is sent. Log in either with `authUsername` and `authPassword`, with a static
token in `authBearerToken`, or with `oauth2ClientId`, `oauth2ClientSecret` and
`oauth2TokenEndpoint`: the Kamelet then gets a token from that URL and sends it
as a Bearer token. [...]
required:
- url
type: object
@@ -56,14 +56,20 @@ spec:
type: string
default: POST
enum: ["GET", "POST", "PUT", "DELETE", "HEAD", "OPTIONS", "TRACE",
"PATCH"]
+ okStatusCodeRange:
+ title: OK Status Codes
+ description: The status codes of a response that do not fail the
message, as ranges such as `200-299` and single codes, separated by commas
without spaces. When it is not set, it is `200-299`. List the 2xx codes too,
for example `200-299,404` to also accept 404.
+ type: string
+ example: "200-299,404"
+ pattern: "^[0-9]{3}(-[0-9]{3})?(,[0-9]{3}(-[0-9]{3})?)*$"
authMethod:
title: Authentication Method
- description: The login methods to allow when the service asks for a
login, as a comma-separated list of `Basic`, `Digest` and `NTLM`. Basic login
with `authUsername` and `authPassword` works without it.
+ description: The login method, `Basic`, `Digest`, `NTLM`, or `Bearer`
to send `authBearerToken`. Basic and Digest login with `authUsername` and
`authPassword` work without it.
type: string
example: Basic
authenticationPreemptive:
title: Authentication Preemptive
- description: If true, `authUsername` and `authPassword` are sent with
Basic login on the first request. If false, they are sent only after the
service answers 401 and asks for them, which takes a second request.
+ description: If true, `authUsername` and `authPassword` are sent with
Basic login, or `authBearerToken` as a Bearer token, on the first request. If
false, they are sent only after the service answers 401 and asks for them,
which takes a second request.
type: boolean
default: false
authUsername:
@@ -79,6 +85,13 @@ spec:
format: password
x-descriptors:
- urn:camel:group:credentials
+ authBearerToken:
+ title: Bearer Token
+ description: A static token, such as an API key, sent in the
`Authorization` header as `Bearer` followed by the token. Set `authMethod` to
`Bearer` with it. Also set `authenticationPreemptive` to true, unless the
service first answers 401 with a `WWW-Authenticate` header that asks for a
Bearer token.
+ type: string
+ format: password
+ x-descriptors:
+ - urn:camel:group:credentials
oauth2ClientId:
title: OAuth2 Client ID
description: The client ID of the application, as registered with the
OAuth 2.0 provider. With `oauth2ClientSecret`, it is used to get a token from
`oauth2TokenEndpoint` (client credentials grant).
@@ -137,8 +150,10 @@ spec:
authMethod: "{{?authMethod}}"
authUsername: "{{?authUsername}}"
authPassword: "{{?authPassword}}"
+ authBearerToken: "RAW({{?authBearerToken}})"
oauth2ClientId: "{{?oauth2ClientId}}"
oauth2ClientSecret: "{{?oauth2ClientSecret}}"
oauth2Scope: "{{?oauth2Scope}}"
oauth2TokenEndpoint: "{{?oauth2TokenEndpoint}}"
authenticationPreemptive: "{{authenticationPreemptive}}"
+ okStatusCodeRange: "{{?okStatusCodeRange}}"
diff --git a/kamelets/http-source.kamelet.yaml
b/kamelets/http-source.kamelet.yaml
index 82379d633..e163af3d1 100644
--- a/kamelets/http-source.kamelet.yaml
+++ b/kamelets/http-source.kamelet.yaml
@@ -37,7 +37,7 @@ spec:
Output: the body is the body of the response, as bytes. The headers of
the response, such as `Content-Type`, are copied to the message, and
`CamelHttpResponseCode` holds the status code.
- Good to know: it fetches the address every `period` and sends a message
for each response, even when the data has not changed. A response with a status
code of 300 or higher sends no message: the error is logged, and the address is
fetched again at the next period. Log in either with `authUsername` and
`authPassword`, or with `oauth2ClientId`, `oauth2ClientSecret` and
`oauth2TokenEndpoint`: the Kamelet then gets a token from that URL and sends it
as a Bearer token.
+ Good to know: it fetches the address every `period` and sends a message
for each response, even when the data has not changed. A response with a status
code outside `okStatusCodeRange`, which is `200-299` when it is not set, sends
no message: the error is logged, and the address is fetched again at the next
period. Log in either with `authUsername` and `authPassword`, with a static
token in `authBearerToken`, or with `oauth2ClientId`, `oauth2ClientSecret` and
`oauth2TokenEndpoint`: [...]
required:
- url
type: object
@@ -60,14 +60,20 @@ spec:
type: string
example: "https://api.example.com/v1/orders/status"
pattern: "^(http|https)://.*"
+ okStatusCodeRange:
+ title: OK Status Codes
+ description: The status codes of a response that is sent as a message,
as ranges such as `200-299` and single codes, separated by commas without
spaces. When it is not set, it is `200-299`. List the 2xx codes too, for
example `200-299,404` to also send the 404 responses.
+ type: string
+ example: "200-299,404"
+ pattern: "^[0-9]{3}(-[0-9]{3})?(,[0-9]{3}(-[0-9]{3})?)*$"
authMethod:
title: Authentication Method
- description: The login methods to allow when the service asks for a
login, as a comma-separated list of `Basic`, `Digest` and `NTLM`. Basic login
with `authUsername` and `authPassword` works without it.
+ description: The login method, `Basic`, `Digest`, `NTLM`, or `Bearer`
to send `authBearerToken`. Basic and Digest login with `authUsername` and
`authPassword` work without it.
type: string
example: Basic
authenticationPreemptive:
title: Authentication Preemptive
- description: If true, `authUsername` and `authPassword` are sent with
Basic login on the first request. If false, they are sent only after the
service answers 401 and asks for them, which takes a second request.
+ description: If true, `authUsername` and `authPassword` are sent with
Basic login, or `authBearerToken` as a Bearer token, on the first request. If
false, they are sent only after the service answers 401 and asks for them,
which takes a second request.
type: boolean
default: false
authUsername:
@@ -83,6 +89,13 @@ spec:
format: password
x-descriptors:
- urn:camel:group:credentials
+ authBearerToken:
+ title: Bearer Token
+ description: A static token, such as an API key, sent in the
`Authorization` header as `Bearer` followed by the token. Set `authMethod` to
`Bearer` with it. Also set `authenticationPreemptive` to true, unless the
service first answers 401 with a `WWW-Authenticate` header that asks for a
Bearer token.
+ type: string
+ format: password
+ x-descriptors:
+ - urn:camel:group:credentials
oauth2ClientId:
title: OAuth2 Client ID
description: The client ID of the application, as registered with the
OAuth 2.0 provider. With `oauth2ClientSecret`, it is used to get a token from
`oauth2TokenEndpoint` (client credentials grant).
@@ -144,10 +157,12 @@ spec:
authMethod: "{{?authMethod}}"
authUsername: "{{?authUsername}}"
authPassword: "{{?authPassword}}"
+ authBearerToken: "RAW({{?authBearerToken}})"
oauth2ClientId: "{{?oauth2ClientId}}"
oauth2ClientSecret: "{{?oauth2ClientSecret}}"
oauth2Scope: "{{?oauth2Scope}}"
oauth2TokenEndpoint: "{{?oauth2TokenEndpoint}}"
authenticationPreemptive: "{{authenticationPreemptive}}"
+ okStatusCodeRange: "{{?okStatusCodeRange}}"
- to:
uri: kamelet:sink
diff --git
a/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
b/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
index b3d7279fb..e6fd303ff 100644
--- a/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
+++ b/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
@@ -1025,7 +1025,7 @@
"supportLevel" : "Stable",
"title" : "HTTP Sink",
"summary" : "Sends each message to a web service or REST API as an HTTP or
HTTPS request, for example a POST of JSON to a webhook.",
- "description" : "Sends each message to a web service or REST API as an
HTTP or HTTPS request, for example a POST of JSON to a webhook.\n\nUse it to
push data to any service that accepts HTTP calls, such as a webhook, a REST API
or a serverless function.\n\nInput: the body is sent as the request body, as
text, bytes or a stream. Turn structured data such as a Map into JSON text
first, for example with `json-serialize-action`. The `Content-Type` header is
sent as the content type of th [...]
+ "description" : "Sends each message to a web service or REST API as an
HTTP or HTTPS request, for example a POST of JSON to a webhook.\n\nUse it to
push data to any service that accepts HTTP calls, such as a webhook, a REST API
or a serverless function.\n\nInput: the body is sent as the request body, as
text, bytes or a stream. Turn structured data such as a Map into JSON text
first, for example with `json-serialize-action`. The `Content-Type` header is
sent as the content type of th [...]
"group" : "HTTP",
"namespace" : "HTTP",
"provider" : "Apache Software Foundation"
@@ -1035,7 +1035,7 @@
"supportLevel" : "Stable",
"title" : "HTTP Source",
"summary" : "Fetches a web address with an HTTP GET request at a regular
interval, and sends each response as a message.",
- "description" : "Fetches a web address with an HTTP GET request at a
regular interval, and sends each response as a message.\n\nUse it to poll a
REST API, a feed or a status page for its current data, for example fetch the
state of the orders every minute. To receive the requests that other systems
send instead, use `webhook-source`.\n\nOutput: the body is the body of the
response, as bytes. The headers of the response, such as `Content-Type`, are
copied to the message, and `CamelHtt [...]
+ "description" : "Fetches a web address with an HTTP GET request at a
regular interval, and sends each response as a message.\n\nUse it to poll a
REST API, a feed or a status page for its current data, for example fetch the
state of the orders every minute. To receive the requests that other systems
send instead, use `webhook-source`.\n\nOutput: the body is the body of the
response, as bytes. The headers of the response, such as `Content-Type`, are
copied to the message, and `CamelHtt [...]
"group" : "HTTP",
"namespace" : "HTTP",
"provider" : "Apache Software Foundation"
diff --git
a/library/camel-kamelets/src/main/resources/kamelets/http-sink.kamelet.yaml
b/library/camel-kamelets/src/main/resources/kamelets/http-sink.kamelet.yaml
index 742fcb171..99a0abc90 100644
--- a/library/camel-kamelets/src/main/resources/kamelets/http-sink.kamelet.yaml
+++ b/library/camel-kamelets/src/main/resources/kamelets/http-sink.kamelet.yaml
@@ -39,7 +39,7 @@ spec:
Output: when it is used inside a route, the body afterwards is the
response of the service.
- Good to know: a response with a status code of 300 or higher fails the
message. The address and the method come only from the options; headers on the
message cannot change where it is sent. Log in either with `authUsername` and
`authPassword`, or with `oauth2ClientId`, `oauth2ClientSecret` and
`oauth2TokenEndpoint`: the Kamelet then gets a token from that URL and sends it
as a Bearer token. Without `authenticationPreemptive`, the user and password
are sent only after the service as [...]
+ Good to know: a response with a status code outside `okStatusCodeRange`,
which is `200-299` when it is not set, fails the message. The address and the
method come only from the options; headers on the message cannot change where
it is sent. Log in either with `authUsername` and `authPassword`, with a static
token in `authBearerToken`, or with `oauth2ClientId`, `oauth2ClientSecret` and
`oauth2TokenEndpoint`: the Kamelet then gets a token from that URL and sends it
as a Bearer token. [...]
required:
- url
type: object
@@ -56,14 +56,20 @@ spec:
type: string
default: POST
enum: ["GET", "POST", "PUT", "DELETE", "HEAD", "OPTIONS", "TRACE",
"PATCH"]
+ okStatusCodeRange:
+ title: OK Status Codes
+ description: The status codes of a response that do not fail the
message, as ranges such as `200-299` and single codes, separated by commas
without spaces. When it is not set, it is `200-299`. List the 2xx codes too,
for example `200-299,404` to also accept 404.
+ type: string
+ example: "200-299,404"
+ pattern: "^[0-9]{3}(-[0-9]{3})?(,[0-9]{3}(-[0-9]{3})?)*$"
authMethod:
title: Authentication Method
- description: The login methods to allow when the service asks for a
login, as a comma-separated list of `Basic`, `Digest` and `NTLM`. Basic login
with `authUsername` and `authPassword` works without it.
+ description: The login method, `Basic`, `Digest`, `NTLM`, or `Bearer`
to send `authBearerToken`. Basic and Digest login with `authUsername` and
`authPassword` work without it.
type: string
example: Basic
authenticationPreemptive:
title: Authentication Preemptive
- description: If true, `authUsername` and `authPassword` are sent with
Basic login on the first request. If false, they are sent only after the
service answers 401 and asks for them, which takes a second request.
+ description: If true, `authUsername` and `authPassword` are sent with
Basic login, or `authBearerToken` as a Bearer token, on the first request. If
false, they are sent only after the service answers 401 and asks for them,
which takes a second request.
type: boolean
default: false
authUsername:
@@ -79,6 +85,13 @@ spec:
format: password
x-descriptors:
- urn:camel:group:credentials
+ authBearerToken:
+ title: Bearer Token
+ description: A static token, such as an API key, sent in the
`Authorization` header as `Bearer` followed by the token. Set `authMethod` to
`Bearer` with it. Also set `authenticationPreemptive` to true, unless the
service first answers 401 with a `WWW-Authenticate` header that asks for a
Bearer token.
+ type: string
+ format: password
+ x-descriptors:
+ - urn:camel:group:credentials
oauth2ClientId:
title: OAuth2 Client ID
description: The client ID of the application, as registered with the
OAuth 2.0 provider. With `oauth2ClientSecret`, it is used to get a token from
`oauth2TokenEndpoint` (client credentials grant).
@@ -137,8 +150,10 @@ spec:
authMethod: "{{?authMethod}}"
authUsername: "{{?authUsername}}"
authPassword: "{{?authPassword}}"
+ authBearerToken: "RAW({{?authBearerToken}})"
oauth2ClientId: "{{?oauth2ClientId}}"
oauth2ClientSecret: "{{?oauth2ClientSecret}}"
oauth2Scope: "{{?oauth2Scope}}"
oauth2TokenEndpoint: "{{?oauth2TokenEndpoint}}"
authenticationPreemptive: "{{authenticationPreemptive}}"
+ okStatusCodeRange: "{{?okStatusCodeRange}}"
diff --git
a/library/camel-kamelets/src/main/resources/kamelets/http-source.kamelet.yaml
b/library/camel-kamelets/src/main/resources/kamelets/http-source.kamelet.yaml
index 82379d633..e163af3d1 100644
---
a/library/camel-kamelets/src/main/resources/kamelets/http-source.kamelet.yaml
+++
b/library/camel-kamelets/src/main/resources/kamelets/http-source.kamelet.yaml
@@ -37,7 +37,7 @@ spec:
Output: the body is the body of the response, as bytes. The headers of
the response, such as `Content-Type`, are copied to the message, and
`CamelHttpResponseCode` holds the status code.
- Good to know: it fetches the address every `period` and sends a message
for each response, even when the data has not changed. A response with a status
code of 300 or higher sends no message: the error is logged, and the address is
fetched again at the next period. Log in either with `authUsername` and
`authPassword`, or with `oauth2ClientId`, `oauth2ClientSecret` and
`oauth2TokenEndpoint`: the Kamelet then gets a token from that URL and sends it
as a Bearer token.
+ Good to know: it fetches the address every `period` and sends a message
for each response, even when the data has not changed. A response with a status
code outside `okStatusCodeRange`, which is `200-299` when it is not set, sends
no message: the error is logged, and the address is fetched again at the next
period. Log in either with `authUsername` and `authPassword`, with a static
token in `authBearerToken`, or with `oauth2ClientId`, `oauth2ClientSecret` and
`oauth2TokenEndpoint`: [...]
required:
- url
type: object
@@ -60,14 +60,20 @@ spec:
type: string
example: "https://api.example.com/v1/orders/status"
pattern: "^(http|https)://.*"
+ okStatusCodeRange:
+ title: OK Status Codes
+ description: The status codes of a response that is sent as a message,
as ranges such as `200-299` and single codes, separated by commas without
spaces. When it is not set, it is `200-299`. List the 2xx codes too, for
example `200-299,404` to also send the 404 responses.
+ type: string
+ example: "200-299,404"
+ pattern: "^[0-9]{3}(-[0-9]{3})?(,[0-9]{3}(-[0-9]{3})?)*$"
authMethod:
title: Authentication Method
- description: The login methods to allow when the service asks for a
login, as a comma-separated list of `Basic`, `Digest` and `NTLM`. Basic login
with `authUsername` and `authPassword` works without it.
+ description: The login method, `Basic`, `Digest`, `NTLM`, or `Bearer`
to send `authBearerToken`. Basic and Digest login with `authUsername` and
`authPassword` work without it.
type: string
example: Basic
authenticationPreemptive:
title: Authentication Preemptive
- description: If true, `authUsername` and `authPassword` are sent with
Basic login on the first request. If false, they are sent only after the
service answers 401 and asks for them, which takes a second request.
+ description: If true, `authUsername` and `authPassword` are sent with
Basic login, or `authBearerToken` as a Bearer token, on the first request. If
false, they are sent only after the service answers 401 and asks for them,
which takes a second request.
type: boolean
default: false
authUsername:
@@ -83,6 +89,13 @@ spec:
format: password
x-descriptors:
- urn:camel:group:credentials
+ authBearerToken:
+ title: Bearer Token
+ description: A static token, such as an API key, sent in the
`Authorization` header as `Bearer` followed by the token. Set `authMethod` to
`Bearer` with it. Also set `authenticationPreemptive` to true, unless the
service first answers 401 with a `WWW-Authenticate` header that asks for a
Bearer token.
+ type: string
+ format: password
+ x-descriptors:
+ - urn:camel:group:credentials
oauth2ClientId:
title: OAuth2 Client ID
description: The client ID of the application, as registered with the
OAuth 2.0 provider. With `oauth2ClientSecret`, it is used to get a token from
`oauth2TokenEndpoint` (client credentials grant).
@@ -144,10 +157,12 @@ spec:
authMethod: "{{?authMethod}}"
authUsername: "{{?authUsername}}"
authPassword: "{{?authPassword}}"
+ authBearerToken: "RAW({{?authBearerToken}})"
oauth2ClientId: "{{?oauth2ClientId}}"
oauth2ClientSecret: "{{?oauth2ClientSecret}}"
oauth2Scope: "{{?oauth2Scope}}"
oauth2TokenEndpoint: "{{?oauth2TokenEndpoint}}"
authenticationPreemptive: "{{authenticationPreemptive}}"
+ okStatusCodeRange: "{{?okStatusCodeRange}}"
- to:
uri: kamelet:sink