Elffuss BraidHub

kikocis/EDC public

main · 3.3 KiBRenderedRawPermalink
1# Jetty
2
3This extension provides a `JettyService`, a Servlet Context Container that can expose REST API on a Jersey based
4WebServer.
5
6## Terminate SSL in the connector runtime
7
8While it is generally advised to handle HTTPS/SSL/TLS termination through deployment mechanisms such as
9Kubernetes, or an API gateway, there are situations where SSL termination directly in the connector is
10needed.
11
12In order to do that, users must set up a Java keystore (
13see [Jetty documentation](https://www.eclipse.org/jetty/documentation/jetty-10/operations-guide/index.html#og-keystore))
14that contains the certificate. Both official and self-signed certificates work.
15
16The following Java properties can be used to configure Jetty to actually use the keystore:
17
18| Config Key | Description | Required | Default |
19|-----------------------------------|---------------------------------------------------------------|----------|------------|
20| `edc.web.https.keystore.password` | Password for the keystore | yes | "password" |
21| `edc.web.https.keymanager.password` | Password for the private key | yes | "password" |
22| `edc.web.https.keystore.path` | Absolute path on the filesystem where the keystore is located | yes | null |
23| `edc.web.https.keystore.type` | Type of keystore, could be "JKS" or "PKCS12" | no | "PKCS12" |
24
25## Expose different web contexts
26
27By default we have the `web.http.port`
28and `web.http.path` config entry with the following default values:
29
30```properties
31web.http.port=8181
32web.http.path=/api
33```
34
35That will expose any resource under `http://<host>:8181/api/*`.
36
37_Please note that under the hood `web.http.*` gets expanded to `web.http.default.*`_
38
39In some situations it is required to expose a part of the public API under another port or path, which can be achieved
40by using port mappings. First, a "named"
41property group needs to be created using the following configuration. The example will create a port mapping with the
42name/alias `"health"`:
43
44```properties
45web.http.health.port=9191
46web.http.health.path=/api/v1/health
47```
48
49Second, the resource must be registered using that context alias (`"health"`):
50
51```java
52public class YourExtension {
53
54 @Inject
55 private WebService webService;
56
57 void initialize(ServiceExtensionContext context) {
58 //...
59 webService.registerResource("health", new HealthController());
60 }
61}
62```
63
64which will expose any resources that the `HealthController` provides under `http://<host>:9191/api/v1/health/*`
65
66## Best practice
67
68In situations where an API is made up of multiple controllers, it is best to expose the APIs base path using this
69mechanism, register the controllers with the
70port mapping's context alias and have the controllers themselves handle any sub-paths.
71
72## Limitations
73
74- Attempting to register two port mappings with the same port will raise an exception. This also takes into account the
75 implicit default values
76- Attempting to register two port mappings with the same path will raise an exception, even if different ports are used.
77 This has to do with the way how servlet
78 contexts are mapped internally and may change in future releases.