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

Consumer Credential as defined using default context-mapper default is invalid JSON-LD #53

Open
jason-fox opened this issue Feb 10, 2025 · 1 comment

Comments

@jason-fox
Copy link
Member

jason-fox commented Feb 10, 2025

Specifically, looking at:
https://github.com/FIWARE/data-space-connector/blob/main/k3s/consumer.yaml#L209-L210

"config": {
    "context": "https://www.w3.org/2018/credentials/v1",
    "supportedCredentialTypes": "VerifiableCredential,UserCredential,OperatorCredential"
}

Defines three terms - VerifiableCredential,UserCredential,OperatorCredential.

Looking at the supplied @context : https://www.w3.org/2018/credentials/v1 I can see that VerifiableCredential is a defined term within the context (it is actually an @protected term so it cannot be overwritten) but the user-defined terms UserCredential,OperatorCredential are not. Furthermore the dynamic mapped terms such as firstName, lastName, eMail and role are also not defined in the base context.

The claim appears as:

{
  "@context": [
    "https://www.w3.org/2018/credentials/v1"
    
  ],
  "type": [
    "VerifiableCredential",
    "OperatorCredential"
  ],
  "credentialSubject": {
    "firstName": "Alice",
    "lastName": "User",
    "eMail": "[email protected]",
    "roles": [ "OPERATOR"]
  }
}

Which expands to:

[
  {
    "https://www.w3.org/2018/credentials#credentialSubject": [
      {}
    ],
    "@type": [
      "https://www.w3.org/2018/credentials#VerifiableCredential",
      "OperatorCredential"
    ]
  }
]

Which drops all the useful stuff.

The correct JSON-LD is something like: "@context" : [ "https://www.w3.org/2018/credentials/v1", "some+other.jsonld"]
where some+other.jsonld maps to the missing terms

{
  "@context": [
    "https://www.w3.org/2018/credentials/v1",
    {
      "OperatorCredential": "https://example.org/OperatorCredential",
      "firstName": "https://schema.org/firstName",
      "lastName": "https://schema.org/lastName",
      "eMail": "https://schema.org/eMail",
      "roles": "https://example.org/roles"
    }
  ],
  "type": [
    "VerifiableCredential",
    "OperatorCredential"
  ],
  "credentialSubject": {
    "firstName": "Alice",
    "lastName": "User",
    "eMail": "[email protected]",
    "roles": [ "OPERATOR"]
  }
}

Which results in the following expansion:

[
  {
    "https://www.w3.org/2018/credentials#credentialSubject": [
      {
        "https://schema.org/eMail": [
          {"@value": "[email protected]"}
        ],
        "https://schema.org/firstName": [
          { "@value": "Alice"}
        ],
        "https://schema.org/lastName": [
          {"@value": "User"}
        ],
        "https://example.org/roles": [
          { "@value": "OPERATOR"}
        ]
      }
    ],
    "@type": [
      "https://www.w3.org/2018/credentials#VerifiableCredential",
      "https://example.org/OperatorCredential"
    ]
  }
]
@jason-fox
Copy link
Member Author

The simplest fix would be host an @context file on GH-Pages adding a file like claim-models.jsonld:

{
  "@context": {
      "OperatorCredential": "https://example.org/OperatorCredential",
      "firstName": "https://schema.org/firstName",
      "lastName": "https://schema.org/lastName",
      "eMail": "https://schema.org/eMail",
      "roles": "https://example.org/roles"
    }
}

And amendng the configuration to point to https://fiware.github.io/data-space-connector/claim-models.jsonld

 "context": ["https://www.w3.org/2018/credentials/v1",  "https://fiware.github.io/data-space-connector/claim-models.jsonld"]

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

1 participant