Elffuss BraidHub

kikocis/EDC public

main · 8.2 KiBRenderedRawPermalink
1# EDC Data Plane EDR Handling and Extensibility
2
3A prerequisite for the changes described here
4is [Data Plane Signaling](data-plane-signaling.md).
5The signaling architecture transitions responsibility for EDR creation and data plane access token handling from Control
6Plane services to the Data Plane. As a companion to that work, the refactoring effort outlined in this document adds key
7features to access token handling in the Data Plane Framework (DPF). Specifically, the following will be introduced:
8
9- Client-side management and API for Endpoint Data References (EDR). Facilities for persisting and updating EDRs
10 received from data providers will be implemented. The API will provide a RESTful query interface to client
11 applications for retrieving EDRs.
12- An extension point for integrating custom authorization token handling. For example, a third-party authorization
13 server can be used to create and verify access tokens, or custom access logic can be introduced into the authorization
14 flow.
15
16> Note that the DPF also supports OAuth client authentication flows for accessing backend data sources and sinks. That
17> feature will not be affected by this refactoring.
18
19## 1. Client-Side EDR Management
20
21The Client EDC will expose an EDR API that provides operations to resolve EDRs as `DataAddress` types by asset ID,
22contract agreement ID, and transfer process ID.
23
24A modified version of
25the [EndpointDataReferenceCache‎](spi/edr-spi/src/main/java/org/eclipse/tractusx/edc/edr/spi/store/EndpointDataReferenceCache.java)
26and EDR API will be upstreamed to EDC as part of that work. The `EndpointDataReferenceCache` will receive and
27persist `EDRs` sent from provider control planes (e.g., when a transfer process has been `STARTED`). The EDR API is
28intended to be used by client applications to resolve `EDRs` granting access to provider data endpoints.
29
30> The API must be segmented from the rest of the management API using a separate API key or role (TBD).
31
32## 2. Updates to the`DataAddress` Format
33
34The format of the Data Address returned by the EDR API will be updated to align with the current DSP specifications (
35backward compatibility to the existing format should be maintained by retaining the previous fields):
36
37```json
38{
39 "dspace:dataAddress": {
40 "@type": "dspace:DataAddress",
41 "dspace:endpointType": "https://w3id.org/idsa/v4.1/HTTP",
42 "dspace:endpoint": "http://example.com",
43 "dspace:endpointProperties": [
44 {
45 "@type": "dspace:EndpointProperty",
46 "dspace:name": "https://w3id.org/edc/v0.0.1/ns/authorization",
47 "dspace:value": "token"
48 },
49 {
50 "@type": "dspace:EndpointProperty",
51 "dspace:name": "https://w3id.org/edc/v0.0.1/ns/authType",
52 "dspace:value": "bearer"
53 }
54 ]
55 }
56}
57```
58
59Support for the optional DSP `https://w3id.org/edc/v0.0.1/ns/authType` property will be added. If present, its value must be `bearer,` which indicates
60clients must present the contained token as a bearer token to the associated HTTP endpoint.
61
62_Note that all endpoints must be represented as URI-style strings._
63
64## 3. Data Plane Authorization
65
66Data Plane authorization involves creating an access token as part of the EDR when a `DataFlowStartMessage` is received
67and performing authorization checks against the token presented by the client when a data request is issued to the
68provider data plane.
69
70These operations will be encapsulated in the `DataPlaneAuthorizationService`:
71
72```java
73public interface DataPlaneAuthorizationService {
74 Result<DataAddress> createEndpointDataReference(DataFlowStartMessage message);
75
76 Result<DataAddress> authorize(String token, Map<String, Object> requestData);
77}
78```
79
80### Public endpoint resolution
81
82In addition to creating an access token (see next section), the data plane must determine the public endpoint, where
83consumers can obtain the data. In the case of HTTP, this would be the internet-facing HTTP URL of the data plane ("
84public url"), e.g. `"http://example.com"`, and the type would be `"https://w3id.org/idsa/v4.1/HTTP"`.
85This tuple consisting of `endpoint` and `endpointType` is determined by another service called
86a `PublicEndpointGenerator` (as public endpoints could be dynamically _generated_):
87
88```java
89public interface PublicEndpointGenerator {
90 Endpoint generateEndpoint(DataAddress sourceDataAddress);
91}
92
93public record Endpoint(String endpoint, String endpointType) {
94
95
96}
97```
98
99Note that the `endpoint` is represented as URI-style string. Thus, both `endpoint` and `endpointType` are _always_
100Strings. The shape of the `endpoint` is specific to each source type and must be documented out-of-band.
101
102### EDR and Token Creation
103
104When `DataPlaneAuthorizationService.createEndpointDataReference()` is invoked, the service will delegate to
105the `DataPlaneAccessTokenService.obtainToken()` to create the authorization token and package it in an EDR. There could
106be a separate `DataPlaneAccessTokenService` per `endpointType`, effectively enabling the data plane to generate
107different tokens for each transfer type.
108
109The `DataPlaneAccessTokenService` is a defined extensibility point that can be used to integrate third-party
110authorization servers:
111
112```java
113public interface DataPlaneAccessTokenService {
114 Result<TokenRepresentation> obtainToken(TokenParameters parameters, DataAddress address);
115
116 Result<AccessTokenData> resolve(String token);
117}
118
119public record AccessTokenData(ClaimToken claimToken, DataAddress address) {
120}
121```
122
123When `DataPlaneAccessTokenService.obtainToken()` is called, `TokenParameters` will contain (at least) the
124following claims:
125
126```java
127String participantId;
128String processId;
129String assetId;
130String agreementId;
131String transferType;
132```
133
134The returned `TokenRepresentation` may contain an additional parameter `tokenType` indicating the token type,
135e.g., `bearer`.
136
137Additional parameters may be added in the future so `DataPlaneAccessTokenService` implementations must take care to
138handle them.
139
140A default in-process `DataPlaneAccessTokenService` implementation will delegate to the existing `TokenGenerationService`
141and `TokenValidationService` using a custom token decorator context (`edc:dataplane`).
142
143The token creation flow is illustrated by the following sequence diagram:
144
145![](./data-plane-signaling_create-token.png)
146
147### Request Authorization
148
149Request authorization is performed when a client issues a request to the provider Data Plane by dispatching
150to `DataPlaneAuthorizationService.authorize()`. The `authorize` method takes the `token` and `requestData`, which
151encapsulates the token and transport-specific request information as a `Map`, e.g., the HTTP request path:
152
153```java
154 Result<DataAddress> authorize(String token, Map<String, Object> requestData);
155```
156
157`DataPlaneAuthorizationService.authorize`, in turn, will perform a two-step process.
158
159##### `AccessTokenData` Resolution
160
161First, the `DataPlaneAuthorizationService.authorize()` implementation will
162invoke `DataPlaneAccessTokenService.resolve()`
163to resolve the `AccessTokenData` containing the `DataAddress` and claims associated with the token:
164
165```java
166public record AccessTokenData(ClaimToken claimToken, DataAddress address) {
167
168}
169```
170
171The `ClaimToken` will contain the claims originally passed in the `TokenParameters` used to create the token:
172
173```java
174String participantId;
175String processId;
176String assetId;
177String agreementId;
178String transferType;
179```
180
181#### Authorization Check
182
183After the `AccessTokenData` is resolved, the `DataPlaneAuthorizationService.authorize` implementation will delegate
184to `DataPlaneAccessControlService.checkAccess`:
185
186```java
187public interface DataPlaneAccessControlService {
188 boolean checkAccess(ClaimToken claimToken, DataAddress address, Map<String, Object> requestData);
189}
190```
191
192The authorization flow is illustrated by the following sequence diagram:
193![](data-plane-signaling_authorize.png)
194
195A default implementation will be provided that always returns true. Extensions can supply alternative implementations
196that perform use-case-specific authorization checks.
197
198> Please note that `DataPlaneAccessControlService` implementation must handle all request types (including transport
199> types) in a data plane runtime. If multiple access check implementations are required, creating a multiplexer or
200> individual data plane runtimes is recommended.
201