|
|
@@ -77,6 +77,7 @@ import org.elasticsearch.xpack.core.security.authc.Authentication;
|
|
|
import org.elasticsearch.xpack.core.security.authc.Authentication.AuthenticationType;
|
|
|
import org.elasticsearch.xpack.core.security.authc.Authentication.RealmRef;
|
|
|
import org.elasticsearch.xpack.core.security.authc.AuthenticationToken;
|
|
|
+import org.elasticsearch.xpack.core.security.authc.service.ServiceAccountSettings;
|
|
|
import org.elasticsearch.xpack.core.security.authc.support.mapper.TemplateRoleName;
|
|
|
import org.elasticsearch.xpack.core.security.authc.support.mapper.expressiondsl.ExpressionModel;
|
|
|
import org.elasticsearch.xpack.core.security.authc.support.mapper.expressiondsl.RoleMapperExpression;
|
|
|
@@ -137,6 +138,7 @@ import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static org.elasticsearch.xpack.core.security.authc.service.ServiceAccountSettings.TOKEN_NAME_FIELD;
|
|
|
+import static org.elasticsearch.xpack.core.security.authc.service.ServiceAccountSettings.TOKEN_SOURCE_FIELD;
|
|
|
import static org.elasticsearch.xpack.security.audit.logfile.LoggingAuditTrail.PRINCIPAL_ROLES_FIELD_NAME;
|
|
|
import static org.elasticsearch.xpack.security.authc.ApiKeyServiceTests.Utils.createApiKeyAuthentication;
|
|
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
|
|
@@ -1637,7 +1639,9 @@ public class LoggingAuditTrailTests extends ESTestCase {
|
|
|
.put(LoggingAuditTrail.REQUEST_NAME_FIELD_NAME, request.getClass().getSimpleName())
|
|
|
.put(LoggingAuditTrail.REQUEST_ID_FIELD_NAME, requestId);
|
|
|
if (authentication.isServiceAccount()) {
|
|
|
- checkedFields.put(LoggingAuditTrail.SERVICE_TOKEN_NAME_FIELD_NAME, (String) authentication.getMetadata().get(TOKEN_NAME_FIELD));
|
|
|
+ checkedFields.put(LoggingAuditTrail.SERVICE_TOKEN_NAME_FIELD_NAME, (String) authentication.getMetadata().get(TOKEN_NAME_FIELD))
|
|
|
+ .put(LoggingAuditTrail.SERVICE_TOKEN_TYPE_FIELD_NAME,
|
|
|
+ ServiceAccountSettings.REALM_TYPE + "_" + authentication.getMetadata().get(TOKEN_SOURCE_FIELD));
|
|
|
}
|
|
|
checkedArrayFields.put(PRINCIPAL_ROLES_FIELD_NAME, (String[]) authorizationInfo.asMap().get(PRINCIPAL_ROLES_FIELD_NAME));
|
|
|
authentication(authentication, checkedFields);
|
|
|
@@ -2373,7 +2377,9 @@ public class LoggingAuditTrailTests extends ESTestCase {
|
|
|
}
|
|
|
}
|
|
|
if (authentication.isServiceAccount()) {
|
|
|
- checkedFields.put(LoggingAuditTrail.SERVICE_TOKEN_NAME_FIELD_NAME, (String) authentication.getMetadata().get(TOKEN_NAME_FIELD));
|
|
|
+ checkedFields.put(LoggingAuditTrail.SERVICE_TOKEN_NAME_FIELD_NAME, (String) authentication.getMetadata().get(TOKEN_NAME_FIELD))
|
|
|
+ .put(LoggingAuditTrail.SERVICE_TOKEN_TYPE_FIELD_NAME,
|
|
|
+ ServiceAccountSettings.REALM_TYPE + "_" + authentication.getMetadata().get(TOKEN_SOURCE_FIELD));
|
|
|
}
|
|
|
}
|
|
|
|