This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 4bb399745a45 CAMEL-17951: camel-platform-http-main - configure CORS,
sessions and body handler flags with camel.server.* keys (#30884)
4bb399745a45 is described below
commit 4bb399745a45f87eef9209db6eb6dfdf2bd02f47
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu Nov 26 19:14:31 2026 +0100
CAMEL-17951: camel-platform-http-main - configure CORS, sessions and body
handler flags with camel.server.* keys (#30884)
The Vert.x server behind camel.server.* had CORS, session and some body
handler settings, but they could only be set in Java code on
VertxPlatformHttpServerConfiguration. They are now Camel Main options, so
they can be set in application.properties, as environment variables and
with the Camel CLI:
- camel.server.corsEnabled, corsOrigins, corsMethods, corsHeaders,
corsExposedHeaders, corsAccessControlMaxAge
- camel.server.sessionEnabled, sessionStoreType, sessionCookieName,
sessionCookiePath, sessionTimeout, sessionCookieSecure,
sessionCookieHttpOnly, sessionCookieSameSite, sessionIdMinLength
- camel.server.mergeFormAttributes, deleteUploadedFilesOnEnd,
preallocateBodyBuffer
The names follow the flat style of the other camel.server options
(authentication*, jwt*, mcp*, static*). The session cookie is HttpOnly by
default.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Claus Ibsen <[email protected]>
---
.../org/apache/camel/catalog/docs/main.adoc | 20 +-
.../camel/catalog/docs/platform-http-main.adoc | 46 +++
.../main/camel-main-configuration-metadata.json | 18 +
.../src/main/docs/platform-http-main.adoc | 46 +++
.../http/main/DefaultMainHttpServerFactory.java | 72 ++++
.../main/DefaultMainHttpServerFactoryTest.java | 155 ++++++++
.../http/main/MainHttpServerCorsSessionTest.java | 144 ++++++++
...ttpServerConfigurationPropertiesConfigurer.java | 126 +++++++
.../camel-main-configuration-metadata.json | 18 +
.../org/apache/camel/main/main-options.properties | 18 +
core/camel-main/src/main/docs/main.adoc | 20 +-
.../main/HttpServerConfigurationProperties.java | 394 +++++++++++++++++++++
12 files changed, 1075 insertions(+), 2 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/main.adoc
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/main.adoc
index b4e0df816141..cf281340147f 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/main.adoc
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/main.adoc
@@ -197,7 +197,7 @@ The camel.routecontroller supports 12 options, which are
listed below.
=== Camel Embedded HTTP Server (only for standalone; not Spring Boot or
Quarkus) configurations
-The camel.server supports 43 options, which are listed below.
+The camel.server supports 61 options, which are listed below.
[width="100%",cols="2,5,^1,2",options="header"]
|===
@@ -206,6 +206,13 @@ The camel.server supports 43 options, which are listed
below.
| `camel.server.authenticationPath` | Set HTTP url path of embedded server
that is protected by authentication configuration. | | String
| `camel.server.authenticationRealm` | Sets the authentication realm | |
String
| `camel.server.basicPropertiesFile` | Name of the file that contains basic
authentication info for Vert.x file auth provider. | | String
+| `camel.server.corsAccessControlMaxAge` | How long (in seconds) a browser may
cache the answer of a preflight request, sent as the Access-Control-Max-Age
header. When not set, the header is not sent. | | Long
+| `camel.server.corsEnabled` | Whether the embedded HTTP server handles CORS
(Cross-Origin Resource Sharing): it answers preflight requests and adds the
Access-Control-* headers to the responses of requests with an Origin header. |
false | boolean
+| `camel.server.corsExposedHeaders` | Comma-separated list of the HTTP
response headers a browser may expose to the calling script, sent as the
Access-Control-Expose-Headers header. | | String
+| `camel.server.corsHeaders` | Comma-separated list of the HTTP headers
allowed in a CORS request. When not set, the headers of the
Access-Control-Request-Headers header of the preflight request are allowed. |
| String
+| `camel.server.corsMethods` | Comma-separated list of the HTTP methods (such
as GET,POST) allowed in a CORS request. When not set, the methods of the
Access-Control-Request-Method header of the preflight request are allowed. | |
String
+| `camel.server.corsOrigins` | Comma-separated list of origins (such as
\https://app.example.com) allowed to call the embedded HTTP server. A request
from an origin in the list is answered with Access-Control-Allow-Origin and
Access-Control-Allow-Credentials=true. When not set, the origin of every
request is allowed (reflected back), without credentials. | | String
+| `camel.server.deleteUploadedFilesOnEnd` | Whether the uploaded files are
deleted from the file upload directory when the response has been sent. | true
| boolean
| `camel.server.enabled` | Whether embedded HTTP server is enabled. By
default, the server is not enabled. | false | boolean
| `camel.server.fileUploadDirectory` | Directory to temporary store file
uploads while Camel routes the incoming request. If no directory has been
explicit configured, then a temporary directory is created in the
java.io.tmpdir directory. | | String
| `camel.server.fileUploadEnabled` | Whether to enable file uploads being
supported (such as POST multipart/form-data) and stored into a temporary
directory. | true | boolean
@@ -239,8 +246,19 @@ The camel.server supports 43 options, which are listed
below.
| `camel.server.mcpTags` | Comma-separated list of tag patterns selecting
ai-tool routes as MCP tools, ai-resource routes as MCP resources and ai-prompt
routes as MCP prompts. Matching is case-insensitive and supports exact match,
wildcard prefix ( foo* ), and * to match all tags. Only routes registered under
a matching tag are exposed; the untagged default pools are never exposed. When
not set, nothing is exposed. | | String
| `camel.server.mcpToolTimeout` | Per-call MCP tool execution timeout in
milliseconds. A call exceeding the timeout returns an error result to the MCP
client; the underlying route keeps running until it completes on its own. |
20000 | long
| `camel.server.mcpTransport` | MCP transport selection: http (streamable HTTP
on the embedded server, serving tools, resources and prompts) or stdio
(JSON-RPC on process stdin/stdout for local agent subprocesses, serving tools
and prompts only). | http | String
+| `camel.server.mergeFormAttributes` | Whether the form attributes of a
request (application/x-www-form-urlencoded or multipart/form-data) are merged
into the request parameters. | true | boolean
| `camel.server.path` | Context-path to use for embedded HTTP server | / |
String
| `camel.server.port` | Port to use for binding embedded HTTP server. Use 0 to
dynamic assign a free random port number. | 8080 | int
+| `camel.server.preallocateBodyBuffer` | Whether the buffer for the request
body is pre-allocated, using the Content-Length header of the request to size
it. | true | boolean
+| `camel.server.sessionCookieHttpOnly` | Whether the session cookie has the
HttpOnly flag, so scripts in the browser cannot read it. | true | boolean
+| `camel.server.sessionCookieName` | The name of the session cookie. |
vertx-web.session | String
+| `camel.server.sessionCookiePath` | The path of the session cookie. | / |
String
+| `camel.server.sessionCookieSameSite` | The SameSite attribute of the session
cookie: strict, lax or none. | strict | String
+| `camel.server.sessionCookieSecure` | Whether the session cookie has the
Secure flag, so browsers only send it over HTTPS. | false | boolean
+| `camel.server.sessionEnabled` | Whether the embedded HTTP server keeps a
session for each client, identified by a session cookie. | false | boolean
+| `camel.server.sessionIdMinLength` | The minimum length of the session id. |
16 | int
+| `camel.server.sessionStoreType` | Where the sessions are stored: local (in
memory of this application) or clustered (in the cluster of a clustered Vert.x
instance, which must be provided in the registry). | local | String
+| `camel.server.sessionTimeout` | The time in milliseconds after which a
session without activity expires. | 1800000 | long
| `camel.server.staticContextPath` | The context-path to use for serving
static content. By default, the root path is used. And if there is an
index.html page then this is automatically loaded. | / | String
| `camel.server.staticEnabled` | Whether serving static files is enabled. If
enabled then Camel can host html/js and other web files that makes it possible
to include small web applications. | false | boolean
| `camel.server.staticSourceDir` | Additional directory that holds static
content when static is enabled. | | String
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/platform-http-main.adoc
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/platform-http-main.adoc
index 42a5c2fc947e..0823589d1ffe 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/platform-http-main.adoc
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/platform-http-main.adoc
@@ -102,6 +102,52 @@ camel.management.host=127.0.0.1
camel.management.healthCheckEnabled=true
----
+== CORS
+
+The embedded HTTP server can handle CORS (Cross-Origin Resource Sharing), so a
web application served from another origin
+can call the routes from a browser. When enabled, the server answers preflight
requests (`OPTIONS` with an `Origin` header)
+itself, and adds the `Access-Control-*` headers to the responses of the other
requests with an `Origin` header.
+
+[source,properties]
+----
+camel.server.enabled=true
+camel.server.corsEnabled=true
+camel.server.corsOrigins=https://app.example.com,https://admin.example.com
+camel.server.corsMethods=GET,POST,PUT
+camel.server.corsHeaders=Content-Type,X-Request-Id
+camel.server.corsExposedHeaders=X-Total-Count
+camel.server.corsAccessControlMaxAge=3600
+----
+
+A request from an origin in `corsOrigins` is answered with
`Access-Control-Allow-Origin` set to that origin, and
+`Access-Control-Allow-Credentials=true`. A request from another origin gets no
`Access-Control-Allow-Origin` header, so
+the browser blocks the response. When `corsOrigins` is not set, the origin of
every request is allowed (sent back
+as `Access-Control-Allow-Origin`), but without credentials. Set `corsOrigins`
for anything other than a public API.
+
+When `corsMethods` or `corsHeaders` is not set, the methods and headers asked
for in the preflight request are allowed.
+`corsAccessControlMaxAge` is in seconds; when not set, the
`Access-Control-Max-Age` header is not sent.
+
+== Sessions
+
+The embedded HTTP server can keep a session for each client, identified by a
session cookie (Vert.x `SessionHandler`):
+
+[source,properties]
+----
+camel.server.enabled=true
+camel.server.sessionEnabled=true
+camel.server.sessionCookieName=my-session
+camel.server.sessionCookieSecure=true
+camel.server.sessionCookieSameSite=lax
+camel.server.sessionTimeout=600000
+----
+
+The session cookie is `HttpOnly` and `SameSite=Strict` by default. Set
`sessionCookieSecure=true` when the server is
+served over HTTPS (or behind a proxy that terminates TLS), so the browser only
sends the cookie over HTTPS.
+The sessions are stored in the memory of the application
(`sessionStoreType=local`). Use `sessionStoreType=clustered`
+to store them in the cluster of a clustered Vert.x instance, which you must
then bind in the registry.
+
+All the `camel.server.*` options are listed in
xref:components:others:main.adoc[Camel Main].
+
== JWT authentication
The embedded HTTP server can validate JWT bearer tokens on incoming requests.
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
index fcb1616865d5..2951850dc1cf 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
@@ -457,6 +457,13 @@
{ "name": "camel.server.authenticationPath", "required": false,
"description": "Set HTTP url path of embedded server that is protected by
authentication configuration.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "string",
"javaType": "java.lang.String", "secret": false },
{ "name": "camel.server.authenticationRealm", "required": false,
"description": "Sets the authentication realm", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "string",
"javaType": "java.lang.String", "secret": false },
{ "name": "camel.server.basicPropertiesFile", "required": false,
"description": "Name of the file that contains basic authentication info for
Vert.x file auth provider.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "string",
"javaType": "java.lang.String", "secret": false },
+ { "name": "camel.server.corsAccessControlMaxAge", "required": false,
"description": "How long (in seconds) a browser may cache the answer of a
preflight request, sent as the Access-Control-Max-Age header. When not set, the
header is not sent.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "integer",
"javaType": "java.lang.Long", "secret": false },
+ { "name": "camel.server.corsEnabled", "required": false, "description":
"Whether the embedded HTTP server handles CORS (Cross-Origin Resource Sharing):
it answers preflight requests and adds the Access-Control-* headers to the
responses of requests with an Origin header.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean",
"javaType": "boolean", "defaultValue": false, "secret": false },
+ { "name": "camel.server.corsExposedHeaders", "required": false,
"description": "Comma-separated list of the HTTP response headers a browser may
expose to the calling script, sent as the Access-Control-Expose-Headers
header.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "string",
"javaType": "java.lang.String", "secret": false },
+ { "name": "camel.server.corsHeaders", "required": false, "description":
"Comma-separated list of the HTTP headers allowed in a CORS request. When not
set, the headers of the Access-Control-Request-Headers header of the preflight
request are allowed.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "string",
"javaType": "java.lang.String", "secret": false },
+ { "name": "camel.server.corsMethods", "required": false, "description":
"Comma-separated list of the HTTP methods (such as GET,POST) allowed in a CORS
request. When not set, the methods of the Access-Control-Request-Method header
of the preflight request are allowed.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "string",
"javaType": "java.lang.String", "secret": false },
+ { "name": "camel.server.corsOrigins", "required": false, "description":
"Comma-separated list of origins (such as https:\/\/app.example.com) allowed to
call the embedded HTTP server. A request from an origin in the list is answered
with Access-Control-Allow-Origin and Access-Control-Allow-Credentials=true.
When not set, the origin of every request is allowed (reflected back), without
credentials.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "stri [...]
+ { "name": "camel.server.deleteUploadedFilesOnEnd", "required": false,
"description": "Whether the uploaded files are deleted from the file upload
directory when the response has been sent.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean",
"javaType": "boolean", "defaultValue": true, "secret": false },
{ "name": "camel.server.enabled", "required": false, "description":
"Whether embedded HTTP server is enabled. By default, the server is not
enabled.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean",
"javaType": "boolean", "defaultValue": false, "secret": false },
{ "name": "camel.server.fileUploadDirectory", "required": false,
"description": "Directory to temporary store file uploads while Camel routes
the incoming request. If no directory has been explicit configured, then a
temporary directory is created in the java.io.tmpdir directory.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "string",
"javaType": "java.lang.String", "secret": false },
{ "name": "camel.server.fileUploadEnabled", "required": false,
"description": "Whether to enable file uploads being supported (such as POST
multipart\/form-data) and stored into a temporary directory.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean",
"javaType": "boolean", "defaultValue": true, "secret": false },
@@ -490,8 +497,19 @@
{ "name": "camel.server.mcpTags", "required": false, "description":
"Comma-separated list of tag patterns selecting ai-tool routes as MCP tools,
ai-resource routes as MCP resources and ai-prompt routes as MCP prompts.
Matching is case-insensitive and supports exact match, wildcard prefix ( foo*
), and * to match all tags. Only routes registered under a matching tag are
exposed; the untagged default pools are never exposed. When not set, nothing is
exposed.", "sourceType": "org.apache [...]
{ "name": "camel.server.mcpToolTimeout", "required": false, "description":
"Per-call MCP tool execution timeout in milliseconds. A call exceeding the
timeout returns an error result to the MCP client; the underlying route keeps
running until it completes on its own.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "integer",
"javaType": "long", "defaultValue": 20000, "secret": false },
{ "name": "camel.server.mcpTransport", "required": false, "description":
"MCP transport selection: http (streamable HTTP on the embedded server, serving
tools, resources and prompts) or stdio (JSON-RPC on process stdin\/stdout for
local agent subprocesses, serving tools and prompts only).", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "enum",
"javaType": "java.lang.String", "defaultValue": "http", "secret": false,
"enum": [ "http", "stdio" ] },
+ { "name": "camel.server.mergeFormAttributes", "required": false,
"description": "Whether the form attributes of a request
(application\/x-www-form-urlencoded or multipart\/form-data) are merged into
the request parameters.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean",
"javaType": "boolean", "defaultValue": true, "secret": false },
{ "name": "camel.server.path", "required": false, "description":
"Context-path to use for embedded HTTP server", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "string",
"javaType": "java.lang.String", "defaultValue": "\/", "secret": false },
{ "name": "camel.server.port", "required": false, "description": "Port to
use for binding embedded HTTP server. Use 0 to dynamic assign a free random
port number.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "integer",
"javaType": "int", "defaultValue": 8080, "secret": false },
+ { "name": "camel.server.preallocateBodyBuffer", "required": false,
"description": "Whether the buffer for the request body is pre-allocated, using
the Content-Length header of the request to size it.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean",
"javaType": "boolean", "defaultValue": true, "secret": false },
+ { "name": "camel.server.sessionCookieHttpOnly", "required": false,
"description": "Whether the session cookie has the HttpOnly flag, so scripts in
the browser cannot read it.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean",
"javaType": "boolean", "defaultValue": true, "secret": false },
+ { "name": "camel.server.sessionCookieName", "required": false,
"description": "The name of the session cookie.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "string",
"javaType": "java.lang.String", "defaultValue": "vertx-web.session", "secret":
false },
+ { "name": "camel.server.sessionCookiePath", "required": false,
"description": "The path of the session cookie.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "string",
"javaType": "java.lang.String", "defaultValue": "\/", "secret": false },
+ { "name": "camel.server.sessionCookieSameSite", "required": false,
"description": "The SameSite attribute of the session cookie: strict, lax or
none.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "enum",
"javaType": "java.lang.String", "defaultValue": "strict", "secret": false,
"enum": [ "strict", "lax", "none" ] },
+ { "name": "camel.server.sessionCookieSecure", "required": false,
"description": "Whether the session cookie has the Secure flag, so browsers
only send it over HTTPS.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean",
"javaType": "boolean", "defaultValue": false, "secret": false },
+ { "name": "camel.server.sessionEnabled", "required": false, "description":
"Whether the embedded HTTP server keeps a session for each client, identified
by a session cookie.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean",
"javaType": "boolean", "defaultValue": false, "secret": false },
+ { "name": "camel.server.sessionIdMinLength", "required": false,
"description": "The minimum length of the session id.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "integer",
"javaType": "int", "defaultValue": 16, "secret": false },
+ { "name": "camel.server.sessionStoreType", "required": false,
"description": "Where the sessions are stored: local (in memory of this
application) or clustered (in the cluster of a clustered Vert.x instance, which
must be provided in the registry).", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "enum",
"javaType": "java.lang.String", "defaultValue": "local", "secret": false,
"enum": [ "local", "clustered" ] },
+ { "name": "camel.server.sessionTimeout", "required": false, "description":
"The time in milliseconds after which a session without activity expires.",
"sourceType": "org.apache.camel.main.HttpServerConfigurationProperties",
"type": "integer", "javaType": "long", "defaultValue": 1800000, "secret": false
},
{ "name": "camel.server.staticContextPath", "required": false,
"description": "The context-path to use for serving static content. By default,
the root path is used. And if there is an index.html page then this is
automatically loaded.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "string",
"javaType": "java.lang.String", "defaultValue": "\/", "secret": false },
{ "name": "camel.server.staticEnabled", "required": false, "description":
"Whether serving static files is enabled. If enabled then Camel can host
html\/js and other web files that makes it possible to include small web
applications.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean",
"javaType": "boolean", "defaultValue": false, "secret": false },
{ "name": "camel.server.staticSourceDir", "required": false,
"description": "Additional directory that holds static content when static is
enabled.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "string",
"javaType": "java.lang.String", "secret": false },
diff --git
a/components/camel-platform-http-main/src/main/docs/platform-http-main.adoc
b/components/camel-platform-http-main/src/main/docs/platform-http-main.adoc
index 42a5c2fc947e..0823589d1ffe 100644
--- a/components/camel-platform-http-main/src/main/docs/platform-http-main.adoc
+++ b/components/camel-platform-http-main/src/main/docs/platform-http-main.adoc
@@ -102,6 +102,52 @@ camel.management.host=127.0.0.1
camel.management.healthCheckEnabled=true
----
+== CORS
+
+The embedded HTTP server can handle CORS (Cross-Origin Resource Sharing), so a
web application served from another origin
+can call the routes from a browser. When enabled, the server answers preflight
requests (`OPTIONS` with an `Origin` header)
+itself, and adds the `Access-Control-*` headers to the responses of the other
requests with an `Origin` header.
+
+[source,properties]
+----
+camel.server.enabled=true
+camel.server.corsEnabled=true
+camel.server.corsOrigins=https://app.example.com,https://admin.example.com
+camel.server.corsMethods=GET,POST,PUT
+camel.server.corsHeaders=Content-Type,X-Request-Id
+camel.server.corsExposedHeaders=X-Total-Count
+camel.server.corsAccessControlMaxAge=3600
+----
+
+A request from an origin in `corsOrigins` is answered with
`Access-Control-Allow-Origin` set to that origin, and
+`Access-Control-Allow-Credentials=true`. A request from another origin gets no
`Access-Control-Allow-Origin` header, so
+the browser blocks the response. When `corsOrigins` is not set, the origin of
every request is allowed (sent back
+as `Access-Control-Allow-Origin`), but without credentials. Set `corsOrigins`
for anything other than a public API.
+
+When `corsMethods` or `corsHeaders` is not set, the methods and headers asked
for in the preflight request are allowed.
+`corsAccessControlMaxAge` is in seconds; when not set, the
`Access-Control-Max-Age` header is not sent.
+
+== Sessions
+
+The embedded HTTP server can keep a session for each client, identified by a
session cookie (Vert.x `SessionHandler`):
+
+[source,properties]
+----
+camel.server.enabled=true
+camel.server.sessionEnabled=true
+camel.server.sessionCookieName=my-session
+camel.server.sessionCookieSecure=true
+camel.server.sessionCookieSameSite=lax
+camel.server.sessionTimeout=600000
+----
+
+The session cookie is `HttpOnly` and `SameSite=Strict` by default. Set
`sessionCookieSecure=true` when the server is
+served over HTTPS (or behind a proxy that terminates TLS), so the browser only
sends the cookie over HTTPS.
+The sessions are stored in the memory of the application
(`sessionStoreType=local`). Use `sessionStoreType=clustered`
+to store them in the cluster of a clustered Vert.x instance, which you must
then bind in the registry.
+
+All the `camel.server.*` options are listed in
xref:components:others:main.adoc[Camel Main].
+
== JWT authentication
The embedded HTTP server can validate JWT bearer tokens on incoming requests.
diff --git
a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/DefaultMainHttpServerFactory.java
b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/DefaultMainHttpServerFactory.java
index c5fb8e2f4835..cb59843b7b96 100644
---
a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/DefaultMainHttpServerFactory.java
+++
b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/DefaultMainHttpServerFactory.java
@@ -16,11 +16,20 @@
*/
package org.apache.camel.component.platform.http.main;
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Locale;
+import java.util.stream.Collectors;
+
+import io.vertx.core.http.CookieSameSite;
import org.apache.camel.CamelContext;
import org.apache.camel.CamelContextAware;
import org.apache.camel.Service;
import
org.apache.camel.component.platform.http.main.authentication.BasicAuthenticationConfigurer;
import
org.apache.camel.component.platform.http.main.authentication.JWTAuthenticationConfigurer;
+import
org.apache.camel.component.platform.http.vertx.VertxPlatformHttpServerConfiguration;
import org.apache.camel.main.HttpManagementServerConfigurationProperties;
import org.apache.camel.main.HttpServerConfigurationProperties;
import org.apache.camel.main.MainConstants;
@@ -71,10 +80,20 @@ public class DefaultMainHttpServerFactory implements
CamelContextAware, MainHttp
dir = TempDirHelper.resolveTempDir(camelContext, null, dir);
server.setFileUploadDirectory(dir);
}
+ VertxPlatformHttpServerConfiguration.BodyHandler bodyHandler =
server.getConfiguration().getBodyHandler();
+
bodyHandler.setMergeFormAttributes(configuration.isMergeFormAttributes());
+
bodyHandler.setDeleteUploadedFilesOnEnd(configuration.isDeleteUploadedFilesOnEnd());
+
bodyHandler.setPreallocateBodyBuffer(configuration.isPreallocateBodyBuffer());
server.setStaticEnabled(configuration.isStaticEnabled());
server.setStaticContextPath(configuration.getStaticContextPath());
server.setStaticSourceDir(configuration.getStaticSourceDir());
+ if (configuration.isCorsEnabled()) {
+ configureCors(server.getConfiguration().getCors(), configuration);
+ }
+ if (configuration.isSessionEnabled()) {
+ configureSession(server.getConfiguration().getSessionConfig(),
configuration);
+ }
if (configuration.isAuthenticationEnabled()) {
configureAuthentication(server, configuration);
}
@@ -82,6 +101,59 @@ public class DefaultMainHttpServerFactory implements
CamelContextAware, MainHttp
return server;
}
+ private static void configureCors(
+ VertxPlatformHttpServerConfiguration.Cors cors,
HttpServerConfigurationProperties configuration) {
+ cors.setEnabled(true);
+ cors.setOrigins(splitList(configuration.getCorsOrigins()));
+ cors.setMethods(splitList(configuration.getCorsMethods()));
+ cors.setHeaders(splitList(configuration.getCorsHeaders()));
+
cors.setExposedHeaders(splitList(configuration.getCorsExposedHeaders()));
+ if (configuration.getCorsAccessControlMaxAge() != null) {
+
cors.setAccessControlMaxAge(Duration.ofSeconds(configuration.getCorsAccessControlMaxAge()));
+ }
+ }
+
+ private static void configureSession(
+ VertxPlatformHttpServerConfiguration.SessionConfig session,
HttpServerConfigurationProperties configuration) {
+ session.setEnabled(true);
+
session.setStoreType(enumValue(VertxPlatformHttpServerConfiguration.SessionStoreType.class,
+ configuration.getSessionStoreType(), "sessionStoreType"));
+ session.setSessionCookieName(configuration.getSessionCookieName());
+ session.setSessionCookiePath(configuration.getSessionCookiePath());
+ session.setSessionTimeout(configuration.getSessionTimeout());
+ session.setCookieSecure(configuration.isSessionCookieSecure());
+ session.setCookieHttpOnly(configuration.isSessionCookieHttpOnly());
+ session.setCookieSameSite(enumValue(CookieSameSite.class,
configuration.getSessionCookieSameSite(),
+ "sessionCookieSameSite"));
+ session.setSessionIdMinLength(configuration.getSessionIdMinLength());
+ }
+
+ private static List<String> splitList(String value) {
+ if (ObjectHelper.isEmpty(value)) {
+ return List.of();
+ }
+ List<String> answer = new ArrayList<>();
+ for (String part : value.split(",")) {
+ String trimmed = part.trim();
+ if (!trimmed.isEmpty()) {
+ answer.add(trimmed);
+ }
+ }
+ return answer;
+ }
+
+ private static <T extends Enum<T>> T enumValue(Class<T> type, String
value, String option) {
+ for (T constant : type.getEnumConstants()) {
+ if (constant.name().equalsIgnoreCase(value)) {
+ return constant;
+ }
+ }
+ throw new IllegalArgumentException(
+ "Invalid value " + value + " for camel.server." + option + ",
must be one of: "
+ +
Arrays.stream(type.getEnumConstants()).map(e ->
e.name().toLowerCase(Locale.ROOT))
+
.collect(Collectors.joining(",")));
+ }
+
@Override
public Service newHttpManagementServer(
CamelContext camelContext,
HttpManagementServerConfigurationProperties configuration) {
diff --git
a/components/camel-platform-http-main/src/test/java/org/apache/camel/component/platform/http/main/DefaultMainHttpServerFactoryTest.java
b/components/camel-platform-http-main/src/test/java/org/apache/camel/component/platform/http/main/DefaultMainHttpServerFactoryTest.java
new file mode 100644
index 000000000000..ebad1700d43a
--- /dev/null
+++
b/components/camel-platform-http-main/src/test/java/org/apache/camel/component/platform/http/main/DefaultMainHttpServerFactoryTest.java
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.platform.http.main;
+
+import java.time.Duration;
+
+import io.vertx.core.http.CookieSameSite;
+import org.apache.camel.CamelContext;
+import
org.apache.camel.component.platform.http.vertx.VertxPlatformHttpServerConfiguration;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.main.HttpServerConfigurationProperties;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+class DefaultMainHttpServerFactoryTest {
+
+ private final CamelContext context = new DefaultCamelContext();
+ private final DefaultMainHttpServerFactory factory = new
DefaultMainHttpServerFactory();
+
+ @AfterEach
+ void stopContext() {
+ context.stop();
+ }
+
+ private VertxPlatformHttpServerConfiguration
newServer(HttpServerConfigurationProperties configuration) {
+ MainHttpServer server = (MainHttpServer)
factory.newHttpServer(context, configuration);
+ return server.getConfiguration();
+ }
+
+ @Test
+ void defaultsKeepCorsAndSessionDisabled() {
+ VertxPlatformHttpServerConfiguration server = newServer(new
HttpServerConfigurationProperties(null));
+
+ assertThat(server.getCors().isEnabled()).isFalse();
+ assertThat(server.getSessionConfig().isEnabled()).isFalse();
+ assertThat(server.getBodyHandler().isMergeFormAttributes()).isTrue();
+
assertThat(server.getBodyHandler().isDeleteUploadedFilesOnEnd()).isTrue();
+ assertThat(server.getBodyHandler().isPreallocateBodyBuffer()).isTrue();
+ }
+
+ @Test
+ void bodyHandlerFlagsAreMapped() {
+ VertxPlatformHttpServerConfiguration server = newServer(new
HttpServerConfigurationProperties(null)
+ .withMergeFormAttributes(false)
+ .withDeleteUploadedFilesOnEnd(false)
+ .withPreallocateBodyBuffer(false));
+
+ assertThat(server.getBodyHandler().isMergeFormAttributes()).isFalse();
+
assertThat(server.getBodyHandler().isDeleteUploadedFilesOnEnd()).isFalse();
+
assertThat(server.getBodyHandler().isPreallocateBodyBuffer()).isFalse();
+ }
+
+ @Test
+ void corsOptionsAreMapped() {
+ VertxPlatformHttpServerConfiguration.Cors cors = newServer(new
HttpServerConfigurationProperties(null)
+ .withCorsEnabled(true)
+ .withCorsOrigins(" https://a.example , https://b.example,")
+ .withCorsMethods("GET,PUT")
+ .withCorsHeaders("X-A")
+ .withCorsExposedHeaders("X-B,X-C")
+ .withCorsAccessControlMaxAge(60))
+ .getCors();
+
+ assertThat(cors.isEnabled()).isTrue();
+ assertThat(cors.getOrigins()).containsExactly("https://a.example",
"https://b.example");
+ assertThat(cors.getMethods()).containsExactly("GET", "PUT");
+ assertThat(cors.getHeaders()).containsExactly("X-A");
+ assertThat(cors.getExposedHeaders()).containsExactly("X-B", "X-C");
+
assertThat(cors.getAccessControlMaxAge()).isEqualTo(Duration.ofSeconds(60));
+ }
+
+ @Test
+ void corsWithoutListsAllowsWhatIsRequested() {
+ VertxPlatformHttpServerConfiguration.Cors cors = newServer(new
HttpServerConfigurationProperties(null)
+ .withCorsEnabled(true))
+ .getCors();
+
+ assertThat(cors.isEnabled()).isTrue();
+ assertThat(cors.getOrigins()).isEmpty();
+ assertThat(cors.getMethods()).isEmpty();
+ assertThat(cors.getHeaders()).isEmpty();
+ assertThat(cors.getExposedHeaders()).isEmpty();
+ assertThat(cors.getAccessControlMaxAge()).isNull();
+ }
+
+ @Test
+ void sessionOptionsAreMapped() {
+ VertxPlatformHttpServerConfiguration.SessionConfig session =
newServer(new HttpServerConfigurationProperties(null)
+ .withSessionEnabled(true)
+ .withSessionStoreType("Clustered")
+ .withSessionCookieName("sid")
+ .withSessionCookiePath("/app")
+ .withSessionTimeout(5000)
+ .withSessionCookieSecure(true)
+ .withSessionCookieHttpOnly(false)
+ .withSessionCookieSameSite("none")
+ .withSessionIdMinLength(32))
+ .getSessionConfig();
+
+ assertThat(session.isEnabled()).isTrue();
+
assertThat(session.getStoreType()).isEqualTo(VertxPlatformHttpServerConfiguration.SessionStoreType.CLUSTERED);
+ assertThat(session.getSessionCookieName()).isEqualTo("sid");
+ assertThat(session.getSessionCookiePath()).isEqualTo("/app");
+ assertThat(session.getSessionTimeOut()).isEqualTo(5000);
+ assertThat(session.isCookieSecure()).isTrue();
+ assertThat(session.isCookieHttpOnly()).isFalse();
+ assertThat(session.getCookieSameSite()).isEqualTo(CookieSameSite.NONE);
+ assertThat(session.getSessionIdMinLength()).isEqualTo(32);
+ }
+
+ @Test
+ void sessionDefaults() {
+ VertxPlatformHttpServerConfiguration.SessionConfig session =
newServer(new HttpServerConfigurationProperties(null)
+ .withSessionEnabled(true))
+ .getSessionConfig();
+
+
assertThat(session.getStoreType()).isEqualTo(VertxPlatformHttpServerConfiguration.SessionStoreType.LOCAL);
+
assertThat(session.getSessionCookieName()).isEqualTo("vertx-web.session");
+ assertThat(session.getSessionCookiePath()).isEqualTo("/");
+ assertThat(session.getSessionTimeOut()).isEqualTo(1800000);
+ assertThat(session.isCookieSecure()).isFalse();
+ assertThat(session.isCookieHttpOnly()).isTrue();
+
assertThat(session.getCookieSameSite()).isEqualTo(CookieSameSite.STRICT);
+ assertThat(session.getSessionIdMinLength()).isEqualTo(16);
+ }
+
+ @Test
+ void invalidSameSiteFails() {
+ HttpServerConfigurationProperties configuration = new
HttpServerConfigurationProperties(null)
+ .withSessionEnabled(true)
+ .withSessionCookieSameSite("sometimes");
+
+ assertThatThrownBy(() -> newServer(configuration))
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessageContaining("camel.server.sessionCookieSameSite")
+ .hasMessageContaining("none,strict,lax");
+ }
+}
diff --git
a/components/camel-platform-http-main/src/test/java/org/apache/camel/component/platform/http/main/MainHttpServerCorsSessionTest.java
b/components/camel-platform-http-main/src/test/java/org/apache/camel/component/platform/http/main/MainHttpServerCorsSessionTest.java
new file mode 100644
index 000000000000..ec6d17ba71ab
--- /dev/null
+++
b/components/camel-platform-http-main/src/test/java/org/apache/camel/component/platform/http/main/MainHttpServerCorsSessionTest.java
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.platform.http.main;
+
+import java.util.Map;
+
+import io.restassured.RestAssured;
+import io.restassured.response.Response;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.main.Main;
+import org.apache.camel.test.AvailablePortFinder;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import static io.restassured.RestAssured.given;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * The CORS and session settings of the embedded HTTP server are configured
with camel.server.* keys.
+ */
+class MainHttpServerCorsSessionTest {
+
+ @RegisterExtension
+ AvailablePortFinder.Port port = AvailablePortFinder.find();
+
+ private Main main;
+
+ @AfterEach
+ void stopMain() {
+ if (main != null) {
+ main.stop();
+ }
+ RestAssured.reset();
+ }
+
+ private void startMain(Map<String, String> properties) {
+ main = new Main();
+ main.addOverrideProperty("camel.server.enabled", "true");
+ main.addOverrideProperty("camel.server.port",
Integer.toString(port.getPort()));
+ properties.forEach(main::addOverrideProperty);
+ main.configure().addRoutesBuilder(new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("platform-http:/hello").setBody(constant("Hello"));
+ }
+ });
+ main.start();
+ RestAssured.port = port.getPort();
+ }
+
+ @Test
+ void corsPreflightIsAnsweredWithTheConfiguredHeaders() {
+ startMain(Map.of(
+ "camel.server.corsEnabled", "true",
+ "camel.server.corsOrigins", "https://app.example.com,
https://other.example.com",
+ "camel.server.corsMethods", "GET,POST",
+ "camel.server.corsHeaders", "X-Custom",
+ "camel.server.corsExposedHeaders", "X-Total,X-Page",
+ "camel.server.cors-access-control-max-age", "3600"));
+
+ Response preflight = given()
+ .header("Origin", "https://app.example.com")
+ .header("Access-Control-Request-Method", "POST")
+ .header("Access-Control-Request-Headers", "X-Custom,X-Other")
+ .when()
+ .options("/hello");
+
+ assertThat(preflight.statusCode()).isEqualTo(200);
+
assertThat(preflight.header("Access-Control-Allow-Origin")).isEqualTo("https://app.example.com");
+
assertThat(preflight.header("Access-Control-Allow-Credentials")).isEqualTo("true");
+
assertThat(preflight.header("Access-Control-Allow-Methods")).isEqualTo("POST");
+
assertThat(preflight.header("Access-Control-Allow-Headers")).isEqualTo("X-Custom");
+
assertThat(preflight.header("Access-Control-Expose-Headers")).isEqualTo("X-Total,X-Page");
+
assertThat(preflight.header("Access-Control-Max-Age")).isEqualTo("3600");
+
+ Response foreign = given()
+ .header("Origin", "https://evil.example.com")
+ .when()
+ .get("/hello");
+
+ assertThat(foreign.statusCode()).isEqualTo(200);
+ assertThat(foreign.header("Access-Control-Allow-Origin")).isNull();
+ }
+
+ @Test
+ void corsIsNotHandledByDefault() {
+ startMain(Map.of());
+
+ Response response = given()
+ .header("Origin", "https://app.example.com")
+ .when()
+ .get("/hello");
+
+ assertThat(response.statusCode()).isEqualTo(200);
+ assertThat(response.header("Access-Control-Allow-Origin")).isNull();
+ }
+
+ @Test
+ void sessionCookieHasTheConfiguredSettings() {
+ startMain(Map.of(
+ "camel.server.sessionEnabled", "true",
+ "camel.server.sessionCookieName", "camel-session",
+ "camel.server.sessionCookiePath", "/hello",
+ "camel.server.sessionCookieSecure", "true",
+ "camel.server.sessionCookieSameSite", "lax"));
+
+ Response response = given().when().get("/hello");
+
+ assertThat(response.statusCode()).isEqualTo(200);
+ assertThat(response.body().asString()).isEqualTo("Hello");
+ String cookie = response.header("Set-Cookie");
+ assertThat(cookie)
+ .startsWith("camel-session=")
+ .contains("Path=/hello")
+ .contains("Secure")
+ .contains("HTTPOnly")
+ .contains("SameSite=Lax");
+ }
+
+ @Test
+ void noSessionCookieByDefault() {
+ startMain(Map.of());
+
+ Response response = given().when().get("/hello");
+
+ assertThat(response.statusCode()).isEqualTo(200);
+ assertThat(response.header("Set-Cookie")).isNull();
+ }
+}
diff --git
a/core/camel-main/src/generated/java/org/apache/camel/main/HttpServerConfigurationPropertiesConfigurer.java
b/core/camel-main/src/generated/java/org/apache/camel/main/HttpServerConfigurationPropertiesConfigurer.java
index e6a5dbcb0d5d..7de2e5825139 100644
---
a/core/camel-main/src/generated/java/org/apache/camel/main/HttpServerConfigurationPropertiesConfigurer.java
+++
b/core/camel-main/src/generated/java/org/apache/camel/main/HttpServerConfigurationPropertiesConfigurer.java
@@ -27,6 +27,13 @@ public class HttpServerConfigurationPropertiesConfigurer
extends org.apache.came
map.put("AuthenticationPath", java.lang.String.class);
map.put("AuthenticationRealm", java.lang.String.class);
map.put("BasicPropertiesFile", java.lang.String.class);
+ map.put("CorsAccessControlMaxAge", java.lang.Long.class);
+ map.put("CorsEnabled", boolean.class);
+ map.put("CorsExposedHeaders", java.lang.String.class);
+ map.put("CorsHeaders", java.lang.String.class);
+ map.put("CorsMethods", java.lang.String.class);
+ map.put("CorsOrigins", java.lang.String.class);
+ map.put("DeleteUploadedFilesOnEnd", boolean.class);
map.put("Enabled", boolean.class);
map.put("FileUploadDirectory", java.lang.String.class);
map.put("FileUploadEnabled", boolean.class);
@@ -60,8 +67,19 @@ public class HttpServerConfigurationPropertiesConfigurer
extends org.apache.came
map.put("McpTags", java.lang.String.class);
map.put("McpToolTimeout", long.class);
map.put("McpTransport", java.lang.String.class);
+ map.put("MergeFormAttributes", boolean.class);
map.put("Path", java.lang.String.class);
map.put("Port", int.class);
+ map.put("PreallocateBodyBuffer", boolean.class);
+ map.put("SessionCookieHttpOnly", boolean.class);
+ map.put("SessionCookieName", java.lang.String.class);
+ map.put("SessionCookiePath", java.lang.String.class);
+ map.put("SessionCookieSameSite", java.lang.String.class);
+ map.put("SessionCookieSecure", boolean.class);
+ map.put("SessionEnabled", boolean.class);
+ map.put("SessionIdMinLength", int.class);
+ map.put("SessionStoreType", java.lang.String.class);
+ map.put("SessionTimeout", long.class);
map.put("StaticContextPath", java.lang.String.class);
map.put("StaticEnabled", boolean.class);
map.put("StaticSourceDir", java.lang.String.class);
@@ -81,6 +99,20 @@ public class HttpServerConfigurationPropertiesConfigurer
extends org.apache.came
case "authenticationRealm":
target.setAuthenticationRealm(property(camelContext, java.lang.String.class,
value)); return true;
case "basicpropertiesfile":
case "basicPropertiesFile":
target.setBasicPropertiesFile(property(camelContext, java.lang.String.class,
value)); return true;
+ case "corsaccesscontrolmaxage":
+ case "corsAccessControlMaxAge":
target.setCorsAccessControlMaxAge(property(camelContext, java.lang.Long.class,
value)); return true;
+ case "corsenabled":
+ case "corsEnabled": target.setCorsEnabled(property(camelContext,
boolean.class, value)); return true;
+ case "corsexposedheaders":
+ case "corsExposedHeaders":
target.setCorsExposedHeaders(property(camelContext, java.lang.String.class,
value)); return true;
+ case "corsheaders":
+ case "corsHeaders": target.setCorsHeaders(property(camelContext,
java.lang.String.class, value)); return true;
+ case "corsmethods":
+ case "corsMethods": target.setCorsMethods(property(camelContext,
java.lang.String.class, value)); return true;
+ case "corsorigins":
+ case "corsOrigins": target.setCorsOrigins(property(camelContext,
java.lang.String.class, value)); return true;
+ case "deleteuploadedfilesonend":
+ case "deleteUploadedFilesOnEnd":
target.setDeleteUploadedFilesOnEnd(property(camelContext, boolean.class,
value)); return true;
case "enabled": target.setEnabled(property(camelContext,
boolean.class, value)); return true;
case "fileuploaddirectory":
case "fileUploadDirectory":
target.setFileUploadDirectory(property(camelContext, java.lang.String.class,
value)); return true;
@@ -145,8 +177,30 @@ public class HttpServerConfigurationPropertiesConfigurer
extends org.apache.came
case "mcpToolTimeout": target.setMcpToolTimeout(property(camelContext,
long.class, value)); return true;
case "mcptransport":
case "mcpTransport": target.setMcpTransport(property(camelContext,
java.lang.String.class, value)); return true;
+ case "mergeformattributes":
+ case "mergeFormAttributes":
target.setMergeFormAttributes(property(camelContext, boolean.class, value));
return true;
case "path": target.setPath(property(camelContext,
java.lang.String.class, value)); return true;
case "port": target.setPort(property(camelContext, int.class, value));
return true;
+ case "preallocatebodybuffer":
+ case "preallocateBodyBuffer":
target.setPreallocateBodyBuffer(property(camelContext, boolean.class, value));
return true;
+ case "sessioncookiehttponly":
+ case "sessionCookieHttpOnly":
target.setSessionCookieHttpOnly(property(camelContext, boolean.class, value));
return true;
+ case "sessioncookiename":
+ case "sessionCookieName":
target.setSessionCookieName(property(camelContext, java.lang.String.class,
value)); return true;
+ case "sessioncookiepath":
+ case "sessionCookiePath":
target.setSessionCookiePath(property(camelContext, java.lang.String.class,
value)); return true;
+ case "sessioncookiesamesite":
+ case "sessionCookieSameSite":
target.setSessionCookieSameSite(property(camelContext, java.lang.String.class,
value)); return true;
+ case "sessioncookiesecure":
+ case "sessionCookieSecure":
target.setSessionCookieSecure(property(camelContext, boolean.class, value));
return true;
+ case "sessionenabled":
+ case "sessionEnabled": target.setSessionEnabled(property(camelContext,
boolean.class, value)); return true;
+ case "sessionidminlength":
+ case "sessionIdMinLength":
target.setSessionIdMinLength(property(camelContext, int.class, value)); return
true;
+ case "sessionstoretype":
+ case "sessionStoreType":
target.setSessionStoreType(property(camelContext, java.lang.String.class,
value)); return true;
+ case "sessiontimeout":
+ case "sessionTimeout": target.setSessionTimeout(property(camelContext,
long.class, value)); return true;
case "staticcontextpath":
case "staticContextPath":
target.setStaticContextPath(property(camelContext, java.lang.String.class,
value)); return true;
case "staticenabled":
@@ -175,6 +229,20 @@ public class HttpServerConfigurationPropertiesConfigurer
extends org.apache.came
case "authenticationRealm": return java.lang.String.class;
case "basicpropertiesfile":
case "basicPropertiesFile": return java.lang.String.class;
+ case "corsaccesscontrolmaxage":
+ case "corsAccessControlMaxAge": return java.lang.Long.class;
+ case "corsenabled":
+ case "corsEnabled": return boolean.class;
+ case "corsexposedheaders":
+ case "corsExposedHeaders": return java.lang.String.class;
+ case "corsheaders":
+ case "corsHeaders": return java.lang.String.class;
+ case "corsmethods":
+ case "corsMethods": return java.lang.String.class;
+ case "corsorigins":
+ case "corsOrigins": return java.lang.String.class;
+ case "deleteuploadedfilesonend":
+ case "deleteUploadedFilesOnEnd": return boolean.class;
case "enabled": return boolean.class;
case "fileuploaddirectory":
case "fileUploadDirectory": return java.lang.String.class;
@@ -239,8 +307,30 @@ public class HttpServerConfigurationPropertiesConfigurer
extends org.apache.came
case "mcpToolTimeout": return long.class;
case "mcptransport":
case "mcpTransport": return java.lang.String.class;
+ case "mergeformattributes":
+ case "mergeFormAttributes": return boolean.class;
case "path": return java.lang.String.class;
case "port": return int.class;
+ case "preallocatebodybuffer":
+ case "preallocateBodyBuffer": return boolean.class;
+ case "sessioncookiehttponly":
+ case "sessionCookieHttpOnly": return boolean.class;
+ case "sessioncookiename":
+ case "sessionCookieName": return java.lang.String.class;
+ case "sessioncookiepath":
+ case "sessionCookiePath": return java.lang.String.class;
+ case "sessioncookiesamesite":
+ case "sessionCookieSameSite": return java.lang.String.class;
+ case "sessioncookiesecure":
+ case "sessionCookieSecure": return boolean.class;
+ case "sessionenabled":
+ case "sessionEnabled": return boolean.class;
+ case "sessionidminlength":
+ case "sessionIdMinLength": return int.class;
+ case "sessionstoretype":
+ case "sessionStoreType": return java.lang.String.class;
+ case "sessiontimeout":
+ case "sessionTimeout": return long.class;
case "staticcontextpath":
case "staticContextPath": return java.lang.String.class;
case "staticenabled":
@@ -265,6 +355,20 @@ public class HttpServerConfigurationPropertiesConfigurer
extends org.apache.came
case "authenticationRealm": return target.getAuthenticationRealm();
case "basicpropertiesfile":
case "basicPropertiesFile": return target.getBasicPropertiesFile();
+ case "corsaccesscontrolmaxage":
+ case "corsAccessControlMaxAge": return
target.getCorsAccessControlMaxAge();
+ case "corsenabled":
+ case "corsEnabled": return target.isCorsEnabled();
+ case "corsexposedheaders":
+ case "corsExposedHeaders": return target.getCorsExposedHeaders();
+ case "corsheaders":
+ case "corsHeaders": return target.getCorsHeaders();
+ case "corsmethods":
+ case "corsMethods": return target.getCorsMethods();
+ case "corsorigins":
+ case "corsOrigins": return target.getCorsOrigins();
+ case "deleteuploadedfilesonend":
+ case "deleteUploadedFilesOnEnd": return
target.isDeleteUploadedFilesOnEnd();
case "enabled": return target.isEnabled();
case "fileuploaddirectory":
case "fileUploadDirectory": return target.getFileUploadDirectory();
@@ -329,8 +433,30 @@ public class HttpServerConfigurationPropertiesConfigurer
extends org.apache.came
case "mcpToolTimeout": return target.getMcpToolTimeout();
case "mcptransport":
case "mcpTransport": return target.getMcpTransport();
+ case "mergeformattributes":
+ case "mergeFormAttributes": return target.isMergeFormAttributes();
case "path": return target.getPath();
case "port": return target.getPort();
+ case "preallocatebodybuffer":
+ case "preallocateBodyBuffer": return target.isPreallocateBodyBuffer();
+ case "sessioncookiehttponly":
+ case "sessionCookieHttpOnly": return target.isSessionCookieHttpOnly();
+ case "sessioncookiename":
+ case "sessionCookieName": return target.getSessionCookieName();
+ case "sessioncookiepath":
+ case "sessionCookiePath": return target.getSessionCookiePath();
+ case "sessioncookiesamesite":
+ case "sessionCookieSameSite": return target.getSessionCookieSameSite();
+ case "sessioncookiesecure":
+ case "sessionCookieSecure": return target.isSessionCookieSecure();
+ case "sessionenabled":
+ case "sessionEnabled": return target.isSessionEnabled();
+ case "sessionidminlength":
+ case "sessionIdMinLength": return target.getSessionIdMinLength();
+ case "sessionstoretype":
+ case "sessionStoreType": return target.getSessionStoreType();
+ case "sessiontimeout":
+ case "sessionTimeout": return target.getSessionTimeout();
case "staticcontextpath":
case "staticContextPath": return target.getStaticContextPath();
case "staticenabled":
diff --git
a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
index fcb1616865d5..2951850dc1cf 100644
---
a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
+++
b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
@@ -457,6 +457,13 @@
{ "name": "camel.server.authenticationPath", "required": false,
"description": "Set HTTP url path of embedded server that is protected by
authentication configuration.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "string",
"javaType": "java.lang.String", "secret": false },
{ "name": "camel.server.authenticationRealm", "required": false,
"description": "Sets the authentication realm", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "string",
"javaType": "java.lang.String", "secret": false },
{ "name": "camel.server.basicPropertiesFile", "required": false,
"description": "Name of the file that contains basic authentication info for
Vert.x file auth provider.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "string",
"javaType": "java.lang.String", "secret": false },
+ { "name": "camel.server.corsAccessControlMaxAge", "required": false,
"description": "How long (in seconds) a browser may cache the answer of a
preflight request, sent as the Access-Control-Max-Age header. When not set, the
header is not sent.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "integer",
"javaType": "java.lang.Long", "secret": false },
+ { "name": "camel.server.corsEnabled", "required": false, "description":
"Whether the embedded HTTP server handles CORS (Cross-Origin Resource Sharing):
it answers preflight requests and adds the Access-Control-* headers to the
responses of requests with an Origin header.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean",
"javaType": "boolean", "defaultValue": false, "secret": false },
+ { "name": "camel.server.corsExposedHeaders", "required": false,
"description": "Comma-separated list of the HTTP response headers a browser may
expose to the calling script, sent as the Access-Control-Expose-Headers
header.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "string",
"javaType": "java.lang.String", "secret": false },
+ { "name": "camel.server.corsHeaders", "required": false, "description":
"Comma-separated list of the HTTP headers allowed in a CORS request. When not
set, the headers of the Access-Control-Request-Headers header of the preflight
request are allowed.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "string",
"javaType": "java.lang.String", "secret": false },
+ { "name": "camel.server.corsMethods", "required": false, "description":
"Comma-separated list of the HTTP methods (such as GET,POST) allowed in a CORS
request. When not set, the methods of the Access-Control-Request-Method header
of the preflight request are allowed.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "string",
"javaType": "java.lang.String", "secret": false },
+ { "name": "camel.server.corsOrigins", "required": false, "description":
"Comma-separated list of origins (such as https:\/\/app.example.com) allowed to
call the embedded HTTP server. A request from an origin in the list is answered
with Access-Control-Allow-Origin and Access-Control-Allow-Credentials=true.
When not set, the origin of every request is allowed (reflected back), without
credentials.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "stri [...]
+ { "name": "camel.server.deleteUploadedFilesOnEnd", "required": false,
"description": "Whether the uploaded files are deleted from the file upload
directory when the response has been sent.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean",
"javaType": "boolean", "defaultValue": true, "secret": false },
{ "name": "camel.server.enabled", "required": false, "description":
"Whether embedded HTTP server is enabled. By default, the server is not
enabled.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean",
"javaType": "boolean", "defaultValue": false, "secret": false },
{ "name": "camel.server.fileUploadDirectory", "required": false,
"description": "Directory to temporary store file uploads while Camel routes
the incoming request. If no directory has been explicit configured, then a
temporary directory is created in the java.io.tmpdir directory.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "string",
"javaType": "java.lang.String", "secret": false },
{ "name": "camel.server.fileUploadEnabled", "required": false,
"description": "Whether to enable file uploads being supported (such as POST
multipart\/form-data) and stored into a temporary directory.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean",
"javaType": "boolean", "defaultValue": true, "secret": false },
@@ -490,8 +497,19 @@
{ "name": "camel.server.mcpTags", "required": false, "description":
"Comma-separated list of tag patterns selecting ai-tool routes as MCP tools,
ai-resource routes as MCP resources and ai-prompt routes as MCP prompts.
Matching is case-insensitive and supports exact match, wildcard prefix ( foo*
), and * to match all tags. Only routes registered under a matching tag are
exposed; the untagged default pools are never exposed. When not set, nothing is
exposed.", "sourceType": "org.apache [...]
{ "name": "camel.server.mcpToolTimeout", "required": false, "description":
"Per-call MCP tool execution timeout in milliseconds. A call exceeding the
timeout returns an error result to the MCP client; the underlying route keeps
running until it completes on its own.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "integer",
"javaType": "long", "defaultValue": 20000, "secret": false },
{ "name": "camel.server.mcpTransport", "required": false, "description":
"MCP transport selection: http (streamable HTTP on the embedded server, serving
tools, resources and prompts) or stdio (JSON-RPC on process stdin\/stdout for
local agent subprocesses, serving tools and prompts only).", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "enum",
"javaType": "java.lang.String", "defaultValue": "http", "secret": false,
"enum": [ "http", "stdio" ] },
+ { "name": "camel.server.mergeFormAttributes", "required": false,
"description": "Whether the form attributes of a request
(application\/x-www-form-urlencoded or multipart\/form-data) are merged into
the request parameters.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean",
"javaType": "boolean", "defaultValue": true, "secret": false },
{ "name": "camel.server.path", "required": false, "description":
"Context-path to use for embedded HTTP server", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "string",
"javaType": "java.lang.String", "defaultValue": "\/", "secret": false },
{ "name": "camel.server.port", "required": false, "description": "Port to
use for binding embedded HTTP server. Use 0 to dynamic assign a free random
port number.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "integer",
"javaType": "int", "defaultValue": 8080, "secret": false },
+ { "name": "camel.server.preallocateBodyBuffer", "required": false,
"description": "Whether the buffer for the request body is pre-allocated, using
the Content-Length header of the request to size it.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean",
"javaType": "boolean", "defaultValue": true, "secret": false },
+ { "name": "camel.server.sessionCookieHttpOnly", "required": false,
"description": "Whether the session cookie has the HttpOnly flag, so scripts in
the browser cannot read it.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean",
"javaType": "boolean", "defaultValue": true, "secret": false },
+ { "name": "camel.server.sessionCookieName", "required": false,
"description": "The name of the session cookie.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "string",
"javaType": "java.lang.String", "defaultValue": "vertx-web.session", "secret":
false },
+ { "name": "camel.server.sessionCookiePath", "required": false,
"description": "The path of the session cookie.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "string",
"javaType": "java.lang.String", "defaultValue": "\/", "secret": false },
+ { "name": "camel.server.sessionCookieSameSite", "required": false,
"description": "The SameSite attribute of the session cookie: strict, lax or
none.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "enum",
"javaType": "java.lang.String", "defaultValue": "strict", "secret": false,
"enum": [ "strict", "lax", "none" ] },
+ { "name": "camel.server.sessionCookieSecure", "required": false,
"description": "Whether the session cookie has the Secure flag, so browsers
only send it over HTTPS.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean",
"javaType": "boolean", "defaultValue": false, "secret": false },
+ { "name": "camel.server.sessionEnabled", "required": false, "description":
"Whether the embedded HTTP server keeps a session for each client, identified
by a session cookie.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean",
"javaType": "boolean", "defaultValue": false, "secret": false },
+ { "name": "camel.server.sessionIdMinLength", "required": false,
"description": "The minimum length of the session id.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "integer",
"javaType": "int", "defaultValue": 16, "secret": false },
+ { "name": "camel.server.sessionStoreType", "required": false,
"description": "Where the sessions are stored: local (in memory of this
application) or clustered (in the cluster of a clustered Vert.x instance, which
must be provided in the registry).", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "enum",
"javaType": "java.lang.String", "defaultValue": "local", "secret": false,
"enum": [ "local", "clustered" ] },
+ { "name": "camel.server.sessionTimeout", "required": false, "description":
"The time in milliseconds after which a session without activity expires.",
"sourceType": "org.apache.camel.main.HttpServerConfigurationProperties",
"type": "integer", "javaType": "long", "defaultValue": 1800000, "secret": false
},
{ "name": "camel.server.staticContextPath", "required": false,
"description": "The context-path to use for serving static content. By default,
the root path is used. And if there is an index.html page then this is
automatically loaded.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "string",
"javaType": "java.lang.String", "defaultValue": "\/", "secret": false },
{ "name": "camel.server.staticEnabled", "required": false, "description":
"Whether serving static files is enabled. If enabled then Camel can host
html\/js and other web files that makes it possible to include small web
applications.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean",
"javaType": "boolean", "defaultValue": false, "secret": false },
{ "name": "camel.server.staticSourceDir", "required": false,
"description": "Additional directory that holds static content when static is
enabled.", "sourceType":
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "string",
"javaType": "java.lang.String", "secret": false },
diff --git
a/core/camel-main/src/generated/resources/org/apache/camel/main/main-options.properties
b/core/camel-main/src/generated/resources/org/apache/camel/main/main-options.properties
index b11b468a9494..38b53ceab8f6 100644
---
a/core/camel-main/src/generated/resources/org/apache/camel/main/main-options.properties
+++
b/core/camel-main/src/generated/resources/org/apache/camel/main/main-options.properties
@@ -415,6 +415,13 @@ camel.server.authenticationEnabled
camel.server.authenticationPath
camel.server.authenticationRealm
camel.server.basicPropertiesFile
+camel.server.corsAccessControlMaxAge
+camel.server.corsEnabled
+camel.server.corsExposedHeaders
+camel.server.corsHeaders
+camel.server.corsMethods
+camel.server.corsOrigins
+camel.server.deleteUploadedFilesOnEnd
camel.server.enabled
camel.server.fileUploadDirectory
camel.server.fileUploadEnabled
@@ -448,8 +455,19 @@ camel.server.mcpStateless
camel.server.mcpTags
camel.server.mcpToolTimeout
camel.server.mcpTransport
+camel.server.mergeFormAttributes
camel.server.path
camel.server.port
+camel.server.preallocateBodyBuffer
+camel.server.sessionCookieHttpOnly
+camel.server.sessionCookieName
+camel.server.sessionCookiePath
+camel.server.sessionCookieSameSite
+camel.server.sessionCookieSecure
+camel.server.sessionEnabled
+camel.server.sessionIdMinLength
+camel.server.sessionStoreType
+camel.server.sessionTimeout
camel.server.staticContextPath
camel.server.staticEnabled
camel.server.staticSourceDir
diff --git a/core/camel-main/src/main/docs/main.adoc
b/core/camel-main/src/main/docs/main.adoc
index b4e0df816141..cf281340147f 100644
--- a/core/camel-main/src/main/docs/main.adoc
+++ b/core/camel-main/src/main/docs/main.adoc
@@ -197,7 +197,7 @@ The camel.routecontroller supports 12 options, which are
listed below.
=== Camel Embedded HTTP Server (only for standalone; not Spring Boot or
Quarkus) configurations
-The camel.server supports 43 options, which are listed below.
+The camel.server supports 61 options, which are listed below.
[width="100%",cols="2,5,^1,2",options="header"]
|===
@@ -206,6 +206,13 @@ The camel.server supports 43 options, which are listed
below.
| `camel.server.authenticationPath` | Set HTTP url path of embedded server
that is protected by authentication configuration. | | String
| `camel.server.authenticationRealm` | Sets the authentication realm | |
String
| `camel.server.basicPropertiesFile` | Name of the file that contains basic
authentication info for Vert.x file auth provider. | | String
+| `camel.server.corsAccessControlMaxAge` | How long (in seconds) a browser may
cache the answer of a preflight request, sent as the Access-Control-Max-Age
header. When not set, the header is not sent. | | Long
+| `camel.server.corsEnabled` | Whether the embedded HTTP server handles CORS
(Cross-Origin Resource Sharing): it answers preflight requests and adds the
Access-Control-* headers to the responses of requests with an Origin header. |
false | boolean
+| `camel.server.corsExposedHeaders` | Comma-separated list of the HTTP
response headers a browser may expose to the calling script, sent as the
Access-Control-Expose-Headers header. | | String
+| `camel.server.corsHeaders` | Comma-separated list of the HTTP headers
allowed in a CORS request. When not set, the headers of the
Access-Control-Request-Headers header of the preflight request are allowed. |
| String
+| `camel.server.corsMethods` | Comma-separated list of the HTTP methods (such
as GET,POST) allowed in a CORS request. When not set, the methods of the
Access-Control-Request-Method header of the preflight request are allowed. | |
String
+| `camel.server.corsOrigins` | Comma-separated list of origins (such as
\https://app.example.com) allowed to call the embedded HTTP server. A request
from an origin in the list is answered with Access-Control-Allow-Origin and
Access-Control-Allow-Credentials=true. When not set, the origin of every
request is allowed (reflected back), without credentials. | | String
+| `camel.server.deleteUploadedFilesOnEnd` | Whether the uploaded files are
deleted from the file upload directory when the response has been sent. | true
| boolean
| `camel.server.enabled` | Whether embedded HTTP server is enabled. By
default, the server is not enabled. | false | boolean
| `camel.server.fileUploadDirectory` | Directory to temporary store file
uploads while Camel routes the incoming request. If no directory has been
explicit configured, then a temporary directory is created in the
java.io.tmpdir directory. | | String
| `camel.server.fileUploadEnabled` | Whether to enable file uploads being
supported (such as POST multipart/form-data) and stored into a temporary
directory. | true | boolean
@@ -239,8 +246,19 @@ The camel.server supports 43 options, which are listed
below.
| `camel.server.mcpTags` | Comma-separated list of tag patterns selecting
ai-tool routes as MCP tools, ai-resource routes as MCP resources and ai-prompt
routes as MCP prompts. Matching is case-insensitive and supports exact match,
wildcard prefix ( foo* ), and * to match all tags. Only routes registered under
a matching tag are exposed; the untagged default pools are never exposed. When
not set, nothing is exposed. | | String
| `camel.server.mcpToolTimeout` | Per-call MCP tool execution timeout in
milliseconds. A call exceeding the timeout returns an error result to the MCP
client; the underlying route keeps running until it completes on its own. |
20000 | long
| `camel.server.mcpTransport` | MCP transport selection: http (streamable HTTP
on the embedded server, serving tools, resources and prompts) or stdio
(JSON-RPC on process stdin/stdout for local agent subprocesses, serving tools
and prompts only). | http | String
+| `camel.server.mergeFormAttributes` | Whether the form attributes of a
request (application/x-www-form-urlencoded or multipart/form-data) are merged
into the request parameters. | true | boolean
| `camel.server.path` | Context-path to use for embedded HTTP server | / |
String
| `camel.server.port` | Port to use for binding embedded HTTP server. Use 0 to
dynamic assign a free random port number. | 8080 | int
+| `camel.server.preallocateBodyBuffer` | Whether the buffer for the request
body is pre-allocated, using the Content-Length header of the request to size
it. | true | boolean
+| `camel.server.sessionCookieHttpOnly` | Whether the session cookie has the
HttpOnly flag, so scripts in the browser cannot read it. | true | boolean
+| `camel.server.sessionCookieName` | The name of the session cookie. |
vertx-web.session | String
+| `camel.server.sessionCookiePath` | The path of the session cookie. | / |
String
+| `camel.server.sessionCookieSameSite` | The SameSite attribute of the session
cookie: strict, lax or none. | strict | String
+| `camel.server.sessionCookieSecure` | Whether the session cookie has the
Secure flag, so browsers only send it over HTTPS. | false | boolean
+| `camel.server.sessionEnabled` | Whether the embedded HTTP server keeps a
session for each client, identified by a session cookie. | false | boolean
+| `camel.server.sessionIdMinLength` | The minimum length of the session id. |
16 | int
+| `camel.server.sessionStoreType` | Where the sessions are stored: local (in
memory of this application) or clustered (in the cluster of a clustered Vert.x
instance, which must be provided in the registry). | local | String
+| `camel.server.sessionTimeout` | The time in milliseconds after which a
session without activity expires. | 1800000 | long
| `camel.server.staticContextPath` | The context-path to use for serving
static content. By default, the root path is used. And if there is an
index.html page then this is automatically loaded. | / | String
| `camel.server.staticEnabled` | Whether serving static files is enabled. If
enabled then Camel can host html/js and other web files that makes it possible
to include small web applications. | false | boolean
| `camel.server.staticSourceDir` | Additional directory that holds static
content when static is enabled. | | String
diff --git
a/core/camel-main/src/main/java/org/apache/camel/main/HttpServerConfigurationProperties.java
b/core/camel-main/src/main/java/org/apache/camel/main/HttpServerConfigurationProperties.java
index 4f0e09ed88c5..adc4711000b9 100644
---
a/core/camel-main/src/main/java/org/apache/camel/main/HttpServerConfigurationProperties.java
+++
b/core/camel-main/src/main/java/org/apache/camel/main/HttpServerConfigurationProperties.java
@@ -47,6 +47,44 @@ public class HttpServerConfigurationProperties implements
BootstrapCloseable {
private String fileUploadDirectory;
@Metadata(label = "advanced")
private Long maxBodySize;
+ @Metadata(label = "advanced", defaultValue = "true")
+ private boolean mergeFormAttributes = true;
+ @Metadata(label = "advanced", defaultValue = "true")
+ private boolean deleteUploadedFilesOnEnd = true;
+ @Metadata(label = "advanced", defaultValue = "true")
+ private boolean preallocateBodyBuffer = true;
+
+ @Metadata(label = "security")
+ private boolean corsEnabled;
+ @Metadata(label = "security")
+ private String corsOrigins;
+ @Metadata(label = "security")
+ private String corsMethods;
+ @Metadata(label = "security")
+ private String corsHeaders;
+ @Metadata(label = "security")
+ private String corsExposedHeaders;
+ @Metadata(label = "security")
+ private Long corsAccessControlMaxAge;
+
+ @Metadata(label = "security")
+ private boolean sessionEnabled;
+ @Metadata(label = "security", defaultValue = "local", enums =
"local,clustered")
+ private String sessionStoreType = "local";
+ @Metadata(label = "security", defaultValue = "vertx-web.session")
+ private String sessionCookieName = "vertx-web.session";
+ @Metadata(label = "security", defaultValue = "/")
+ private String sessionCookiePath = "/";
+ @Metadata(label = "security", defaultValue = "1800000")
+ private long sessionTimeout = 1800000;
+ @Metadata(label = "security")
+ private boolean sessionCookieSecure;
+ @Metadata(label = "security", defaultValue = "true")
+ private boolean sessionCookieHttpOnly = true;
+ @Metadata(label = "security", defaultValue = "strict", enums =
"strict,lax,none")
+ private String sessionCookieSameSite = "strict";
+ @Metadata(label = "security", defaultValue = "16")
+ private int sessionIdMinLength = 16;
@Metadata(label = "security")
private boolean useGlobalSslContextParameters;
@@ -184,6 +222,215 @@ public class HttpServerConfigurationProperties implements
BootstrapCloseable {
this.maxBodySize = maxBodySize;
}
+ public boolean isMergeFormAttributes() {
+ return mergeFormAttributes;
+ }
+
+ /**
+ * Whether the form attributes of a request
(application/x-www-form-urlencoded or multipart/form-data) are merged
+ * into the request parameters.
+ */
+ public void setMergeFormAttributes(boolean mergeFormAttributes) {
+ this.mergeFormAttributes = mergeFormAttributes;
+ }
+
+ public boolean isDeleteUploadedFilesOnEnd() {
+ return deleteUploadedFilesOnEnd;
+ }
+
+ /**
+ * Whether the uploaded files are deleted from the file upload directory
when the response has been sent.
+ */
+ public void setDeleteUploadedFilesOnEnd(boolean deleteUploadedFilesOnEnd) {
+ this.deleteUploadedFilesOnEnd = deleteUploadedFilesOnEnd;
+ }
+
+ public boolean isPreallocateBodyBuffer() {
+ return preallocateBodyBuffer;
+ }
+
+ /**
+ * Whether the buffer for the request body is pre-allocated, using the
Content-Length header of the request to size
+ * it.
+ */
+ public void setPreallocateBodyBuffer(boolean preallocateBodyBuffer) {
+ this.preallocateBodyBuffer = preallocateBodyBuffer;
+ }
+
+ public boolean isCorsEnabled() {
+ return corsEnabled;
+ }
+
+ /**
+ * Whether the embedded HTTP server handles CORS (Cross-Origin Resource
Sharing): it answers preflight requests and
+ * adds the Access-Control-* headers to the responses of requests with an
Origin header.
+ */
+ public void setCorsEnabled(boolean corsEnabled) {
+ this.corsEnabled = corsEnabled;
+ }
+
+ public String getCorsOrigins() {
+ return corsOrigins;
+ }
+
+ /**
+ * Comma-separated list of origins (such as https://app.example.com)
allowed to call the embedded HTTP server. A
+ * request from an origin in the list is answered with
Access-Control-Allow-Origin and
+ * Access-Control-Allow-Credentials=true. When not set, the origin of
every request is allowed (reflected back),
+ * without credentials.
+ */
+ public void setCorsOrigins(String corsOrigins) {
+ this.corsOrigins = corsOrigins;
+ }
+
+ public String getCorsMethods() {
+ return corsMethods;
+ }
+
+ /**
+ * Comma-separated list of the HTTP methods (such as GET,POST) allowed in
a CORS request. When not set, the methods
+ * of the Access-Control-Request-Method header of the preflight request
are allowed.
+ */
+ public void setCorsMethods(String corsMethods) {
+ this.corsMethods = corsMethods;
+ }
+
+ public String getCorsHeaders() {
+ return corsHeaders;
+ }
+
+ /**
+ * Comma-separated list of the HTTP headers allowed in a CORS request.
When not set, the headers of the
+ * Access-Control-Request-Headers header of the preflight request are
allowed.
+ */
+ public void setCorsHeaders(String corsHeaders) {
+ this.corsHeaders = corsHeaders;
+ }
+
+ public String getCorsExposedHeaders() {
+ return corsExposedHeaders;
+ }
+
+ /**
+ * Comma-separated list of the HTTP response headers a browser may expose
to the calling script, sent as the
+ * Access-Control-Expose-Headers header.
+ */
+ public void setCorsExposedHeaders(String corsExposedHeaders) {
+ this.corsExposedHeaders = corsExposedHeaders;
+ }
+
+ public Long getCorsAccessControlMaxAge() {
+ return corsAccessControlMaxAge;
+ }
+
+ /**
+ * How long (in seconds) a browser may cache the answer of a preflight
request, sent as the Access-Control-Max-Age
+ * header. When not set, the header is not sent.
+ */
+ public void setCorsAccessControlMaxAge(Long corsAccessControlMaxAge) {
+ this.corsAccessControlMaxAge = corsAccessControlMaxAge;
+ }
+
+ public boolean isSessionEnabled() {
+ return sessionEnabled;
+ }
+
+ /**
+ * Whether the embedded HTTP server keeps a session for each client,
identified by a session cookie.
+ */
+ public void setSessionEnabled(boolean sessionEnabled) {
+ this.sessionEnabled = sessionEnabled;
+ }
+
+ public String getSessionStoreType() {
+ return sessionStoreType;
+ }
+
+ /**
+ * Where the sessions are stored: local (in memory of this application) or
clustered (in the cluster of a clustered
+ * Vert.x instance, which must be provided in the registry).
+ */
+ public void setSessionStoreType(String sessionStoreType) {
+ this.sessionStoreType = sessionStoreType;
+ }
+
+ public String getSessionCookieName() {
+ return sessionCookieName;
+ }
+
+ /**
+ * The name of the session cookie.
+ */
+ public void setSessionCookieName(String sessionCookieName) {
+ this.sessionCookieName = sessionCookieName;
+ }
+
+ public String getSessionCookiePath() {
+ return sessionCookiePath;
+ }
+
+ /**
+ * The path of the session cookie.
+ */
+ public void setSessionCookiePath(String sessionCookiePath) {
+ this.sessionCookiePath = sessionCookiePath;
+ }
+
+ public long getSessionTimeout() {
+ return sessionTimeout;
+ }
+
+ /**
+ * The time in milliseconds after which a session without activity expires.
+ */
+ public void setSessionTimeout(long sessionTimeout) {
+ this.sessionTimeout = sessionTimeout;
+ }
+
+ public boolean isSessionCookieSecure() {
+ return sessionCookieSecure;
+ }
+
+ /**
+ * Whether the session cookie has the Secure flag, so browsers only send
it over HTTPS.
+ */
+ public void setSessionCookieSecure(boolean sessionCookieSecure) {
+ this.sessionCookieSecure = sessionCookieSecure;
+ }
+
+ public boolean isSessionCookieHttpOnly() {
+ return sessionCookieHttpOnly;
+ }
+
+ /**
+ * Whether the session cookie has the HttpOnly flag, so scripts in the
browser cannot read it.
+ */
+ public void setSessionCookieHttpOnly(boolean sessionCookieHttpOnly) {
+ this.sessionCookieHttpOnly = sessionCookieHttpOnly;
+ }
+
+ public String getSessionCookieSameSite() {
+ return sessionCookieSameSite;
+ }
+
+ /**
+ * The SameSite attribute of the session cookie: strict, lax or none.
+ */
+ public void setSessionCookieSameSite(String sessionCookieSameSite) {
+ this.sessionCookieSameSite = sessionCookieSameSite;
+ }
+
+ public int getSessionIdMinLength() {
+ return sessionIdMinLength;
+ }
+
+ /**
+ * The minimum length of the session id.
+ */
+ public void setSessionIdMinLength(int sessionIdMinLength) {
+ this.sessionIdMinLength = sessionIdMinLength;
+ }
+
public boolean isUseGlobalSslContextParameters() {
return useGlobalSslContextParameters;
}
@@ -691,6 +938,153 @@ public class HttpServerConfigurationProperties implements
BootstrapCloseable {
return this;
}
+ /**
+ * Whether the form attributes of a request
(application/x-www-form-urlencoded or multipart/form-data) are merged
+ * into the request parameters.
+ */
+ public HttpServerConfigurationProperties withMergeFormAttributes(boolean
mergeFormAttributes) {
+ this.mergeFormAttributes = mergeFormAttributes;
+ return this;
+ }
+
+ /**
+ * Whether the uploaded files are deleted from the file upload directory
when the response has been sent.
+ */
+ public HttpServerConfigurationProperties
withDeleteUploadedFilesOnEnd(boolean deleteUploadedFilesOnEnd) {
+ this.deleteUploadedFilesOnEnd = deleteUploadedFilesOnEnd;
+ return this;
+ }
+
+ /**
+ * Whether the buffer for the request body is pre-allocated, using the
Content-Length header of the request to size
+ * it.
+ */
+ public HttpServerConfigurationProperties withPreallocateBodyBuffer(boolean
preallocateBodyBuffer) {
+ this.preallocateBodyBuffer = preallocateBodyBuffer;
+ return this;
+ }
+
+ /**
+ * Whether the embedded HTTP server handles CORS (Cross-Origin Resource
Sharing).
+ */
+ public HttpServerConfigurationProperties withCorsEnabled(boolean
corsEnabled) {
+ this.corsEnabled = corsEnabled;
+ return this;
+ }
+
+ /**
+ * Comma-separated list of origins allowed to call the embedded HTTP
server. When not set, the origin of every
+ * request is allowed (reflected back), without credentials.
+ */
+ public HttpServerConfigurationProperties withCorsOrigins(String
corsOrigins) {
+ this.corsOrigins = corsOrigins;
+ return this;
+ }
+
+ /**
+ * Comma-separated list of the HTTP methods allowed in a CORS request.
+ */
+ public HttpServerConfigurationProperties withCorsMethods(String
corsMethods) {
+ this.corsMethods = corsMethods;
+ return this;
+ }
+
+ /**
+ * Comma-separated list of the HTTP headers allowed in a CORS request.
+ */
+ public HttpServerConfigurationProperties withCorsHeaders(String
corsHeaders) {
+ this.corsHeaders = corsHeaders;
+ return this;
+ }
+
+ /**
+ * Comma-separated list of the HTTP response headers a browser may expose
to the calling script.
+ */
+ public HttpServerConfigurationProperties withCorsExposedHeaders(String
corsExposedHeaders) {
+ this.corsExposedHeaders = corsExposedHeaders;
+ return this;
+ }
+
+ /**
+ * How long (in seconds) a browser may cache the answer of a preflight
request.
+ */
+ public HttpServerConfigurationProperties withCorsAccessControlMaxAge(long
corsAccessControlMaxAge) {
+ this.corsAccessControlMaxAge = corsAccessControlMaxAge;
+ return this;
+ }
+
+ /**
+ * Whether the embedded HTTP server keeps a session for each client,
identified by a session cookie.
+ */
+ public HttpServerConfigurationProperties withSessionEnabled(boolean
sessionEnabled) {
+ this.sessionEnabled = sessionEnabled;
+ return this;
+ }
+
+ /**
+ * Where the sessions are stored: local or clustered.
+ */
+ public HttpServerConfigurationProperties withSessionStoreType(String
sessionStoreType) {
+ this.sessionStoreType = sessionStoreType;
+ return this;
+ }
+
+ /**
+ * The name of the session cookie.
+ */
+ public HttpServerConfigurationProperties withSessionCookieName(String
sessionCookieName) {
+ this.sessionCookieName = sessionCookieName;
+ return this;
+ }
+
+ /**
+ * The path of the session cookie.
+ */
+ public HttpServerConfigurationProperties withSessionCookiePath(String
sessionCookiePath) {
+ this.sessionCookiePath = sessionCookiePath;
+ return this;
+ }
+
+ /**
+ * The time in milliseconds after which a session without activity expires.
+ */
+ public HttpServerConfigurationProperties withSessionTimeout(long
sessionTimeout) {
+ this.sessionTimeout = sessionTimeout;
+ return this;
+ }
+
+ /**
+ * Whether the session cookie has the Secure flag, so browsers only send
it over HTTPS.
+ */
+ public HttpServerConfigurationProperties withSessionCookieSecure(boolean
sessionCookieSecure) {
+ this.sessionCookieSecure = sessionCookieSecure;
+ return this;
+ }
+
+ /**
+ * Whether the session cookie has the HttpOnly flag, so scripts in the
browser cannot read it.
+ */
+ public HttpServerConfigurationProperties withSessionCookieHttpOnly(boolean
sessionCookieHttpOnly) {
+ this.sessionCookieHttpOnly = sessionCookieHttpOnly;
+ return this;
+ }
+
+ /**
+ * The SameSite attribute of the session cookie: strict, lax or none.
+ */
+ public HttpServerConfigurationProperties withSessionCookieSameSite(String
sessionCookieSameSite) {
+ this.sessionCookieSameSite = sessionCookieSameSite;
+ return this;
+ }
+
+ /**
+ * The minimum length of the session id.
+ */
+ public HttpServerConfigurationProperties withSessionIdMinLength(int
sessionIdMinLength) {
+ this.sessionIdMinLength = sessionIdMinLength;
+ return this;
+ }
+
/**
* Whether to use global SSL configuration for securing the embedded HTTP
server.
*/