Skip to content

Commit d245164

Browse files
committed
Add documentation and information to the swagger api
Signed-off-by: Andrew Thornton <[email protected]>
1 parent f8ebfd2 commit d245164

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

docs/content/doc/advanced/api-usage.en-us.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,7 @@ using BasicAuth, as follows:
7373
$ curl --request GET --url https://yourusername:[email protected]/api/v1/users/yourusername/tokens
7474
[{"name":"test","sha1":"..."},{"name":"dev","sha1":"..."}]
7575
```
76+
77+
## Sudo
78+
79+
The API allows admin users to sudo API requests as another user. Simply add either a `sudo=` parameter or `Sudo:` request header with the username of the user to sudo.

routers/api/v1/api.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
// - Token :
2525
// - AccessToken :
2626
// - AuthorizationHeaderToken :
27+
// - SudoParam :
28+
// - SudoHeader :
2729
//
2830
// SecurityDefinitions:
2931
// BasicAuth:
@@ -40,6 +42,16 @@
4042
// type: apiKey
4143
// name: Authorization
4244
// in: header
45+
// SudoParam:
46+
// type: apiKey
47+
// name: sudo
48+
// in: query
49+
// description: Sudo API request as the user provided as the key. Admin privileges are required.
50+
// SudoHeader:
51+
// type: apiKey
52+
// name: Sudo
53+
// in: header
54+
// description: Sudo API request as the user provided as the key. Admin privileges are required.
4355
//
4456
// swagger:meta
4557
package v1

templates/swagger/v1_json.tmpl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8008,6 +8008,18 @@
80088008
"BasicAuth": {
80098009
"type": "basic"
80108010
},
8011+
"SudoHeader": {
8012+
"description": "Sudo API request as the user provided as the key. Admin privileges are required.",
8013+
"type": "apiKey",
8014+
"name": "Sudo",
8015+
"in": "header"
8016+
},
8017+
"SudoParam": {
8018+
"description": "Sudo API request as the user provided as the key. Admin privileges are required.",
8019+
"type": "apiKey",
8020+
"name": "sudo",
8021+
"in": "query"
8022+
},
80118023
"Token": {
80128024
"type": "apiKey",
80138025
"name": "token",
@@ -8026,6 +8038,12 @@
80268038
},
80278039
{
80288040
"AuthorizationHeaderToken": []
8041+
},
8042+
{
8043+
"SudoParam": []
8044+
},
8045+
{
8046+
"SudoHeader": []
80298047
}
80308048
]
80318049
}

0 commit comments

Comments
 (0)