Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Controls - Role Management API Docs #34854

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 73 additions & 8 deletions docs/api/role-management/get.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,15 @@ representation of the roles.
"cluster": [ ],
"run_as": [ ]
},
"kibana": [ {
"privileges": [ "all" ]
} ],
"kibana": [{
"base": [
"all"
],
"feature": {},
"spaces": [
"*"
]
}]
},
{
"name": "my_admin_role",
Expand Down Expand Up @@ -82,7 +88,7 @@ the `/api/security/role/<rolename>` endpoint:

[source,js]
--------------------------------------------------
GET /api/security/role/my_kibana_role
GET /api/security/role/my_restricted_kibana_role
--------------------------------------------------
// KIBANA

Expand All @@ -94,7 +100,7 @@ representation of the role.
[source,js]
--------------------------------------------------
{
"name": "my_kibana_role",
"name": "my_restricted_kibana_role",
"metadata" : {
"version" : 1
},
Expand All @@ -106,8 +112,67 @@ representation of the role.
"indices": [ ],
"run_as": [ ]
},
"kibana": [ {
"privileges": [ "all" ]
} ],
"kibana": [
{
"base": [
"read"
],
"feature": {},
"spaces": [
"marketing"
]
},
{
"base": [],
"feature": {
"discover": [
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feature list might be overkill, but I wanted to show an example of a really customized role definition. I can scale it back if that'd be better.

"all"
],
"visualize": [
"all"
],
"dashboard": [
"all"
],
"dev_tools": [
"read"
],
"advancedSettings": [
"read"
],
"indexPatterns": [
"read"
],
"timelion": [
"all"
],
"graph": [
"all"
],
"apm": [
"read"
],
"maps": [
"read"
],
"canvas": [
"read"
],
"infrastructure": [
"all"
],
"logs": [
"all"
],
"uptime": [
"all"
]
},
"spaces": [
"sales",
"default"
]
}
]
}
--------------------------------------------------
111 changes: 93 additions & 18 deletions docs/api/role-management/put.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,39 @@ that begin with `_` are reserved for system usage.
`elasticsearch`:: (object) Optional {es} cluster and index privileges, valid keys are
`cluster`, `indices` and `run_as`. For more information, see {xpack-ref}/defining-roles.html[Defining Roles].

`kibana`:: (object) An object that specifies the <<kibana-privileges>>. Valid keys are `global` and `space`. Privileges defined in the `global` key will apply to all spaces within Kibana, and will take precedent over any privileges defined in the `space` key. For example, specifying `global: ["all"]` will grant full access to all spaces within Kibana, even if the role indicates that a specific space should only have `read` privileges.
`kibana`:: (array) An array of objects which specify the <<kibana-privileges>> for this role:
legrego marked this conversation as resolved.
Show resolved Hide resolved
[source,js]
--------------------------------------------------
[{
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than explain all this in prose, I thought it'd be easier to understand if I just had a well-documented JSON snippet instead.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good idea. However, some of the lines are hard to read because of horizontal scrolling. I made an attempt to edit them down.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only concern is that we can't link to the "Kibana Privileges" section when using comments within the JSON. Perhaps we could mirror the way that Elasticsearch's role API docs implement the "index privileges": https://www.elastic.co/guide/en/elasticsearch/reference/7.0/security-api-put-role.html

// An optional base privilege.
// If specified, must either be ["all"] or ["read"].
// Privileges granted here cannot be revoked or downgraded via the `feature` section.
legrego marked this conversation as resolved.
Show resolved Hide resolved
// "all" grants read/write access to all features within Kibana for the specified spaces.
legrego marked this conversation as resolved.
Show resolved Hide resolved
// "read" grants read-only access to all featuers within Kibana for the specified spaces.
legrego marked this conversation as resolved.
Show resolved Hide resolved
"base": [],

// Object containing privileges for specific features.
// Privileges specified here will be added to the base privilege, if one was provided.
legrego marked this conversation as resolved.
Show resolved Hide resolved
// For example, specifying `base: ["read"]` will grant read access to every feature,
legrego marked this conversation as resolved.
Show resolved Hide resolved
// even if they aren't granted anything in this feature section.
legrego marked this conversation as resolved.
Show resolved Hide resolved
// Use the Features API to retrieve a list of available features <1>
legrego marked this conversation as resolved.
Show resolved Hide resolved
"feature": {
"advancedSettings": ["all"],
"discover": ["all"],
"visualize": ["all"],
"dashboard": ["read"]
},

// The spaces these privileges should be applied to.
// To grant access to all spaces, set this to `["*"]`, or omit the value altogether.
legrego marked this conversation as resolved.
Show resolved Hide resolved
"spaces": ["default", "marketing", "sales"]
}]
--------------------------------------------------

<1> <<features-api>>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: This relies on the Features API docs created in #34575


===== Example
===== Example 1
Granting read access to all features in all spaces, with full access to Advanced Settings.

[source,js]
--------------------------------------------------
Expand All @@ -54,22 +84,60 @@ PUT /api/security/role/my_kibana_role
"query" : "{\"match\": {\"title\": \"foo\"}}"
} ]
},
"kibana": {
"global": ["all"]
}
"kibana": [
{
"base": [
"read"
],
"feature": {
"advancedSettings": ["all"]
},
"spaces": [
"*"
]
}
]
}
--------------------------------------------------
// KIBANA

==== Response

A successful call returns a response code of `204` and no response body.
===== Example 2
Granting "dashboard only" access to only the Marketing space.

[source,js]
--------------------------------------------------
PUT /api/security/role/my_kibana_role
{
"metadata" : {
"version" : 1
},
"elasticsearch": {
legrego marked this conversation as resolved.
Show resolved Hide resolved
"cluster" : [ "all" ],
"indices" : [ {
"names" : [ "index1", "index2" ],
"privileges" : [ "all" ],
"field_security" : {
"grant" : [ "title", "body" ]
},
"query" : "{\"match\": {\"title\": \"foo\"}}"
} ]
},
"kibana": [
{
"base": [],
"feature": {
"dashboard": ["read"]
},
"spaces": [
"marketing"
]
}
]
}
--------------------------------------------------

==== Granting access to specific spaces
To grant access to individual spaces within {kib}, specify the space identifier within the `kibana` object.

Note: granting access
===== Example 3
Granting full access to all features in the Default space.

[source,js]
--------------------------------------------------
Expand All @@ -89,12 +157,19 @@ PUT /api/security/role/my_kibana_role
"query" : "{\"match\": {\"title\": \"foo\"}}"
} ]
},
"kibana": {
"global": [],
"space": {
"marketing": ["all"],
"engineering": ["read"]
"kibana": [
{
"base": ["all"],
"feature": {
},
"spaces": [
"default"
]
}
}
]
}
--------------------------------------------------

==== Response

A successful call returns a response code of `204` and no response body.
15 changes: 11 additions & 4 deletions docs/security/authorization/kibana-privileges.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,20 @@
=== Kibana privileges
legrego marked this conversation as resolved.
Show resolved Hide resolved

This section lists the Kibana privileges that you can assign to a role.
Privileges can be assigned at the following levels:
legrego marked this conversation as resolved.
Show resolved Hide resolved

`base`::
legrego marked this conversation as resolved.
Show resolved Hide resolved
Privileges assigned at the base level will grant access to all available features within Kibana (Discover, Visualize, Dashboard, etc).
legrego marked this conversation as resolved.
Show resolved Hide resolved

`feature`::
Privileges assigned at the feature level will grant access to a specific feature.
legrego marked this conversation as resolved.
Show resolved Hide resolved

For more information, consult the <<role-management-api-put, Role Management API>>
legrego marked this conversation as resolved.
Show resolved Hide resolved

[horizontal]
legrego marked this conversation as resolved.
Show resolved Hide resolved
[[kibana-privileges-all]]
`all`::
All Kibana privileges, can read, write and delete saved searches, dashboards, visualizations,
short URLs, Timelion sheets, graph workspaces, index patterns and advanced settings.
Grants full read-write access.

`read`::
Can read saved searches, dashboards, visualizations, short URLs, Timelion sheets, graph workspaces,
index patterns, and advanced settings.
Grants read-only access.