API: Restrict anonymous user information access (#18422)
Existing /api/alert-notifications now requires at least editor access. Existing /api/alert-notifiers now requires at least editor access. New /api/alert-notifications/lookup returns less information than /api/alert-notifications and can be access by any authenticated user. Existing /api/org/users now requires org admin role. New /api/org/users/lookup returns less information than /api/org/users and can be access by users that are org admins, admin in any folder or admin of any team. UserPicker component now uses /api/org/users/lookup instead of /api/org/users. Fixes #17318
This commit is contained in:
@@ -63,6 +63,48 @@ Content-Type: application/json
|
||||
|
||||
```
|
||||
|
||||
## Get all notification channels (lookup)
|
||||
|
||||
Returns all notification channels, but with less detailed information.
|
||||
Accessible by any authenticated user and is mainly used by providing
|
||||
alert notification channels in Grafana UI when configuring alert rule.
|
||||
|
||||
`GET /api/alert-notifications/lookup`
|
||||
|
||||
**Example Request**:
|
||||
|
||||
```http
|
||||
GET /api/alert-notifications/lookup HTTP/1.1
|
||||
Accept: application/json
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
||||
```
|
||||
|
||||
**Example Response**:
|
||||
|
||||
```http
|
||||
HTTP/1.1 200
|
||||
Content-Type: application/json
|
||||
|
||||
[
|
||||
{
|
||||
"id": 1,
|
||||
"uid": "000000001",
|
||||
"name": "Test",
|
||||
"type": "email",
|
||||
"isDefault": false
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"uid": "000000002",
|
||||
"name": "Slack",
|
||||
"type": "slack",
|
||||
"isDefault": false
|
||||
}
|
||||
]
|
||||
|
||||
```
|
||||
|
||||
## Get notification channel by uid
|
||||
|
||||
`GET /api/alert-notifications/uid/:uid`
|
||||
|
||||
@@ -47,6 +47,9 @@ Content-Type: application/json
|
||||
|
||||
`GET /api/org/users`
|
||||
|
||||
Returns all org users within the current organization.
|
||||
Accessible to users with org admin role.
|
||||
|
||||
**Example Request**:
|
||||
|
||||
```http
|
||||
@@ -64,11 +67,47 @@ Content-Type: application/json
|
||||
|
||||
[
|
||||
{
|
||||
"orgId":1,
|
||||
"userId":1,
|
||||
"email":"admin@mygraf.com",
|
||||
"login":"admin",
|
||||
"role":"Admin"
|
||||
"orgId": 1,
|
||||
"userId": 1,
|
||||
"email": "admin@localhost",
|
||||
"avatarUrl": "/avatar/46d229b033af06a191ff2267bca9ae56",
|
||||
"login": "admin",
|
||||
"role": "Admin",
|
||||
"lastSeenAt": "2019-08-09T11:02:49+02:00",
|
||||
"lastSeenAtAge": "< 1m"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
### Get all users within the current organization (lookup)
|
||||
|
||||
`GET /api/org/users/lookup`
|
||||
|
||||
Returns all org users within the current organization, but with less detailed information.
|
||||
Accessible to users with org admin role, admin in any folder or admin of any team.
|
||||
Mainly used by Grafana UI for providing list of users when adding team members and
|
||||
when editing folder/dashboard permissions.
|
||||
|
||||
**Example Request**:
|
||||
|
||||
```http
|
||||
GET /api/org/users/lookup HTTP/1.1
|
||||
Accept: application/json
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
||||
```
|
||||
|
||||
**Example Response**:
|
||||
|
||||
```http
|
||||
HTTP/1.1 200
|
||||
Content-Type: application/json
|
||||
|
||||
[
|
||||
{
|
||||
"userId": 1,
|
||||
"login": "admin",
|
||||
"avatarUrl": "/avatar/46d229b033af06a191ff2267bca9ae56"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user