* Adding very basic audit logging for auth success/failure * Extracting security specific audit logger from the AuditLogger * Using short auditLogger in authenticate in one more place * Logging some information from the request during success/failure * Adding AuditLogger tests * Removing the security audit logger, this is out of scope... * Better asserts, thanks Aleh * Adding `audit` to the default events * Using `info` with the audit logger, emulating with ES does
20 lines
541 B
JavaScript
20 lines
541 B
JavaScript
/*
|
|
* 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.
|
|
*/
|
|
|
|
export class AuditLogger {
|
|
constructor(server, pluginId) {
|
|
this._server = server;
|
|
this._pluginId = pluginId;
|
|
}
|
|
|
|
log(eventType, message, data = {}) {
|
|
this._server.log(['info', 'audit', this._pluginId, eventType], {
|
|
tmpl: message,
|
|
eventType,
|
|
...data
|
|
});
|
|
}
|
|
}
|