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

WIldcard IndicesPermissions don't cover .security #36765

Closed
Closed
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
fa07a97
Names
albertzaharovits Dec 18, 2018
c12fa0e
getting there
albertzaharovits Dec 18, 2018
59ff695
HashCode and trimms
albertzaharovits Dec 18, 2018
536640d
HasPrivilege
albertzaharovits Dec 18, 2018
4ee6cbd
Husling
albertzaharovits Dec 18, 2018
ac9ec5a
ReservedRolesStore
albertzaharovits Dec 18, 2018
52e7c2a
Merge branch 'master' into strict_privilege_take_3
albertzaharovits Dec 18, 2018
c806970
Trimming
albertzaharovits Dec 18, 2018
c7f7f2b
AuthorizedIndices remove hack + tests
albertzaharovits Dec 19, 2018
f77fff1
More tests and checkstyle
albertzaharovits Dec 19, 2018
2e92793
Javadoc and renames
albertzaharovits Dec 19, 2018
6750306
two comments
albertzaharovits Dec 19, 2018
b6ea0b3
import static
albertzaharovits Dec 19, 2018
527a22e
import static
albertzaharovits Dec 19, 2018
82577ba
Merge branch 'backup_security_index' into strict_privilege_take_3
albertzaharovits Dec 20, 2018
4340bcc
Merge branch 'backup_security_index' into strict_privilege_take_3
albertzaharovits Dec 24, 2018
2a3f38d
Fix check
albertzaharovits Dec 25, 2018
aadd062
Implicit authorize monitoring passthrough
albertzaharovits Dec 25, 2018
d63577d
import static
albertzaharovits Dec 26, 2018
7759040
Merge branch 'backup_security_index' into strict_privilege_take_3
albertzaharovits Jan 8, 2019
eaa4eb2
Merge branch 'master' into strict_privilege_take_3
albertzaharovits Jan 9, 2019
ee7e2c2
review nits
albertzaharovits Jan 9, 2019
d6191cf
Compilation minor error
albertzaharovits Jan 9, 2019
55aefb6
Merge branch 'master' into strict_privilege_take_3
albertzaharovits Jan 15, 2019
9f6c739
RoleDescriptor allow_restricted_indices
albertzaharovits Jan 15, 2019
e50ebfc
Mapping
albertzaharovits Jan 15, 2019
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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.elasticsearch.xpack.core.security.authz.permission.Role;
import org.elasticsearch.xpack.core.security.authz.privilege.ConditionalClusterPrivilege;
import org.elasticsearch.xpack.core.security.authz.privilege.ConditionalClusterPrivileges.ManageApplicationPrivileges;
import org.elasticsearch.xpack.core.security.index.SystemIndicesNames;
import org.elasticsearch.xpack.core.security.support.MetadataUtils;
import org.elasticsearch.xpack.core.security.user.KibanaUser;
import org.elasticsearch.xpack.core.security.user.UsernamesField;
Expand All @@ -32,7 +33,9 @@ public class ReservedRolesStore implements BiConsumer<Set<String>, ActionListene
public static final RoleDescriptor SUPERUSER_ROLE_DESCRIPTOR = new RoleDescriptor("superuser",
new String[] { "all" },
new RoleDescriptor.IndicesPrivileges[] {
RoleDescriptor.IndicesPrivileges.builder().indices("*").privileges("all").build()},
RoleDescriptor.IndicesPrivileges.builder().indices("*").privileges("all").build(),
RoleDescriptor.IndicesPrivileges.builder().indices(SystemIndicesNames.indexNames().toArray(new String[0]))
.privileges("all").build() },
Copy link
Contributor

Choose a reason for hiding this comment

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

This should have allowRestrictedIndices(true)

new RoleDescriptor.ApplicationResourcePrivileges[] {
RoleDescriptor.ApplicationResourcePrivileges.builder().application("*").privileges("*").resources("*").build()
},
Expand All @@ -43,11 +46,7 @@ public class ReservedRolesStore implements BiConsumer<Set<String>, ActionListene

private static Map<String, RoleDescriptor> initializeReservedRoles() {
return MapBuilder.<String, RoleDescriptor>newMapBuilder()
.put("superuser", new RoleDescriptor("superuser", new String[] { "all" },
new RoleDescriptor.IndicesPrivileges[] {
RoleDescriptor.IndicesPrivileges.builder().indices("*").privileges("all").build()},
new String[] { "*" },
MetadataUtils.DEFAULT_RESERVED_METADATA))
.put("superuser", SUPERUSER_ROLE_DESCRIPTOR)
.put("transport_client", new RoleDescriptor("transport_client", new String[] { "transport_client" }, null, null,
MetadataUtils.DEFAULT_RESERVED_METADATA))
.put("kibana_user", new RoleDescriptor("kibana_user", null, new RoleDescriptor.IndicesPrivileges[] {
Expand Down Expand Up @@ -83,6 +82,8 @@ private static Map<String, RoleDescriptor> initializeReservedRoles() {
},
new RoleDescriptor.IndicesPrivileges[] {
RoleDescriptor.IndicesPrivileges.builder().indices("*").privileges("monitor").build(),
RoleDescriptor.IndicesPrivileges.builder().indices(SystemIndicesNames.indexNames().toArray(new String[0]))
.privileges("monitor").build(),
RoleDescriptor.IndicesPrivileges.builder().indices(".kibana*").privileges("read").build()
},
null,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

package org.elasticsearch.xpack.core.security.index;

import org.elasticsearch.xpack.core.upgrade.IndexUpgradeCheckVersion;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

public final class SystemIndicesNames {

public static final String AUDIT_INDEX_NAME_PREFIX = ".security_audit_log";
public static final String INTERNAL_SECURITY_INDEX = ".security-" + IndexUpgradeCheckVersion.UPRADE_VERSION;
public static final String SECURITY_INDEX_NAME = ".security";
private static final Set<String> index_names;

static {
Set<String> indexNames = new HashSet<>();
indexNames.add(SECURITY_INDEX_NAME);
indexNames.add(INTERNAL_SECURITY_INDEX);
index_names = Collections.unmodifiableSet(indexNames);
}

public static Set<String> indexNames() {
return index_names;
}

private SystemIndicesNames() {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import org.elasticsearch.xpack.core.security.authz.RoleDescriptor;
import org.elasticsearch.xpack.core.security.authz.permission.Role;
import org.elasticsearch.xpack.core.security.index.IndexAuditTrailField;
import org.elasticsearch.xpack.core.security.index.SystemIndicesNames;
import org.elasticsearch.xpack.core.security.support.MetadataUtils;

/**
Expand All @@ -20,7 +20,7 @@ public class XPackUser extends User {
public static final Role ROLE = Role.builder(new RoleDescriptor(ROLE_NAME, new String[] { "all" },
new RoleDescriptor.IndicesPrivileges[] {
RoleDescriptor.IndicesPrivileges.builder().indices("/@&~(\\.security.*)/").privileges("all").build(),
RoleDescriptor.IndicesPrivileges.builder().indices(IndexAuditTrailField.INDEX_NAME_PREFIX + "-*")
RoleDescriptor.IndicesPrivileges.builder().indices(SystemIndicesNames.AUDIT_INDEX_NAME_PREFIX + "-*")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can simplify this when we remove index audit.

.privileges("read").build()
},
new String[] { "*" },
Expand Down
Loading