From eb8645f93e620b45fbcf358d3f6746e98469403e Mon Sep 17 00:00:00 2001 From: Thom Heymann Date: Thu, 10 Dec 2020 12:57:24 +0000 Subject: [PATCH] Add suggestions from code review --- x-pack/plugins/security/server/audit/audit_service.ts | 6 +++--- .../server/usage_collector/security_usage_collector.ts | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/security/server/audit/audit_service.ts b/x-pack/plugins/security/server/audit/audit_service.ts index 1cccc9a3b237f..8dbdc48c7dee9 100644 --- a/x-pack/plugins/security/server/audit/audit_service.ts +++ b/x-pack/plugins/security/server/audit/audit_service.ts @@ -70,7 +70,7 @@ export class AuditService { /** * @deprecated */ - private allowAuditLogging = false; + private allowLegacyAuditLogging = false; private ecsLogger: Logger; @@ -89,7 +89,7 @@ export class AuditService { if (config.enabled && !config.appender) { this.licenseFeaturesSubscription = license.features$.subscribe( ({ allowLegacyAuditLogging }) => { - this.allowAuditLogging = allowLegacyAuditLogging; + this.allowLegacyAuditLogging = allowLegacyAuditLogging; } ); } @@ -171,7 +171,7 @@ export class AuditService { const getLogger = (id?: string): LegacyAuditLogger => { return { log: (eventType: string, message: string, data?: Record) => { - if (!this.allowAuditLogging) { + if (!this.allowLegacyAuditLogging) { return; } diff --git a/x-pack/plugins/security/server/usage_collector/security_usage_collector.ts b/x-pack/plugins/security/server/usage_collector/security_usage_collector.ts index b85cf9f293df1..64a586588648e 100644 --- a/x-pack/plugins/security/server/usage_collector/security_usage_collector.ts +++ b/x-pack/plugins/security/server/usage_collector/security_usage_collector.ts @@ -92,8 +92,10 @@ export function registerSecurityUsageCollector({ usageCollection, config, licens }; } + const legacyAuditLoggingEnabled = allowLegacyAuditLogging && config.audit.enabled; const auditLoggingEnabled = - (allowAuditLogging || allowLegacyAuditLogging) && config.audit.enabled; + allowAuditLogging && config.audit.enabled && config.audit.appender != null; + const loginSelectorEnabled = config.authc.selector.enabled; const authProviderCount = config.authc.sortedProviders.length; const enabledAuthProviders = [ @@ -113,7 +115,7 @@ export function registerSecurityUsageCollector({ usageCollection, config, licens ); return { - auditLoggingEnabled, + auditLoggingEnabled: legacyAuditLoggingEnabled || auditLoggingEnabled, loginSelectorEnabled, accessAgreementEnabled, authProviderCount,