Commit Graph

451 Commits

Author SHA1 Message Date
jaymode 2b3c157c97 store names of indices as an array instead of a string
We currently store the names of indices as a comma separated string instead
of an array. An array is the proper format for this information so this commit
changes the index audit trail to store the indices as an array.

Closes elastic/elasticsearch#917

Original commit: elastic/x-pack-elasticsearch@025393d91c
2015-06-18 13:26:51 -04:00
jaymode 6202914ffc Test: add '.' to allowed name characters
Original commit: elastic/x-pack-elasticsearch@26a254a4c2
2015-06-18 09:20:30 -04:00
Boaz Leskes 3394c2e883 Add a debug log to IndexAuditTrail
Original commit: elastic/x-pack-elasticsearch@ccff079b12
2015-06-18 08:55:34 +02:00
jaymode 853f8d50ef Test: assert that the current thread is not already interrupted
Original commit: elastic/x-pack-elasticsearch@acc517ca53
2015-06-17 09:38:50 -04:00
jaymode d036fc505d Test: override beforeIndexDeletion for audit trail tests
The beforeIndexDeletion method expects that nothing is still indexing when it runs
but this is not the case as the index audit trail will continue indexing events that
occur as checks are being performed in the cluster.

Original commit: elastic/x-pack-elasticsearch@02001a5222
2015-06-17 06:26:12 -04:00
Alexander Reelsen 22c77805bd Test: Removed river handler due to removal in master
Original commit: elastic/x-pack-elasticsearch@c6a3372ce0
2015-06-17 12:07:02 +02:00
jaymode 38837b310c [Test] disable random dynamic templates for audit index
Original commit: elastic/x-pack-elasticsearch@914e0990ef
2015-06-16 15:43:58 -04:00
jaymode cb80e9ccbd add mapping and configurable settings for audit index output
Previously we relied on the default dynamic mapping for the audit index output, which did
not create an ideal mapping. This change adds a mapping file with default settings and
dynamic mapping disabled for the audit indexes.

Additionally, the ability to override settings for the audit indexes has been provided so that
users can customize the number of shards and replicas to meet their needs.

In order to implement these changes, the index audit service had to be moved from a lifecycle
component to an abstract component that had its own custom lifecycle on top of the cluster
state. A ShieldLifecycleService class was added to accomplish this. In the future, this class
can be used for other services that need to perform index based operations.

Closes elastic/elasticsearch#913

Original commit: elastic/x-pack-elasticsearch@231740c1cc
2015-06-16 13:33:03 -04:00
jaymode f4ed6282fd only bind the index audit trail if auditing is enabled
If auditing is not enabled, we should not bind the index audit trail as a lifecycle component
since we do not bind all of its dependent classes when auditing is disabled.

Original commit: elastic/x-pack-elasticsearch@39f736ca6a
2015-06-12 17:08:31 -04:00
jaymode 95ad77a778 allow periods in esusers usernames and role names
This change allows periods in the usernames and role names in the esusers realm.

Closes elastic/elasticsearch#905

Original commit: elastic/x-pack-elasticsearch@64b4f02ee5
2015-06-12 16:39:29 -04:00
jaymode 9a97b046d5 control index audit events through an include/excludes mechanism
This changes how the user defines which events should be indexed. Previously, there were
several boolean settings being used. This condenses to an include and exclude setting.

Additionally, the IndexAuditTrail needed to become a lifecycle component since parsing the
enum could throw exceptions. Given this, the IndexBulkProcessor was condensed into the
IndexAuditTrail since it did not make sense to have two lifecycle components for an index
audit trail.

Closes elastic/elasticsearch#900

Original commit: elastic/x-pack-elasticsearch@4b4d824f5e
2015-06-12 14:17:38 -04:00
jaymode c82816dd49 ensure we call authentication failed even if an exception is thrown
Today, a realm could throw an exception, which will not be caught and cause the audit
trail to be skipped. This commit catches exceptions thrown by realms and ensures that
the audit trail is called and then re-throws the exceptions.

Closes elastic/elasticsearch#901

Original commit: elastic/x-pack-elasticsearch@d260c00b33
2015-06-12 12:20:09 -04:00
jaymode 7c67b49aa5 system actions are only logged at the correct audit level
Today, some system actions could be logged by default when the actions performed are
not internal. Additionally for internal actions, we never checked if the user was the system
user.

This adds a check to ensure the user is the System user and that the actions that are being
suppressed are known system actions.

Closes elastic/elasticsearch#902

Original commit: elastic/x-pack-elasticsearch@b107994692
2015-06-12 08:39:43 -04:00
jaymode 5a6dcfa0ac fix compilation due to change in snapshot state enum
Original commit: elastic/x-pack-elasticsearch@771333594d
2015-06-12 06:34:54 -04:00
jaymode ae3d56f55e [Test] use the new resource watcher settings
Original commit: elastic/x-pack-elasticsearch@09c9951aaf
2015-06-09 08:32:54 -04:00
jaymode 018919fb43 fix JDK7 compilation
Original commit: elastic/x-pack-elasticsearch@56e5f69803
2015-06-06 20:26:15 -04:00
jaymode 26f52be95a [Test] add response to the fail statement for debugging
Original commit: elastic/x-pack-elasticsearch@c6628a5cda
2015-06-06 15:48:14 -04:00
jaymode 1c54d49a71 remove use of shaded core packages
Elasticsearch core no longer uses shaded dependencies by default, so this change makes
the plugin use the unshaded dependencies.

Original commit: elastic/x-pack-elasticsearch@495f636266
2015-06-06 15:37:24 -04:00
aleph-zero a1b4a47684 Store audit events in an index
This commit provides the ability to store audit events into an
Elasticsearch index.

Closes elastic/elasticsearch#781

Original commit: elastic/x-pack-elasticsearch@6e136d8dbb
2015-06-05 18:04:47 -07:00
jaymode b713d16803 ensure protocols and ciphers are set on SSLSockets
Today, we simply return a SSLSocketFactory from a SSLContext, which provides
the default SSL configuration for sockets. This means that SSLv3 could still be
enabled on these sockets when running in an older JVM. This also means that
the ciphers and protocol settings are not honored for users of this socket factory,
which is currently the LDAP code.

This change returns a custom socket factory that delegates to the default socket
factory and sets the ciphers and protocols on the socket before returning the
socket.

Original commit: elastic/x-pack-elasticsearch@c4cfedfd51
2015-06-05 16:20:06 -04:00
jaymode 6f079dd2f2 PKI: allow username extraction to work for certs with CN only
Our current CA configuration creates certificates with only a CN and this caused
the regular expression in the PKI realm to fail. The default regular expression in
the PKI realm has been changed to allow for only a CN, while still maintaining the
ability to extract only the CN when other fields are present in the DN.

Additionally, the CA configuration has been updated so that is will copy any of the
originally specified fields (besides CN and EMAILADDRESS) over to the signed
certificate.

Original commit: elastic/x-pack-elasticsearch@ff27f69781
2015-06-05 16:00:06 -04:00
jaymode 7c62e4c82c disable core caches to ensure users are always authorized
The IndicesTermsFilter Cache in core can leak data by not authorizing users prior to
retrieving data from the cache. We work around this by ensuring that the cache has
a maximum size of 0, effectively disabling it.

A test is also added to ensure that data is not leaked by this cache or the cache used by
the ScriptService in core.

Closes elastic/elasticsearch#854

Original commit: elastic/x-pack-elasticsearch@8a48bdad98
2015-06-05 11:28:13 -04:00
jaymode 0f56bd37d8 PKI: add the ability to set want instead of need client authentication
Today, we only have the option to require client authentication or not require it. A third case
exists where the server can want client authentication, but if the client does not have credentials
or wish to send credentials the connection will still be allowed.

This is beneficial for the PKI realm because it allows some clients to authenticate with PKI and
others to use another authentication token such as username and password authentication.

Closes elastic/elasticsearch#858

Original commit: elastic/x-pack-elasticsearch@e7cbc20bca
2015-06-05 09:39:38 -04:00
jaymode 8949e5fcaf fix compilation issue with parsing TimeValue
Original commit: elastic/x-pack-elasticsearch@a7390861be
2015-06-05 09:20:33 -04:00
jaymode a12eba49fa make encryption and decryption tolerant to missing key
Today, an exception is thrown when calls to the encrypt and decrypt methods are
made without a key being present. For now, we will not require the system key and
this behavior is undesirable.

This commit changes the behavior to just return the provided characters or bytes
when no key is present. Additionally, a method has been added for callers to see
if encryption is supported. Finally, the listener interface has been made public and
expanded to provide the old keys when the keys are changed. This allows
consumers to decrypt with the old key and re-encrypt with the new key.

Original commit: elastic/x-pack-elasticsearch@de3d5b6180
2015-06-01 13:47:09 -04:00
jaymode 5309353745 allow authentication exceptions for unauthorized anonymous users
Today, we always throw an AuthorizationException for an unauthorized user. This is
problematic when anonymous access is enabled and the HTTP client being used
does not support preemptive basic authentication as only the anonymous user
will be used by such a client.

This change adds a setting to allow an AuthenticationException to be thrown for
anonymous users. This will clients such as browsers to work with anonymous
access and authenticated access.

Closes elastic/elasticsearch#853

Original commit: elastic/x-pack-elasticsearch@d338b468c7
2015-06-01 09:40:55 -04:00
jaymode d393cc2740 do not attempt to resolve permissions in the esusers tool
The esusers tool reads the list of roles to provide validation feedback to the user,
however since we have added custom roles the tool doesn't know about these roles
as they come from outside of Shield. When a custom role was found, a warning
was printed that can be confusing to users.

Now when validating roles, we only read the names from the roles.yml file.

Closes elastic/elasticsearch#835

Original commit: elastic/x-pack-elasticsearch@89d0e3efce
2015-06-01 09:07:10 -04:00
jaymode 03520e0aa7 [CLI] check the number of arguments for esusers commands
Adds a check to all of the esusers commands to ensure the correct number
of arguments are found. If extra arguments are found, they are printed out
with an error message and the tool exits.

Closes elastic/elasticsearch#817

Original commit: elastic/x-pack-elasticsearch@cd3e786267
2015-06-01 08:21:31 -04:00
jaymode b8f75a2bae Netty: reduce logging for a close request during handshake
Reduces the amount of logging on both HTTP and Transport protocols for
a channel being closed while in the middle of a handshake. This often
occurs when the client does not trust the server certificate and aborts the
handshake. Also, reduces logging on the Transport protocol for a
plain text message received on a channel that is using TLS.

Closes elastic/elasticsearch#771

Original commit: elastic/x-pack-elasticsearch@321c384ddd
2015-06-01 08:04:55 -04:00
jaymode 6e660dbd7d remove commons codec dependency
This commit removes the commons codec dependency and simplifies the
hasher code by only supporting bcrypt encryption in the users file. All tests
now also exercise the esusers realm with bcrypt instead of plain text passwords.

Closes elastic/elasticsearch#806

Original commit: elastic/x-pack-elasticsearch@3119267851
2015-06-01 07:52:38 -04:00
jaymode ba1001a3a4 update BCrypt implementation to version 0.4
This updates the BCrypt implementation that we use to version 0.4, which
corrects an integer overflow bug when a large number of rounds are used.

Closes elastic/elasticsearch#865

Original commit: elastic/x-pack-elasticsearch@2f9a07e7c8
2015-05-29 13:52:39 -04:00
jaymode 2e4f3e8d23 make TLSv1.2 the default protocol
This commit makes TLSv1.2 the default protocol for better security. The
old value of TLS would only pick a TLSv1.0 supporting context and cause
client connections to be negotiated using that protocol when TLSv1.2 is
supported and considered an improved protocol.

Closes elastic/elasticsearch#867

Original commit: elastic/x-pack-elasticsearch@1f062f6dde
2015-05-29 13:46:48 -04:00
jaymode 44017711e2 remove DHE cipher from default list
This commit removes the DHE cipher from our list of enabled ciphers
due to the recently published Logjam attack. The default configuration
is not susceptible to the Logjam attack, but since we support Java 7
the maximum prime size (768 bit) is considered too weak. Java 8 supports
1024 bit primes, but these are also not ideal and this cipher should not be
used with a prime smaller than 2048 bits.

Closes elastic/elasticsearch#862

Original commit: elastic/x-pack-elasticsearch@9785bf47cf
2015-05-29 13:33:54 -04:00
jaymode c01eef8863 Test: update with new core actions and upgrade api changes
Original commit: elastic/x-pack-elasticsearch@0189cf850f
2015-05-29 09:16:31 -04:00
jaymode 84c5115889 Test: use URI so paths work on Windows
Original commit: elastic/x-pack-elasticsearch@3e6a185ac4
2015-05-27 06:55:19 -04:00
jaymode fb7cbbe581 fix compilation due to renamed transport actions
Original commit: elastic/x-pack-elasticsearch@fca64087dd
2015-05-27 06:42:42 -04:00
jaymode 7c4ce5760f Test: workaround JNA being required on windows now
Adds JNA as a test time dependency to work around it being required on
windows in elasticsearch core.

Original commit: elastic/x-pack-elasticsearch@b8fc70a051
2015-05-26 15:26:01 -04:00
jaymode 39915f92bc update shield to depend on elasticsearch 2.0
This commit is a squashed commit of work done in conjunction with @rmuir to make
shield work properly with elasticsearch 2.0. This includes ensuring all tests
pass when running with the security manager and updating the code to be compatible
with the latest core forbidden apis.

Shield is now a child project of elasticsearch-parent and inherits a lot of common
build, test, and static coverage functionality from that project resulting in a much
smaller and simpler pom.xml for shield. As part of this work, Shield can now read
rest tests from the elasticsearch jar so the rest tests are run automatically when
running the slow tests.

Original commit: elastic/x-pack-elasticsearch@2ebbf4284a
2015-05-26 13:57:58 -04:00
jaymode 3848ef3644 [Test] use elastic.co instead of elasticsearch.com
The elasticsearch.com SSL cert expired causing these tests to fail. Just use
elastic.co instead.

Original commit: elastic/x-pack-elasticsearch@b54895e6b8
2015-05-06 13:57:04 -04:00
jaymode 7366c95994 [Test] fix bug where random byte may be the same as the byte being changed
Original commit: elastic/x-pack-elasticsearch@657d38fbca
2015-04-30 13:11:15 -04:00
jaymode 03a00201ab add version 1.2.1
Original commit: elastic/x-pack-elasticsearch@b5c40a88bf
2015-04-29 13:04:00 -04:00
jaymode 316c179ec5 add version 1.1.1
Original commit: elastic/x-pack-elasticsearch@b95b59414a
2015-04-29 12:18:43 -04:00
jaymode a6df3d003e add reroute permissions for the system user
The system user needs to be able to execute a reroute action to support the
DiskThresholdDecider. The DiskThresholdDecider executes an empty reroute
request when a high disk watermark has been exceeded.

Relates to elastic/elasticsearch#816

Original commit: elastic/x-pack-elasticsearch@890b44d79e
2015-04-29 08:39:31 -04:00
jaymode c83836df71 [Test] fix bug in creating a byte array for tampered encryption test
The testChangingAByte method was requesting a random length byte array ranging
from 0-1000. The issue is that a byte array with length of 0 cannot be changed and
therefore this test is not valid in this case. It now requests a range of 1-1000.

Original commit: elastic/x-pack-elasticsearch@88edf535f4
2015-04-27 09:27:01 -04:00
jaymode c0858842ad [Test] update randomization file for elasticsearch 1.5.2 release
Original commit: elastic/x-pack-elasticsearch@cc48198ce4
2015-04-27 08:39:42 -04:00
jaymode bff95d9ca1 Add CryptoService to support signing and encryption operations
This changes the SignatureService into a CryptoService that now supports encryption
operations in addition to the signing operations. The encryption leverages the existing
system key and uses it with AES.

Closes elastic/elasticsearch#805

Original commit: elastic/x-pack-elasticsearch@a792ed4a54
2015-04-21 08:38:40 -04:00
jaymode 39f587a497 [CLI] attempt to restore owner and group on new files
For the CLI tools in Shield we create a new temp file and replace the existing file
to prevent issues with reloading a half written file. This has a potential side effect
of changing the user and group that own the file. Many times the commands are
run with root privileges (sudo) and when run with root privileges we can actually
reset the owner and group correctly.

Closes elastic/elasticsearch#812

Original commit: elastic/x-pack-elasticsearch@1ee3715376
2015-04-21 07:32:44 -04:00
jaymode 197817e900 use a time constant comparison function for security
For HMAC and password hash comparisons we need to use a time
constant comparison that always compares the whole value in order
to protect against timing attacks.

Original commit: elastic/x-pack-elasticsearch@f6082c76b9
2015-04-10 09:37:41 -04:00
jaymode d1759ff322 Tests: update randomization for ES 1.5.1
Elasticsearch version 1.5.1 was released today, so move to testing against
the release version and add 1.5.2-SNAPSHOT.

Original commit: elastic/x-pack-elasticsearch@36b502dbb1
2015-04-09 10:19:11 -04:00
jaymode aec8982996 Build: rename zip to shield-version.zip
As part of the release process, the shield zip files are renamed prior to
uploading to the downloads server. This change removes the need to
rename the file.

Closes elastic/elasticsearch#760

Original commit: elastic/x-pack-elasticsearch@f1822d9d4c
2015-04-07 13:47:23 -04:00