Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to retrieve a federated, redirected context source using separate tenants. #1585

Open
jason-fox opened this issue Mar 18, 2024 · 1 comment
Assignees

Comments

@jason-fox
Copy link
Member

Internally forwarding from an endpoint to itself twice is detected as a loop even when it is not.

Two (and a half) issues here -

  1. A forwarding using two registrations with different contextSourceAlias but the same endpoint should not be a loop.
  2. A forwarding using two registrations with different tentant but the same endpoint should not be a loop.
  3. There is no indication in the response that a Loop may have occurred - Maybe add an NGSI-LD Warning header?

Create an Entity on the vet Tenant:

curl -iX POST \
  http://localhost:1026/ngsi-ld/v1/entities \
  -H 'Content-Type: application/ld+json' \
  -H 'NGSILD-Tenant: vet' \
  -d '{
    "id": "urn:ngsi-ld:Animal:cow103",
    "type": "Animal",
    "name": {
        "type": "Property",
        "value": "Buttercup"
    },
    "@context": "https://raw.githubusercontent.com/FIWARE/tutorials.Context-Providers/NGSI-LD/data-models/ngsi-context.jsonld"
}

Now add a registration on the farmer tenant

curl -L 'http://localhost:1026/ngsi-ld/v1/csourceRegistrations/' \
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json' \
-H 'NGSILD-Tenant: farmer' \
-H 'Content-Type: application/json' \
-d '{
    "type": "ContextSourceRegistration",
    "information": [
        {
            "entities": [
                {
                    "type": "Animal"
                }
            ]
        }
    ],
    "contextSourceAlias": "VET",
    "tenant": "vet",
    "mode": "inclusive",
    "operations": [
        "federationOps"
    ],
    "endpoint": "http://orion:1026"
}'

The Entity can be viewed from the farmer tenant. ✅

curl -L 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Animal:cow103' \
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json' \
-H 'Accept: application/ld+json' \
-H 'NGSILD-Tenant: farmer'

Result:

{
   "id": "urn:ngsi-ld:Animal:cow103",
    "type": "Animal",
   "name": {
        "type": "Property",
        "value": "Buttercup"
    }
}

Now add a second registration from the DEFAULT tenant

curl -L 'http://localhost:1026/ngsi-ld/v1/csourceRegistrations/' \
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json' \
-H 'Content-Type: application/json' \
-d '{
    "type": "ContextSourceRegistration",
    "information": [
        {
            "entities": [
                {
                    "type": "Animal"
                }
            ]
        }
    ],
    "contextSourceAlias": "FARMER",
    "tenant": "farmer",
    "mode": "redirect",
    "operations": [
        "redirectionOps"
    ],
    "endpoint": "http://orion:1026"
}'

The Entity cannot be viewed from the DEFAULT tenant. ❌

curl -L 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Animal:cow103' \
-H 'Link: <http://context/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json' \
-H 'Accept: application/ld+json' \
-H 'NGSILD-Tenant: farmer'

Result:

{
    "type": "https://uri.etsi.org/ngsi-ld/errors/ResourceNotFound",
    "title": "Entity not found",
    "detail": "urn:ngsi-ld:Animal:cow103"
}
@kzangeli kzangeli self-assigned this Apr 10, 2024
@kzangeli
Copy link
Collaborator

Yes, this twisted!:) example hasn't been implemented yet ...
The tenant name hasn't been included in the Via header and thus, the second time it enters the broker, it's considered a loop.
Easy fix, just include the tenant name in the "Via item"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants