🔎 Open source distributed and RESTful search engine.
Go to file
Jay Modi 18a2cf23d4 Build a single role that represents a user's permissions (elastic/elasticsearch#4449)
This PR changes how we use roles and how we look at the roles of a user. Previously we looked up each role individually, parsed each into their own `Role` object, and had a wrapper that essentially served as an iterator over the roles. The same pattern was also followed for the permissions that composed a role (ClusterPermission, IndicesPermission, and RunAsPermission). This resulted in a lot of code that was hard to follow and could be inefficient. 

Now, we look up the roles for a user in bulk and only get the RoleDescriptor for each role. Once all role descriptors have been retrieved, we build a single Role that represents the user's permissions and we also cache this combination for better performance as authorization can happen many times for a single top level request as we authorize the top level request and any sub requests, which could be a large number in the case of shard requests.

This change also enabled a large cleanup of our permission and privilege classes, which should reduce the footprint of what needs to be followed. Some of the notable changes are:

* Consolidation of GeneralPrivilege and AbstractAutomatonPrivilege into the Privilege class
* The DefaultRole class has been removed and the permissions it provided were moved into the AuthorizationService
* The GlobalPermission class was removed as there is a single role that represents a user's permissions
* The Global inner classes for the various permissions were removed
* The Core inner class was removed and ClusterPermission, IndexPermission, RunAsPermission became final classes instead of interfaces
* The Permission interface has been removed. The isEmpty() method defined by this interface is not needed as we can simply evaluate the permission to get the same effect
* The ClusterPermission#check method only takes the action name again
* The AutomatonPredicate class was removed and replaced by Automatons#predicate
* IndicesAccessControl objects no longer need to be merged when evaluating permissions
* MergedFieldPermissions has been removed
* The Name class that was used to hold an array of strings has been removed and replaced with the use of a Set
* Privilege resolution is more efficient by only combining automata once

Other items:
* NativeRolesStore no longer does caching, so the RoleAndVersion class could be removed
* FileRolesStore doesn't need to be an AbstractLifecycleComponent

Relates elastic/elasticsearch#4327

Original commit: elastic/x-pack-elasticsearch@c1901bc82e
2016-12-30 09:27:49 -05:00
buildSrc Build: Convert xplugins to use new extra projects setup (elastic/elasticsearch#4175) 2016-12-14 15:02:28 -08:00
dev-tools [ci] Fix bug with -Dtests.jvm.argline 2016-12-20 16:35:18 +02:00
elasticsearch Build a single role that represents a user's permissions (elastic/elasticsearch#4449) 2016-12-30 09:27:49 -05:00
elasticsearch-transport-client Skip pre-built transport client test on JDK 9 2016-12-20 20:25:41 -05:00
license-tools Build: Convert xplugins to use new extra projects setup (elastic/elasticsearch#4175) 2016-12-14 15:02:28 -08:00
qa Build a single role that represents a user's permissions (elastic/elasticsearch#4449) 2016-12-30 09:27:49 -05:00
.dir-locals.el Update .dir-locals.el for enforced line length 2016-02-04 14:55:41 -07:00
.projectile Add .dir-locals.el and .projectile 2015-10-30 11:16:29 -06:00
GRADLE.CHEATSHEET.asciidoc Fixing grammar in GRADLE.CHEATSHEET 2016-05-18 14:17:13 -04:00
LICENSE.txt Initial X-Pack commit 2018-04-20 14:16:58 -07:00
README.asciidoc Fix x-pack readme to reflect project name and dev-setup changes (elastic/elasticsearch#4402) 2016-12-20 12:43:32 -06:00
build.gradle Fix x-pack readme to reflect project name and dev-setup changes (elastic/elasticsearch#4402) 2016-12-20 12:43:32 -06:00
gradle.properties Gradle daemon is a demon 2015-11-25 10:39:08 -05:00
settings.gradle Build: Convert xplugins to use new extra projects setup (elastic/elasticsearch#4175) 2016-12-14 15:02:28 -08:00

README.asciidoc

= Elasticsearch X Pack

A set of Elastic's commercial plugins:

- License
- Security
- Watcher
- Monitoring

= Setup
You must checkout x-pack and elasticsearch with a specific directory structure. The
elasticsearch checkout will be used when building x-pack. The structure is:

- /path/to/elastic/elasticsearch
- /path/to/elastic/elasticsearch-extra/x-pack

= Build

- Run unit tests:
+
[source, txt]
-----
gradle clean test
-----

- Run all tests:
+
[source, txt]
-----
gradle clean check
-----

- Run integration tests:
+
[source, txt]
-----
gradle clean integTest
-----

- Package X-Pack (wihtout running tests)
+
[source, txt]
-----
gradle clean assemble
-----

- Install X-Pack (wihtout running tests)
+
[source, txt]
-----
gradle clean install
-----

- If you don't work on the UI side of x-plugins, you can force gradle to skip building kibana by adding
  `xpack.kibana.build=false` to your `~/.gradle/gradle.properties`. Alternatively you add `-Pxpack.kibana.build=false`
  on the command line if you only want to do this on individual builds (or `-Pxpack.kibana.build=true` if you need to
  override having added this to your `gradle.properties`).