Skip to content

Commit

Permalink
Add session cleanup usage data
Browse files Browse the repository at this point in the history
  • Loading branch information
jportner committed Aug 31, 2021
1 parent fb0850b commit 94379a6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ describe('Security UsageCollector', () => {
httpAuthSchemes: ['apikey'],
sessionIdleTimeoutInMinutes: 60,
sessionLifespanInMinutes: 43200,
sessionCleanupInMinutes: 60,
};

describe('initialization', () => {
Expand Down Expand Up @@ -108,6 +109,7 @@ describe('Security UsageCollector', () => {
httpAuthSchemes: [],
sessionIdleTimeoutInMinutes: 0,
sessionLifespanInMinutes: 0,
sessionCleanupInMinutes: 0,
});
});

Expand Down Expand Up @@ -471,12 +473,12 @@ describe('Security UsageCollector', () => {
});
});

describe('session expirations', () => {
describe('session', () => {
// Note: can't easily test deprecated 'sessionTimeout' value here because of the way that config deprecation renaming works
it('reports customized session idleTimeout and lifespan', async () => {
it('reports customized session idleTimeout, lifespan, and cleanupInterval', async () => {
const config = createSecurityConfig(
ConfigSchema.validate({
session: { idleTimeout: '123m', lifespan: '456m' },
session: { idleTimeout: '123m', lifespan: '456m', cleanupInterval: '789m' },
})
);
const usageCollection = usageCollectionPluginMock.createSetupContract();
Expand All @@ -491,6 +493,7 @@ describe('Security UsageCollector', () => {
...DEFAULT_USAGE,
sessionIdleTimeoutInMinutes: 123,
sessionLifespanInMinutes: 456,
sessionCleanupInMinutes: 789,
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ interface Usage {
httpAuthSchemes: string[];
sessionIdleTimeoutInMinutes: number;
sessionLifespanInMinutes: number;
sessionCleanupInMinutes: number;
}

interface Deps {
Expand Down Expand Up @@ -122,6 +123,13 @@ export function registerSecurityUsageCollector({ usageCollection, config, licens
'The global session lifespan expiration that is configured, in minutes (0 if disabled).',
},
},
sessionCleanupInMinutes: {
type: 'long',
_meta: {
description:
'The session cleanup interval that is configured, in minutes (0 if disabled).',
},
},
},
fetch: () => {
const {
Expand All @@ -140,6 +148,7 @@ export function registerSecurityUsageCollector({ usageCollection, config, licens
httpAuthSchemes: [],
sessionIdleTimeoutInMinutes: 0,
sessionLifespanInMinutes: 0,
sessionCleanupInMinutes: 0,
};
}

Expand Down Expand Up @@ -175,6 +184,7 @@ export function registerSecurityUsageCollector({ usageCollection, config, licens
const sessionExpirations = config.session.getExpirationTimeouts(); // get global expiration values
const sessionIdleTimeoutInMinutes = sessionExpirations.idleTimeout?.asMinutes() ?? 0;
const sessionLifespanInMinutes = sessionExpirations.lifespan?.asMinutes() ?? 0;
const sessionCleanupInMinutes = config.session.cleanupInterval?.asMinutes() ?? 0;

return {
auditLoggingEnabled: legacyAuditLoggingEnabled || ecsAuditLoggingEnabled,
Expand All @@ -186,6 +196,7 @@ export function registerSecurityUsageCollector({ usageCollection, config, licens
httpAuthSchemes,
sessionIdleTimeoutInMinutes,
sessionLifespanInMinutes,
sessionCleanupInMinutes,
};
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5508,6 +5508,12 @@
"_meta": {
"description": "The global session lifespan expiration that is configured, in minutes (0 if disabled)."
}
},
"sessionCleanupInMinutes": {
"type": "long",
"_meta": {
"description": "The session cleanup interval that is configured, in minutes (0 if disabled)."
}
}
}
},
Expand Down

0 comments on commit 94379a6

Please sign in to comment.