dc4eu / vc

European Wallet
BSD 2-Clause "Simplified" License
6 stars 9 forks source link

Validation of identity objects in /upload and PUT /document/identity #75

Open JuAlMan opened 3 months ago

JuAlMan commented 3 months ago

Using image docker.sunet.se/dc4eu/apigw:apiv28

When uploading a document or using the PUT /document/identity call for adding identities, it is possible to submit invalid identity objects like this:

"identities": [
        {
            "name": 2
        }
    ]

We propose that all identity objects in the array should be validated to make sure that all required attributes are set and the types are matching.

masv3971 commented 2 months ago

should be fixed with, https://github.com/dc4eu/vc/commit/e1ea46f3d3bd5e1393e1686af6d9c465efd1d4ca

JuAlMan commented 2 months ago

I tried with the same invalid identity object as i posted before, but still get no validation errors. The objects with the submitted identities array don't seem to be validated

masv3971 commented 1 month ago

When I tried with the above request, I got;

{
    "error": {
        "title": "validation_error",
        "details": [
            {
                "field": "authentic_source",
                "namespace": "authentic_source",
                "type": "string",
                "validation": "required",
                "validationParam": "",
                "value": ""
            },
            {
                "field": "document_type",
                "namespace": "document_type",
                "type": "string",
                "validation": "required",
                "validationParam": "",
                "value": ""
            },
            {
                "field": "document_id",
                "namespace": "document_id",
                "type": "string",
                "validation": "required",
                "validationParam": "",
                "value": ""
            }
        ]
    }
}
JuAlMan commented 1 month ago

I am sorry, i guess i didn't outline the problem precisely enough.

What i meant is that the identity objects in the array are not validated. So if i submit a request like

{
    "authentic_source": "data_existent_in_db",
    "document_type": "data_existent_in_db",
    "document_id": "data_existent_in_db",
    "identities": [
        {
            "name": 2
        }
    ]
}

This just works fine even though the submitted identity object is obviously not valid. Of course i get a validation error as well if i leave out any of the top-level attributes like document_id, etc.

Same behaviour with the upload call. So our request is that that every submitted identity object should be validated