eclipse-edc / Connector

EDC core services including data plane and control plane
Apache License 2.0
267 stars 226 forks source link

The new `/public/v2/` API endpoint is unexpectedly sending the `v2/` path segment to the backend #4072

Closed istvan-nagy-epam closed 5 months ago

istvan-nagy-epam commented 5 months ago

Bug Report

Describe the Bug

When using the new /public/v2/ API endpoint of the provider data plane while proxyPath is active for the asset, the v2/ is forwarded to the backend service as well.

Expected Behavior

  1. The request sent from EDC provider data plane to the backend service should not include the v2/ prefix. i.e., The backend URL should be <asset_base_url><proxied_path_starting_after_public_v2> for example: http://local-edc-wiremock:18080/pcf/api/carbon-footprint/00000000-aaaa-0000-0000-000000000001

Observed Behavior

  1. The request sent from EDC provider data plane to the backend service includes the v2/ prefix. i.e., The backend URL is <asset_base_url>v2/<proxied_path_starting_after_public_v2> for example: http://local-edc-wiremock:18080/pcf/v2/api/carbon-footprint/00000000-aaaa-0000-0000-000000000001

Steps to Reproduce

Steps to reproduce the behavior:

  1. Create an EDC asset using the "proxyPath": true property for the data address. e.g.,
{
    "@context": {
        "@vocab": "https://w3id.org/edc/v0.0.1/ns/"
    },
    "properties": {
        "description": "PCF asset for local EDC"
    },
    "privateProperties": {},
    "dataAddress": {
        "@type": "DataAddress",
        "type": "HttpData",
        "baseUrl": "http://local-edc-wiremock:18080/pcf/",
        "proxyPath": "true",
        "proxyBody": "true",
        "proxyMethod": "true",
        "proxyQueryParams": "true",
        "header:Accept": "application/json"
    }
}
  1. Perform all necessary to get ready for the data plane backend call (create policy, contract, negotiate, initiate transfer, edc.)
  2. Observe the endpoint and authorization attributes in the response which was sent by the GET http://local-edc-consumer-control-plane:9105/management/v2/edrs/{{edcTransferProcessId}}/dataaddress endpoint. For example:
    {
    "@type": "DataAddress",
    "type": "https://w3id.org/idsa/v4.1/HTTP",
    "endpoint": "http://local-edc-provider-data-plane:9051/public/v2",
    "https://w3id.org/tractusx/auth/refreshToken": "eyJraWQiOiJlYy1wdWJsaWMiLCJhbGciOiJFUzI1NiJ9.eyJleHAiOjE3MTIwNjE2NzYsImlhdCI6MTcxMjA2MTM3NiwianRpIjoiNzA1MzQ5NTktZDI4MC00M2U1LTk3NDYtMGQyOThlOGNkN2E0In0.K2zctgvGrENBBzrtl8GQhGHE-RLLCqinYaB8L4NwxyrtUXFp4SSAcF0q-L4KbmT1goA8aAE7VXk4n52bq4z3EQ",
    "https://w3id.org/tractusx/auth/expiresIn": "300",
    "endpointType": "https://w3id.org/idsa/v4.1/HTTP",
    "authorization": "eyJraWQiOiJlYy1wdWJsaWMiLCJhbGciOiJFUzI1NiJ9.eyJpc3MiOiJhbm9ueW1vdXMiLCJhdWQiOiJCUE5MMDAwMDAwMDAwMDBBIiwic3ViIjoiYW5vbnltb3VzIiwiZXhwIjoxNzEyMDYxNjc2LCJpYXQiOjE3MTIwNjEzNzYsImp0aSI6ImMwNmJlZmJmLThlZTgtNDIzMi1hYTQ2LTE0NGIxNWI5NWFiNyJ9.VZMYt9_GuWPT-vBapozTW7covIDpnXSnQmuuYtMlIMLCCKArk5bG-r4Lr8xzvqCeUJwjJ6k2UX2Wldwcjk6Mmg",
    "https://w3id.org/tractusx/auth/refreshEndpoint": "http://local-edc-provider-data-plane:9051/public",
    "@context": {
        "@vocab": "https://w3id.org/edc/v0.0.1/ns/",
        "edc": "https://w3id.org/edc/v0.0.1/ns/",
        "tx": "https://w3id.org/tractusx/v0.0.1/ns/",
        "odrl": "http://www.w3.org/ns/odrl/2/"
    }
    }
  3. Call the provider data plane URL using the endpoint and authorization attribute values from the previous step. For example:
    
    GET http://local-edc-provider-data-plane:9051/public/v2/api/carbon-footprint/00000000-aaaa-0000-0000-000000000001

Authorization: eyJraWQiOiJlYy1wdWJsaWMiLCJhbGciOiJFUzI1NiJ9.eyJpc3MiOiJhbm9ueW1vdXMiLCJhdWQiOiJCUE5MMDAwMDAwMDAwMDBBIiwic3ViIjoiYW5vbnltb3VzIiwiZXhwIjoxNzEyMDYxNjc2LCJpYXQiOjE3MTIwNjEzNzYsImp0aSI6ImMwNmJlZmJmLThlZTgtNDIzMi1hYTQ2LTE0NGIxNWI5NWFiNyJ9.VZMYt9_GuWPT-vBapozTW7covIDpnXSnQmuuYtMlIMLCCKArk5bG-r4Lr8xzvqCeUJwjJ6k2UX2Wldwcjk6Mmg


5. Observe the URL of the request received by the backend service.

## Context Information

- Used version [e.g. EDC v1.0.0]: Tractus-X EDC using 0.6.0 EDC dependencies
- OS: [e.g. iOS, Windows]: Mac (but should not be OS specific)

## Detailed Description

Please see the request log from the Wiremock backend service I have used below:
![Screenshot 2024-04-02 at 15 13 49](https://github.com/eclipse-edc/Connector/assets/15124019/d9006056-e510-462c-a8b1-f1d77a6da9c9)

## Possible Implementation

I think the full `/public/v2/` path prefix could be removed from the request path before proxying it.
github-actions[bot] commented 5 months ago

Thanks for your contribution :fire: We will take a look asap :rocket: