Writing (POST) to new REST api fails due to CSFR protection
baszoetekouw opened this issue · comments
When trying to create a new entity using the REST API with basic auth, like this:
curl -u user:geheim \
--data-binary @./sr_backup_eid=0885.json \
-H "Content-Type: application/json" \
-v \
https://serviceregistry.surfconext.nl/janus/app.php/api/connections.json
then SR/Janus replies with a 400 Bad Request:
{
"code": 400,
"errors": {
"children": {
"active": [],
"allowAllEntities": [],
"allowedConnections": [],
"arpAttributes": {
"children": {
"urn:mace:dir:attribute-def:cn": [],
"urn:mace:dir:attribute-def:displayName": [],
"urn:mace:dir:attribute-def:eduPersonAffiliation": [],
"urn:mace:dir:attribute-def:eduPersonEntitlement": [],
"urn:mace:dir:attribute-def:eduPersonPrincipalName": [],
"urn:mace:dir:attribute-def:eduPersonScopedAffiliation": [],
"urn:mace:dir:attribute-def:eduPersonTargetedID": [],
"urn:mace:dir:attribute-def:givenName": [],
"urn:mace:dir:attribute-def:isMemberOf": [],
"urn:mace:dir:attribute-def:mail": [],
"urn:mace:dir:attribute-def:preferredLanguage": [],
"urn:mace:dir:attribute-def:sn": [],
"urn:mace:dir:attribute-def:uid": [],
"urn:mace:surffederatie_nl:attribute-def:nlDigitalAuthorIdentifier": [],
"urn:mace:surffederatie_nl:attribute-def:nlEduPersonOrgUnit": [],
"urn:mace:surffederatie_nl:attribute-def:nlEduPersonStudyBranch": [],
"urn:mace:surffederatie_nl:attribute-def:nlStudielinkNummer": [],
"urn:mace:terena_org:attribute-def:schacHomeOrganization": [],
"urn:mace:terena_org:attribute-def:schacHomeOrganizationType": [],
"urn:oid:1_3_6_1_4_1_1076_20_40_40_1": []
}
},
"blockedConnections": [],
"createdAtDate": [],
"disableConsentConnections": [],
"expirationDate": {
"children": {
"date": {
"children": {
"day": [],
"month": [],
"year": []
}
},
"time": {
"children": {
"hour": [],
"minute": []
}
}
}
},
"id": [],
"isActive": [],
"manipulationCode": [],
"metadata": {
"children": {
"NameIDFormat": [],
"OrganizationDisplayName": {
"children": {
"en": [],
"nl": []
}
},
"OrganizationName": [],
"OrganizationURL": [],
"SingleLogoutService_Binding": [],
"SingleLogoutService_Location": [],
"SingleSignOnService": {
"children": [
{
"children": {
"Binding": [],
"Location": []
}
}
]
},
"certData": [],
"certData2": [],
"certData3": [],
"coin": {
"children": {
"additional_logging": [],
"disable_scoping": [],
"guest_qualifier": [],
"hidden": [],
"institution_id": [],
"publish_in_edugain": [],
"publish_in_edugain_date": [],
"schachomeorganization": []
}
},
"contacts": {
"children": [
{
"children": {
"contactType": [],
"emailAddress": [],
"givenName": [],
"surName": [],
"telephoneNumber": []
}
},
{
"children": {
"contactType": [],
"emailAddress": [],
"givenName": [],
"surName": [],
"telephoneNumber": []
}
},
{
"children": {
"contactType": [],
"emailAddress": [],
"givenName": [],
"surName": [],
"telephoneNumber": []
}
}
]
},
"description": {
"children": {
"en": [],
"nl": []
}
},
"displayName": [],
"keywords": {
"children": {
"en": [],
"nl": []
}
},
"logo": {
"children": [
{
"children": {
"height": [],
"url": [],
"width": []
}
}
]
},
"name": {
"children": {
"en": [],
"nl": []
}
},
"redirect": {
"children": {
"sign": []
}
},
"shibmd": {
"children": {
"scope": []
}
}
}
},
"metadataCacheUntil": {
"children": {
"date": {
"children": {
"day": [],
"month": [],
"year": []
}
},
"time": {
"children": {
"hour": [],
"minute": []
}
}
}
},
"metadataUrl": [],
"metadataValidUntil": {
"children": {
"date": {
"children": {
"day": [],
"month": [],
"year": []
}
},
"time": {
"children": {
"hour": [],
"minute": []
}
}
}
},
"name": [],
"notes": [],
"parentRevisionNr": [],
"revisionNote": [],
"revisionNr": [],
"state": [],
"type": [],
"updatedAtDate": [],
"updatedByUserName": [],
"updatedFromIp": []
},
"errors": [
"The CSRF token is invalid. Please try to resubmit the form."
]
},
"message": "Validation Failed"
}
The user used for authentication is defined in the Janus user panel.