|
77 | 77 | import org.elasticsearch.xpack.core.ml.notifications.AuditorField;
|
78 | 78 | import org.elasticsearch.xpack.core.monitoring.action.MonitoringBulkAction;
|
79 | 79 | import org.elasticsearch.xpack.core.security.action.privilege.DeletePrivilegesAction;
|
| 80 | +import org.elasticsearch.xpack.core.security.action.privilege.DeletePrivilegesRequest; |
80 | 81 | import org.elasticsearch.xpack.core.security.action.privilege.GetPrivilegesAction;
|
| 82 | +import org.elasticsearch.xpack.core.security.action.privilege.GetPrivilegesRequest; |
81 | 83 | import org.elasticsearch.xpack.core.security.action.privilege.PutPrivilegesAction;
|
| 84 | +import org.elasticsearch.xpack.core.security.action.privilege.PutPrivilegesRequest; |
82 | 85 | import org.elasticsearch.xpack.core.security.action.role.PutRoleAction;
|
83 | 86 | import org.elasticsearch.xpack.core.security.action.saml.SamlAuthenticateAction;
|
84 | 87 | import org.elasticsearch.xpack.core.security.action.saml.SamlPrepareAuthenticationAction;
|
|
89 | 92 | import org.elasticsearch.xpack.core.security.authz.accesscontrol.IndicesAccessControl.IndexAccessControl;
|
90 | 93 | import org.elasticsearch.xpack.core.security.authz.permission.FieldPermissionsCache;
|
91 | 94 | import org.elasticsearch.xpack.core.security.authz.permission.Role;
|
| 95 | +import org.elasticsearch.xpack.core.security.authz.privilege.ApplicationPrivilegeDescriptor; |
92 | 96 | import org.elasticsearch.xpack.core.security.user.BeatsSystemUser;
|
93 | 97 | import org.elasticsearch.xpack.core.security.user.LogstashSystemUser;
|
94 | 98 | import org.elasticsearch.xpack.core.security.user.SystemUser;
|
|
108 | 112 | import org.joda.time.DateTimeZone;
|
109 | 113 |
|
110 | 114 | import java.util.Arrays;
|
| 115 | +import java.util.Collections; |
111 | 116 | import java.util.Map;
|
112 | 117 |
|
113 | 118 | import static org.hamcrest.Matchers.hasEntry;
|
@@ -192,10 +197,27 @@ public void testKibanaSystemRole() {
|
192 | 197 | assertThat(kibanaRole.cluster().check(InvalidateTokenAction.NAME, request), is(true));
|
193 | 198 | assertThat(kibanaRole.cluster().check(CreateTokenAction.NAME, request), is(false));
|
194 | 199 |
|
195 |
| - // Security |
196 |
| - assertThat(kibanaRole.cluster().check(DeletePrivilegesAction.NAME, request), is(false)); |
197 |
| - assertThat(kibanaRole.cluster().check(GetPrivilegesAction.NAME, request), is(true)); |
198 |
| - assertThat(kibanaRole.cluster().check(PutPrivilegesAction.NAME, request), is(true)); |
| 200 | + // Application Privileges |
| 201 | + DeletePrivilegesRequest deleteKibanaPrivileges = new DeletePrivilegesRequest("kibana-.kibana", new String[]{ "all", "read" }); |
| 202 | + DeletePrivilegesRequest deleteLogstashPrivileges = new DeletePrivilegesRequest("logstash", new String[]{ "all", "read" }); |
| 203 | + assertThat(kibanaRole.cluster().check(DeletePrivilegesAction.NAME, deleteKibanaPrivileges), is(true)); |
| 204 | + assertThat(kibanaRole.cluster().check(DeletePrivilegesAction.NAME, deleteLogstashPrivileges), is(false)); |
| 205 | + |
| 206 | + GetPrivilegesRequest getKibanaPrivileges = new GetPrivilegesRequest(); |
| 207 | + getKibanaPrivileges.application("kibana-.kibana-sales"); |
| 208 | + GetPrivilegesRequest getApmPrivileges = new GetPrivilegesRequest(); |
| 209 | + getApmPrivileges.application("apm"); |
| 210 | + assertThat(kibanaRole.cluster().check(GetPrivilegesAction.NAME, getKibanaPrivileges), is(true)); |
| 211 | + assertThat(kibanaRole.cluster().check(GetPrivilegesAction.NAME, getApmPrivileges), is(false)); |
| 212 | + |
| 213 | + PutPrivilegesRequest putKibanaPrivileges = new PutPrivilegesRequest(); |
| 214 | + putKibanaPrivileges.setPrivileges(Collections.singletonList(new ApplicationPrivilegeDescriptor( |
| 215 | + "kibana-.kibana-" + randomAlphaOfLengthBetween(2,6), "all", Collections.emptySet(), Collections.emptyMap()))); |
| 216 | + PutPrivilegesRequest putSwiftypePrivileges = new PutPrivilegesRequest(); |
| 217 | + putSwiftypePrivileges.setPrivileges(Collections.singletonList(new ApplicationPrivilegeDescriptor( |
| 218 | + "swiftype-kibana" , "all", Collections.emptySet(), Collections.emptyMap()))); |
| 219 | + assertThat(kibanaRole.cluster().check(PutPrivilegesAction.NAME, putKibanaPrivileges), is(true)); |
| 220 | + assertThat(kibanaRole.cluster().check(PutPrivilegesAction.NAME, putSwiftypePrivileges), is(false)); |
199 | 221 |
|
200 | 222 | // Everything else
|
201 | 223 | assertThat(kibanaRole.runAs().check(randomAlphaOfLengthBetween(1, 12)), is(false));
|
|
0 commit comments