| 1 | # EDC Data Plane EDR Handling and Extensibility |
| 2 | |
| 3 | A prerequisite for the changes described here |
| 4 | is [Data Plane Signaling](data-plane-signaling.md). |
| 5 | The signaling architecture transitions responsibility for EDR creation and data plane access token handling from Control |
| 6 | Plane services to the Data Plane. As a companion to that work, the refactoring effort outlined in this document adds key |
| 7 | features 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 | |
| 21 | The Client EDC will expose an EDR API that provides operations to resolve EDRs as `DataAddress` types by asset ID, |
| 22 | contract agreement ID, and transfer process ID. |
| 23 | |
| 24 | A modified version of |
| 25 | the [EndpointDataReferenceCache](spi/edr-spi/src/main/java/org/eclipse/tractusx/edc/edr/spi/store/EndpointDataReferenceCache.java) |
| 26 | and EDR API will be upstreamed to EDC as part of that work. The `EndpointDataReferenceCache` will receive and |
| 27 | persist `EDRs` sent from provider control planes (e.g., when a transfer process has been `STARTED`). The EDR API is |
| 28 | intended 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 | |
| 34 | The format of the Data Address returned by the EDR API will be updated to align with the current DSP specifications ( |
| 35 | backward 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 | |
| 59 | Support 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 |
| 60 | clients 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 | |
| 66 | Data Plane authorization involves creating an access token as part of the EDR when a `DataFlowStartMessage` is received |
| 67 | and performing authorization checks against the token presented by the client when a data request is issued to the |
| 68 | provider data plane. |
| 69 | |
| 70 | These operations will be encapsulated in the `DataPlaneAuthorizationService`: |
| 71 | |
| 72 | ```java |
| 73 | public 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 | |
| 82 | In addition to creating an access token (see next section), the data plane must determine the public endpoint, where |
| 83 | consumers can obtain the data. In the case of HTTP, this would be the internet-facing HTTP URL of the data plane (" |
| 84 | public url"), e.g. `"http://example.com"`, and the type would be `"https://w3id.org/idsa/v4.1/HTTP"`. |
| 85 | This tuple consisting of `endpoint` and `endpointType` is determined by another service called |
| 86 | a `PublicEndpointGenerator` (as public endpoints could be dynamically _generated_): |
| 87 | |
| 88 | ```java |
| 89 | public interface PublicEndpointGenerator { |
| 90 | Endpoint generateEndpoint(DataAddress sourceDataAddress); |
| 91 | } |
| 92 | |
| 93 | public record Endpoint(String endpoint, String endpointType) { |
| 94 | |
| 95 | |
| 96 | } |
| 97 | ``` |
| 98 | |
| 99 | Note that the `endpoint` is represented as URI-style string. Thus, both `endpoint` and `endpointType` are _always_ |
| 100 | Strings. 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 | |
| 104 | When `DataPlaneAuthorizationService.createEndpointDataReference()` is invoked, the service will delegate to |
| 105 | the `DataPlaneAccessTokenService.obtainToken()` to create the authorization token and package it in an EDR. There could |
| 106 | be a separate `DataPlaneAccessTokenService` per `endpointType`, effectively enabling the data plane to generate |
| 107 | different tokens for each transfer type. |
| 108 | |
| 109 | The `DataPlaneAccessTokenService` is a defined extensibility point that can be used to integrate third-party |
| 110 | authorization servers: |
| 111 | |
| 112 | ```java |
| 113 | public interface DataPlaneAccessTokenService { |
| 114 | Result<TokenRepresentation> obtainToken(TokenParameters parameters, DataAddress address); |
| 115 | |
| 116 | Result<AccessTokenData> resolve(String token); |
| 117 | } |
| 118 | |
| 119 | public record AccessTokenData(ClaimToken claimToken, DataAddress address) { |
| 120 | } |
| 121 | ``` |
| 122 | |
| 123 | When `DataPlaneAccessTokenService.obtainToken()` is called, `TokenParameters` will contain (at least) the |
| 124 | following claims: |
| 125 | |
| 126 | ```java |
| 127 | String participantId; |
| 128 | String processId; |
| 129 | String assetId; |
| 130 | String agreementId; |
| 131 | String transferType; |
| 132 | ``` |
| 133 | |
| 134 | The returned `TokenRepresentation` may contain an additional parameter `tokenType` indicating the token type, |
| 135 | e.g., `bearer`. |
| 136 | |
| 137 | Additional parameters may be added in the future so `DataPlaneAccessTokenService` implementations must take care to |
| 138 | handle them. |
| 139 | |
| 140 | A default in-process `DataPlaneAccessTokenService` implementation will delegate to the existing `TokenGenerationService` |
| 141 | and `TokenValidationService` using a custom token decorator context (`edc:dataplane`). |
| 142 | |
| 143 | The token creation flow is illustrated by the following sequence diagram: |
| 144 | |
| 145 |  |
| 146 | |
| 147 | ### Request Authorization |
| 148 | |
| 149 | Request authorization is performed when a client issues a request to the provider Data Plane by dispatching |
| 150 | to `DataPlaneAuthorizationService.authorize()`. The `authorize` method takes the `token` and `requestData`, which |
| 151 | encapsulates 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 | |
| 161 | First, the `DataPlaneAuthorizationService.authorize()` implementation will |
| 162 | invoke `DataPlaneAccessTokenService.resolve()` |
| 163 | to resolve the `AccessTokenData` containing the `DataAddress` and claims associated with the token: |
| 164 | |
| 165 | ```java |
| 166 | public record AccessTokenData(ClaimToken claimToken, DataAddress address) { |
| 167 | |
| 168 | } |
| 169 | ``` |
| 170 | |
| 171 | The `ClaimToken` will contain the claims originally passed in the `TokenParameters` used to create the token: |
| 172 | |
| 173 | ```java |
| 174 | String participantId; |
| 175 | String processId; |
| 176 | String assetId; |
| 177 | String agreementId; |
| 178 | String transferType; |
| 179 | ``` |
| 180 | |
| 181 | #### Authorization Check |
| 182 | |
| 183 | After the `AccessTokenData` is resolved, the `DataPlaneAuthorizationService.authorize` implementation will delegate |
| 184 | to `DataPlaneAccessControlService.checkAccess`: |
| 185 | |
| 186 | ```java |
| 187 | public interface DataPlaneAccessControlService { |
| 188 | boolean checkAccess(ClaimToken claimToken, DataAddress address, Map<String, Object> requestData); |
| 189 | } |
| 190 | ``` |
| 191 | |
| 192 | The authorization flow is illustrated by the following sequence diagram: |
| 193 |  |
| 194 | |
| 195 | A default implementation will be provided that always returns true. Extensions can supply alternative implementations |
| 196 | that 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 | |