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

NGSILD-Tenant Header Bad Request. Tenants are Strings and not IRIs. #1076

Closed
jason-fox opened this issue Jan 12, 2024 · 6 comments
Closed

NGSILD-Tenant Header Bad Request. Tenants are Strings and not IRIs. #1076

jason-fox opened this issue Jan 12, 2024 · 6 comments

Comments

@jason-fox
Copy link
Contributor

Stellio: 2.10.2

I create a new tenant with the name openiot

curl -L -X POST 'http://localhost:8080/ngsi-ld/v1/entityOperations/upsert/?options=update' \
-H 'Content-Type: application/ld+json' \
-H 'NGSILD-Tenant: openiot' \
--data-raw '[
        {
            "@context": "http://context/ngsi-context.jsonld",
            "id": "urn:ngsi-ld:Device:filling002",
            "type": "FillingLevelSensor",
            "filling": {
                "type": "Property",
                "value": 0.96,
                "unitCode": "C62",
                "accuracy": {
                    "type": "Property",
                    "value": 0.05
                },
                "observedAt": "2024-01-12T13:28:33.867Z"
            }
        }
    ]'

Stellio responds:

{
  "detail": "The supplied identifier was expected to be an URI but it is not: openiot (tenant)",
  "type": "https://uri.etsi.org/ngsi-ld/errors/BadRequestData",
  "title": "The request includes input data which does not meet the requirements of the operation"
}

Nowhere in the NGSI-LD specification is it stated that a tenant must be a URI - it is usually defined as a String, so openiot is valid:

6.3.14 Tenant specification

If the system implementing the NGSI-LD API supports multi-tenancy as described in clause 4.14 and clause 5.5.10, the
tenant, to which the NGSI-LD HTTP operation is targeted, is specified as the HTTP header "NGSILD-Tenant", whose
value is the String identifying the tenant.

Table 5.2.9-1: CSourceRegistration data type definition

  • tenant String - Identifies the tenant that has to be specified in all requests to the Context Source that are
    related to the information registered in this Context Source Registration

Compare this with id in the same table which is restricted to an IRI.

  • `id String Valid URI. - At creation time, if it is not provided, it will be assigned during registration process
@bobeal
Copy link
Member

bobeal commented Jan 12, 2024

Seems it has changed between 1.6.1 and 1.7.1, because 1.6.1 states in 6.3.14:

If the system implementing the NGSI-LD API supports multi-tenancy as described in clause 4.14 and clause 5.5.10, the
tenant, to which the NGSI-LD HTTP operation is targeted, is specified as the HTTP header "NGSILD-Tenant", whose
value is the tenant URI.

PS: Stellio does not support on-the-fly creation of tenants (which is an optional behavior, as said in 5.5.10): https://stellio.readthedocs.io/en/latest/user/multitenancy.html

@jason-fox
Copy link
Contributor Author

Fair point - it looks like the NGSI-LD spec has changed between 1.6.1. and 1.7.1

6.3.14 Tenant specification

If the system implementing the NGSI-LD API supports multi-tenancy as described in
clause 4.14 and clause 5.5.10, the tenant, to which the NGSI-LD HTTP operation is targeted, 
is specified as the HTTP header "NGSILD-Tenant", 
- whose value is the tenant URI. 
+ whose value is the String identifying the tenant. 
In case the target tenant is the default tenant, the HTTP header is omitted. 
If the HTTP header "NGSILD-Tenant" is present in the HTTP request, it shall also be present
in HTTP response. This also applies to HTTP notifications sent as a result of subscriptions 
with an "NGSILD-Tenant" HTTP header (clause 6.3.8).

@jason-fox
Copy link
Contributor Author

5.5.10 seems clear enough.

5.5..10

A tenant is represented in form of a String. How the tenant is specified for an API operation is protocol binding specific.
How tenants are created, is implementation-specific.
One implementation option is to support the implicit creation of tenants.

I'm trying to integrate an IoT Agent (which requires a Tenant) with Stellio.Two questions remain however:

  1. Can the Tenant name be loosened from a URI to a String somehow? (following 1.7.1)
  2. How to set up a docker-compose to set up a tenant as supported?

@bobeal
Copy link
Member

bobeal commented Jan 15, 2024

1. Can the Tenant name be loosened from a URI to a String somehow? (following 1.7.1)

On its way: #1081

As it is a feature and a (minor) breaking change (due to the renaming of tenant URI to tenant name in config properties), I will release a 2.11.0 for this. I already have a major PR to be merged today (#1073), so this one will come next (mid week if everything goes well with the other).

2. How to set up a `docker-compose` to set up a  tenant as supported?

I added more details in https://stellio.readthedocs.io/en/latest/user/multitenancy.html on how to do it (I will update it when the relaxing of tenant names is available). Let me know.

@bobeal
Copy link
Member

bobeal commented Jan 19, 2024

FYI, relaxing of tenants names has been merged and will be in the Stellio release planned for Monday (just in time for the FIWARE TSC ;) ). Doc is updated on https://stellio.readthedocs.io/en/latest/user/multitenancy.html.

@bobeal
Copy link
Member

bobeal commented Jan 27, 2024

2.11.0 has been released last Monday. The points discussed in the issue are addressed now.

Closing the issue, re-open if needed.

@bobeal bobeal closed this as completed Jan 27, 2024
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