Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ In summary, Spring Cloud Function instruments Java functions with additional fea
While the previous example shows you how to lookup a function in `FunctionCatalog` programmatically, in a typical integration case where Spring Cloud Function is used as the programming model by another framework (e.g. https://spring.io/projects/spring-cloud-stream[Spring Cloud Stream]), you can declare which functions to use via the `spring.cloud.function.definition` property.
It is important to know and understand the default behaviour when it comes to discovering functions in `FunctionCatalog`.

When using the web support, catalog lookup also determines which beans can be invoked over HTTP, including beans discovered as POJO functions.
The `spring.cloud.function.definition` property does not restrict HTTP access to other functions by name.
See xref:spring-cloud-function/standalone-web-applications.adoc#securing-function-endpoints[Securing Function Endpoints] for catalog exclusions and the application's responsibility for securing exposed endpoints.

For instance, if you only have one Functional bean in your `ApplicationContext`, the `spring.cloud.function.definition` property typically will not be required since a single function in `FunctionCatalog`
can be looked up by an empty name, or any name.
For example, assuming that `uppercase` is the only function in your catalog, it can be looked up as `catalog.lookup(null)`, `catalog.lookup(“”)`, `catalog.lookup(“foo”)`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ Functions could be automatically exported as HTTP endpoints.

The `spring-cloud-function-web` module has autoconfiguration that
activates when it is included in a Spring Boot web application (with
MVC support). There is also a `spring-cloud-starter-function-web` to
MVC or WebFlux support). There is also a `spring-cloud-starter-function-web` to
collect all the optional dependencies in case you just want a simple
getting started experience.

With the web configurations activated your app will have an MVC
With the web configurations activated your app will have an HTTP
endpoint (on "/" by default, but configurable with
`spring.cloud.function.web.path`) that can be used to access the
functions in the application context where function name becomes part of the URL path. The supported content types are
Expand Down Expand Up @@ -41,6 +41,36 @@ When POSTing text the response format might be different with Spring Boot 2.0 an

See <<Testing Functional Applications>> to see the details and example on how to test such application.

[[securing-function-endpoints]]
== Securing Function Endpoints

Spring Cloud Function is a framework for building applications, and applications built on it are responsible for their own security.
The web support does not authenticate or authorize requests to function endpoints.
Secure these endpoints in the application, for example with https://spring.io/projects/spring-security[Spring Security], or at a gateway or network layer.

With `spring-cloud-function-web` (MVC or WebFlux), the first path segment after the configured web path is used as a function name and looked up in `FunctionCatalog`.
By default, anything the catalog can resolve by that name is invocable over HTTP using the supported methods described above.
This includes beans that do not implement `Function`, `Supplier`, or `Consumer` but are discovered as POJO functions during catalog lookup.
Do not assume that only beans explicitly declared with these functional interfaces are reachable.

Use `spring.cloud.function.definition` to select the function or function composition the application intends to use as its default.
As explained in <<function-filtering-rules>>, this property is not an HTTP allowlist: other functions remain reachable by name.
Use `spring.cloud.function.ineligible-definitions` to exclude bean names from catalog lookup, including beans that could otherwise be discovered as POJO functions.

For example, in `application.properties`:

[source,properties]
----
spring.cloud.function.definition=uppercase
spring.cloud.function.ineligible-definitions=internalHelper,administrativeTask
----

This selects `uppercase` as the default and makes `internalHelper` and `administrativeTask` ineligible for catalog lookup.
It does not prevent access to other eligible functions, and neither property replaces authentication or authorization.
For additional HTTP method restrictions, see <<function-filtering-rules>>.

IMPORTANT: Before exposing Spring Cloud Function web endpoints on an untrusted network, secure them and review the beans present in the application context, including beans supplied by dependencies and auto-configuration.

[[http-request-parameters]]
== HTTP Request Parameters
As you have noticed from the previous table, you can pass an argument to a function as path variable (i.e., `/\{function}/\{item}`).
Expand Down