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

Introduce new audit record for security configuration changes via API #62916

Merged
Show file tree
Hide file tree
Changes from 73 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
8440779
SomeRequests to XContent
albertzaharovits Sep 24, 2020
7240823
Merge branch 'master' into audit_request_body_for_certain_transport_r…
albertzaharovits Sep 25, 2020
79868b9
Do not audit non-write security changes
albertzaharovits Sep 25, 2020
81fe94e
Almost all requests
albertzaharovits Sep 25, 2020
d7f566e
draft ready
albertzaharovits Sep 25, 2020
03d4edb
Revert unnecessary changes
albertzaharovits Sep 26, 2020
5490420
Merge branch 'master' into audit_request_body_for_certain_transport_r…
albertzaharovits Sep 26, 2020
8bd8441
Merge branch 'master' into audit_request_body_for_certain_transport_r…
albertzaharovits Oct 4, 2020
f0579b1
tweaks
albertzaharovits Oct 4, 2020
9fcd059
requests contain operation names
albertzaharovits Oct 4, 2020
9550f42
WIP
albertzaharovits Oct 5, 2020
fb941c1
Merge branch 'master' into audit_request_body_for_certain_transport_r…
albertzaharovits Oct 5, 2020
6bb09a0
Security Config Change
albertzaharovits Oct 5, 2020
47131ae
WIP
albertzaharovits Oct 6, 2020
5986223
review
albertzaharovits Oct 7, 2020
3fceda2
nit
albertzaharovits Oct 7, 2020
f62a1fd
Merge branch 'master' into audit_request_body_for_certain_transport_r…
albertzaharovits Oct 7, 2020
a535098
Merge fallout
albertzaharovits Oct 7, 2020
6f8ceaf
WIP tests
albertzaharovits Oct 7, 2020
ff6b544
Mhm
albertzaharovits Oct 8, 2020
4d2a104
trims
albertzaharovits Oct 8, 2020
61c9e28
Checkstyle
albertzaharovits Oct 8, 2020
bd44688
Test audit cluster settings update
albertzaharovits Oct 8, 2020
2dca8e4
Tests in progress
albertzaharovits Oct 8, 2020
93be896
Merge branch 'master' into audit_request_body_for_certain_transport_r…
albertzaharovits Oct 18, 2020
e831fc9
Revert useless
albertzaharovits Oct 18, 2020
92d9789
master merge mistake
albertzaharovits Oct 18, 2020
576f7d4
log4j audit pattern equals
albertzaharovits Oct 18, 2020
7f33a26
Don't overcomplicate the diff
albertzaharovits Oct 18, 2020
e2c305d
Nit javadoc
albertzaharovits Oct 18, 2020
4a0aa79
Minor thing
albertzaharovits Oct 18, 2020
10dad5b
Uninteresting test
albertzaharovits Oct 18, 2020
9823e29
Update x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/s…
albertzaharovits Oct 19, 2020
f7f569d
Nit
albertzaharovits Oct 19, 2020
44ac372
More restructuring on the format
albertzaharovits Oct 20, 2020
59e9e85
Do not show some null fields
albertzaharovits Oct 20, 2020
44d68d7
tests still in progress
albertzaharovits Oct 20, 2020
5d3e6ed
Lose the _
albertzaharovits Oct 21, 2020
c3bdaf0
Fix for the above
albertzaharovits Oct 21, 2020
4e8a0d5
Condition_cluster to global rename
albertzaharovits Oct 21, 2020
c5859d2
Almost
albertzaharovits Oct 22, 2020
3e0d846
Checkstyle
albertzaharovits Oct 22, 2020
5d502bc
Checkstyle
albertzaharovits Oct 22, 2020
daa77fa
Merge branch 'master' into audit_request_body_for_certain_transport_r…
albertzaharovits Oct 22, 2020
7b1d40f
Create API key test done
albertzaharovits Oct 22, 2020
988d600
Indices privileges
albertzaharovits Oct 22, 2020
96300ce
grant api key tests
albertzaharovits Oct 23, 2020
e02cf8d
Merge branch 'master' into audit_request_body_for_certain_transport_r…
albertzaharovits Oct 23, 2020
93817bb
Role
albertzaharovits Oct 24, 2020
78874a5
Put user security changes
albertzaharovits Oct 25, 2020
38fbb4f
Enable user test
albertzaharovits Oct 25, 2020
c183458
Disable user and change password
albertzaharovits Oct 25, 2020
85be35f
Role mapping changes tested
albertzaharovits Oct 25, 2020
ea15a05
Api Key invalidation tests
albertzaharovits Oct 25, 2020
f7bc2fe
Merge branch 'master' into audit_request_body_for_certain_transport_r…
albertzaharovits Oct 25, 2020
61b3121
Resolve Exception TODO
albertzaharovits Oct 25, 2020
8a6be5e
Checkstyle
albertzaharovits Oct 25, 2020
83b6992
More tests
albertzaharovits Oct 26, 2020
612e69c
More tests
albertzaharovits Oct 26, 2020
79f495a
great...
albertzaharovits Oct 26, 2020
5218d72
Merge branch 'master' into audit_request_body_for_certain_transport_r…
albertzaharovits Dec 2, 2020
42b6de0
Update x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/…
albertzaharovits Dec 2, 2020
68f2445
Remove realm name
albertzaharovits Dec 2, 2020
b647408
Checkstyle
albertzaharovits Dec 2, 2020
c75e4d3
Merge branch 'master' into audit_request_body_for_certain_transport_r…
albertzaharovits Dec 7, 2020
e6d9a35
Nits
albertzaharovits Dec 7, 2020
3b8f339
Merge branch 'master' into audit_request_body_for_certain_transport_r…
albertzaharovits Dec 9, 2020
f27629e
Review role descriptor privileges
albertzaharovits Dec 9, 2020
8b3dcf0
RoleDescriptorTests
albertzaharovits Dec 9, 2020
49f7fdb
Show run_as when empty
albertzaharovits Dec 9, 2020
413f613
Merge branch 'master' into audit_request_body_for_certain_transport_r…
albertzaharovits Dec 9, 2020
a369b2f
Merge branch 'master' into audit_request_body_for_certain_transport_r…
albertzaharovits Dec 10, 2020
71c399c
Renames++
albertzaharovits Dec 10, 2020
3008905
Merge branch 'master' into audit_request_body_for_certain_transport_r…
albertzaharovits Dec 10, 2020
3716966
Merge branch 'master' into audit_request_body_for_certain_transport_r…
albertzaharovits Dec 14, 2020
786518b
Always print grant fields
albertzaharovits Dec 14, 2020
f99e95f
change:enable and change:disable
albertzaharovits Dec 14, 2020
252b170
Merge branch 'master' into audit_request_body_for_certain_transport_r…
elasticmachine Dec 15, 2020
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
15 changes: 11 additions & 4 deletions distribution/docker/src/docker/config/log4j2.properties
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,19 @@ appender.audit_rolling.layout.pattern = {\
%varsNotEmpty{, "x_forwarded_for":"%enc{%map{x_forwarded_for}}{JSON}"}\
%varsNotEmpty{, "transport.profile":"%enc{%map{transport.profile}}{JSON}"}\
%varsNotEmpty{, "rule":"%enc{%map{rule}}{JSON}"}\
%varsNotEmpty{, "event.category":"%enc{%map{event.category}}{JSON}"}\
%varsNotEmpty{, "put":%map{put}}\
%varsNotEmpty{, "delete":%map{delete}}\
%varsNotEmpty{, "change":%map{change}}\
%varsNotEmpty{, "enable":%map{enable}}\
%varsNotEmpty{, "disable":%map{disable}}\
%varsNotEmpty{, "create":%map{create}}\
%varsNotEmpty{, "invalidate":%map{invalidate}}\
}%n
# "node.name" node name from the `elasticsearch.yml` settings
# "node.id" node id which should not change between cluster restarts
# "host.name" unresolved hostname of the local node
# "host.ip" the local bound ip (i.e. the ip listening for connections)
# "event.type" a received REST request is translated into one or more transport requests. This indicates which processing layer generated the event "rest" or "transport" (internal)
# "origin.type" a received REST request is translated into one or more transport requests. This indicates which processing layer generated the event "rest" or "transport" (internal)
# "event.action" the name of the audited event, eg. "authentication_failed", "access_granted", "run_as_granted", etc.
# "authentication.type" one of "realm", "api_key", "token", "anonymous" or "internal"
# "user.name" the subject name as authenticated by a realm
Expand All @@ -98,7 +104,7 @@ appender.audit_rolling.layout.pattern = {\
# "user.roles" the roles array of the user; these are the roles that are granting privileges
# "apikey.id" this field is present if and only if the "authentication.type" is "api_key"
# "apikey.name" this field is present if and only if the "authentication.type" is "api_key"
# "origin.type" it is "rest" if the event is originating (is in relation to) a REST request; possible other values are "transport" and "ip_filter"
# "event.type" informs about what internal system generated the event; possible values are "rest", "transport", "ip_filter" and "security_config_change"
# "origin.address" the remote address and port of the first network hop, i.e. a REST proxy or another cluster node
# "realm" name of a realm that has generated an "authentication_failed" or an "authentication_successful"; the subject is not yet authenticated
# "url.path" the URI component between the port and the query string; it is percent (URL) encoded
Expand All @@ -113,7 +119,8 @@ appender.audit_rolling.layout.pattern = {\
# "x_forwarded_for" the addresses from the "X-Forwarded-For" request header, as a verbatim string value (not an array)
# "transport.profile" name of the transport profile in case this is a "connection_granted" or "connection_denied" event
# "rule" name of the applied rule if the "origin.type" is "ip_filter"
# "event.category" fixed value "elasticsearch-audit"
# the "put", "delete", "change", "enable", "disable", "create", "invalidate" fields are only present
# when the "event.type" is "security_config_change" and contain the security config change (as an object) taking effect

logger.xpack_security_audit_logfile.name = org.elasticsearch.xpack.security.audit.logfile.LoggingAuditTrail
logger.xpack_security_audit_logfile.level = info
Expand Down
15 changes: 11 additions & 4 deletions x-pack/plugin/core/src/main/config/log4j2.properties
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,19 @@ appender.audit_rolling.layout.pattern = {\
%varsNotEmpty{, "x_forwarded_for":"%enc{%map{x_forwarded_for}}{JSON}"}\
%varsNotEmpty{, "transport.profile":"%enc{%map{transport.profile}}{JSON}"}\
%varsNotEmpty{, "rule":"%enc{%map{rule}}{JSON}"}\
%varsNotEmpty{, "event.category":"%enc{%map{event.category}}{JSON}"}\
%varsNotEmpty{, "put":%map{put}}\
%varsNotEmpty{, "delete":%map{delete}}\
%varsNotEmpty{, "change":%map{change}}\
%varsNotEmpty{, "enable":%map{enable}}\
%varsNotEmpty{, "disable":%map{disable}}\
%varsNotEmpty{, "create":%map{create}}\
%varsNotEmpty{, "invalidate":%map{invalidate}}\
}%n
# "node.name" node name from the `elasticsearch.yml` settings
# "node.id" node id which should not change between cluster restarts
# "host.name" unresolved hostname of the local node
# "host.ip" the local bound ip (i.e. the ip listening for connections)
# "event.type" a received REST request is translated into one or more transport requests. This indicates which processing layer generated the event "rest" or "transport" (internal)
# "origin.type" a received REST request is translated into one or more transport requests. This indicates which processing layer generated the event "rest" or "transport" (internal)
# "event.action" the name of the audited event, eg. "authentication_failed", "access_granted", "run_as_granted", etc.
# "authentication.type" one of "realm", "api_key", "token", "anonymous" or "internal"
# "user.name" the subject name as authenticated by a realm
Expand All @@ -54,7 +60,7 @@ appender.audit_rolling.layout.pattern = {\
# "user.roles" the roles array of the user; these are the roles that are granting privileges
# "apikey.id" this field is present if and only if the "authentication.type" is "api_key"
# "apikey.name" this field is present if and only if the "authentication.type" is "api_key"
# "origin.type" it is "rest" if the event is originating (is in relation to) a REST request; possible other values are "transport" and "ip_filter"
# "event.type" informs about what internal system generated the event; possible values are "rest", "transport", "ip_filter" and "security_config_change"
# "origin.address" the remote address and port of the first network hop, i.e. a REST proxy or another cluster node
# "realm" name of a realm that has generated an "authentication_failed" or an "authentication_successful"; the subject is not yet authenticated
# "url.path" the URI component between the port and the query string; it is percent (URL) encoded
Expand All @@ -69,7 +75,8 @@ appender.audit_rolling.layout.pattern = {\
# "x_forwarded_for" the addresses from the "X-Forwarded-For" request header, as a verbatim string value (not an array)
# "transport.profile" name of the transport profile in case this is a "connection_granted" or "connection_denied" event
# "rule" name of the applied rule if the "origin.type" is "ip_filter"
# "event.category" fixed value "elasticsearch-audit"
# the "put", "delete", "change", "enable", "disable", "create", "invalidate" fields are only present
# when the "event.type" is "security_config_change" and contain the security config change (as an object) taking effect

appender.audit_rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_audit-%d{yyyy-MM-dd}-%i.json.gz
appender.audit_rolling.policies.type = Policies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ public void cluster(String... clusterPrivileges) {
this.clusterPrivileges = clusterPrivileges;
}

void conditionalCluster(ConfigurableClusterPrivilege... configurableClusterPrivileges) {
public void conditionalCluster(ConfigurableClusterPrivilege... configurableClusterPrivileges) {
this.configurableClusterPrivileges = configurableClusterPrivileges;
}

void addIndex(RoleDescriptor.IndicesPrivileges... privileges) {
public void addIndex(RoleDescriptor.IndicesPrivileges... privileges) {
this.indicesPrivileges.addAll(Arrays.asList(privileges));
}

Expand All @@ -139,7 +139,7 @@ public void addIndex(String[] indices, String[] privileges, String[] grantedFiel
.build());
}

void addApplicationPrivileges(RoleDescriptor.ApplicationResourcePrivileges... privileges) {
public void addApplicationPrivileges(RoleDescriptor.ApplicationResourcePrivileges... privileges) {
this.applicationPrivileges.addAll(Arrays.asList(privileges));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

public final class NativeRealmSettings {
public static final String TYPE = "native";
public static final String DEFAULT_NAME = "default_native";

private NativeRealmSettings() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

public final class FileRealmSettings {
public static final String TYPE = "file";
public static final String DEFAULT_NAME = "default_file";

private FileRealmSettings() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -673,11 +673,11 @@ public boolean allowRestrictedIndices() {
return allowRestrictedIndices;
}

private boolean hasDeniedFields() {
public boolean hasDeniedFields() {
return deniedFields != null && deniedFields.length > 0;
}

private boolean hasGrantedFields() {
public boolean hasGrantedFields() {
if (grantedFields != null && grantedFields.length >= 0) {
// we treat just '*' as no FLS since that's what the UI defaults to
if (grantedFields.length == 1 && "*".equals(grantedFields[0])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

public enum AuditLevel {


ANONYMOUS_ACCESS_DENIED,
AUTHENTICATION_FAILED,
REALM_AUTHENTICATION_FAILED,
Expand All @@ -22,6 +21,7 @@ public enum AuditLevel {
CONNECTION_GRANTED,
CONNECTION_DENIED,
SYSTEM_ACCESS_GRANTED,
SECURITY_CONFIG_CHANGE,
AUTHENTICATION_SUCCESS,
RUN_AS_GRANTED,
RUN_AS_DENIED;
Expand Down Expand Up @@ -61,6 +61,9 @@ static EnumSet<AuditLevel> parse(List<String> levels) {
case "system_access_granted":
enumSet.add(SYSTEM_ACCESS_GRANTED);
break;
case "security_config_change":
enumSet.add(SECURITY_CONFIG_CHANGE);
break;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The new audit event.

case "authentication_success":
enumSet.add(AUTHENTICATION_SUCCESS);
break;
Expand Down
Loading