PKI CA Add User REST API - dogtagpki/pki GitHub Wiki
-
Method:
POST -
Path:
/ca/rest/admin/users -
Authentication: Client certificate
curl -k -X POST -H "Content-Type:application/json" -H "Accept: application/json" -d '{"id":"qwertty","UserID":"asdtfg","FullName":"ctas","Link":{"rel":"self","href":"https://localhost.localdomain:8443/ca/rest/admin/users/qwerty","type":"application/xml"},"Attributes":{"Attribute":[]}}' --user caadmin:Secret.123 -s https://localhost.localdomain:8443/ca/rest/admin/users | python -m json.tool
{
"id": "asdtfg",
"UserID": "asdtfg",
"FullName": "ctas",
"Link": {
"rel": "self",
"href": "https://localhost.localdomain:8443/ca/rest/admin/users/asdtfg",
"type": "application/xml"
},
"Attributes": {
"Attribute": []
}
}
Run a second time and the server rejects the duplicate request:
curl -k -X POST -H "Content-Type:application/json" -H "Accept: application/json" -d '{"id":"qwertty","UserID":"asdtfg","FullName":"ctas","Link":{"rel":"self","href":"https://localhost.localdomain:8443/ca/rest/admin/users/qwerty","type":"application/xml"},"Attributes":{"Attribute":[]}}' --user caadmin:Secret.123 -s https://localhost.localdomain:8443/ca/rest/admin/users | python -m json.tool
{
"Attributes": {
"Attribute": []
},
"ClassName": "com.netscape.certsrv.base.ConflictingOperationException",
"Code": 409,
"Message": "Entry already exists."
}
To add a CA user using PKI CLI:
$ pki -n caadmin --message-format json --output tmp ca-user-add testuser --fullName "Test User"The request will be stored in tmp/http-request-3:
POST /ca/rest/admin/users HTTP/1.1
Accept: application/json
Content-Type: application/json
...
{
"UserID": "testuser",
"FullName": "Test User",
"Attributes": {
"Attribute": []
}
}The response will be stored in tmp/http-response-3:
HTTP/1.1 201
Location: https://localhost.localdomain:8443/ca/rest/admin/users/testuser
Content-Type: application/json
...
{
"id": "testuser",
"UserID": "testuser",
"FullName": "Test User",
"Link": {
"rel": "self",
"href": "https://localhost.localdomain:8443/ca/rest/admin/users/testuser",
"type": "application/xml"
},
"Attributes": {
"Attribute": []
}
}