summaryrefslogtreecommitdiff
path: root/doc/api
diff options
context:
space:
mode:
authorIzaak Alpert <ihalpert@blackberry.com>2013-03-28 14:37:44 -0400
committerIzaak Alpert <ialpert@blackberry.com>2013-09-09 12:04:38 -0400
commite86e8818327059279247db3a451994c6a62ab161 (patch)
tree5af04da559f21450b9c12d575f0fefe4958937b8 /doc/api
parent9ad5d9a4c6a3e292ddde7e46949f739eb63c746e (diff)
downloadgitlab-ce-e86e8818327059279247db3a451994c6a62ab161.tar.gz
API: admin users can sudo commands as other users
-Specifying a header of SUDO or adding a :sudo with either user id, or username of the user will set the current_user to be that user if your identifying private_token/PRIVATE_TOKEN is an administrator token
Diffstat (limited to 'doc/api')
-rw-r--r--doc/api/README.md36
1 files changed, 36 insertions, 0 deletions
diff --git a/doc/api/README.md b/doc/api/README.md
index 7668df07af1..6971e08f010 100644
--- a/doc/api/README.md
+++ b/doc/api/README.md
@@ -58,7 +58,43 @@ Return values:
* `409 Conflict` - A conflicting resource already exists, e.g. creating a project with a name that already exists
* `500 Server Error` - While handling the request something went wrong on the server side
+## Sudo
+All API requests support performing an api call as if you were another user, if your private token is for an administration account. You need to pass `sudo` parameter by url or header with an id or username of the user you want to perform the operation as. If passed as header, the header name must be "SUDO" (capitals).
+If a non administrative `private_token` is provided then an error message will be returned with status code 403:
+
+```json
+{
+ "message": "403 Forbidden: Must be admin to use sudo"
+}
+```
+
+If the sudo user id or username cannot be found then an error message will be returned with status code 404:
+
+```json
+{
+ "message": "404 Not Found: No user id or username for: <id/username>"
+}
+```
+
+Example of a valid API with sudo request:
+
+```
+GET http://example.com/api/v3/projects?private_token=QVy1PB7sTxfy4pqfZM1U&sudo=username
+```
+```
+GET http://example.com/api/v3/projects?private_token=QVy1PB7sTxfy4pqfZM1U&sudo=23
+```
+
+
+Example for a valid API request with sudo using curl and authentication via header:
+
+```
+curl --header "PRIVATE-TOKEN: QVy1PB7sTxfy4pqfZM1U" --header "SUDO: username" "http://example.com/api/v3/projects"
+```
+```
+curl --header "PRIVATE-TOKEN: QVy1PB7sTxfy4pqfZM1U" --header "SUDO: 23" "http://example.com/api/v3/projects"
+```
#### Pagination