-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Monitoring] Added a case for Alerting if security/ssl is disabled #71846
Changes from all commits
e73d14e
9e76d18
4e701a5
b8a62c6
91475c3
83b7a7f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
import { EuiSpacer, EuiLink, EuiCode, EuiText } from '@elastic/eui'; | ||
import { Legacy } from '../../legacy_shims'; | ||
import { toMountPoint } from '../../../../../../src/plugins/kibana_react/public'; | ||
|
||
export interface AlertingFrameworkHealth { | ||
isSufficientlySecure: boolean; | ||
hasPermanentEncryptionKey: boolean; | ||
} | ||
|
||
const showTlsAndEncryptionError = () => { | ||
const { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } = Legacy.shims.docLinks; | ||
|
||
Legacy.shims.toastNotifications.addWarning({ | ||
title: toMountPoint( | ||
<FormattedMessage | ||
id="xpack.monitoring.healthCheck.tlsAndEncryptionErrorTitle" | ||
defaultMessage="Additional setup required" | ||
/> | ||
), | ||
text: toMountPoint( | ||
<div> | ||
<p> | ||
{i18n.translate('xpack.monitoring.healthCheck.tlsAndEncryptionError', { | ||
defaultMessage: `You must enable Transport Layer Security between Kibana and Elasticsearch | ||
and configure an encryption key in your kibana.yml file to use the Alerting feature.`, | ||
})} | ||
</p> | ||
<EuiSpacer /> | ||
<EuiLink | ||
href={`${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/alert-action-settings-kb.html#general-alert-action-settings`} | ||
external | ||
target="_blank" | ||
> | ||
{i18n.translate('xpack.monitoring.healthCheck.encryptionErrorAction', { | ||
defaultMessage: 'Learn how.', | ||
})} | ||
</EuiLink> | ||
</div> | ||
), | ||
}); | ||
}; | ||
|
||
const showEncryptionError = () => { | ||
const { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } = Legacy.shims.docLinks; | ||
|
||
Legacy.shims.toastNotifications.addWarning( | ||
{ | ||
title: toMountPoint( | ||
<FormattedMessage | ||
id="xpack.monitoring.healthCheck.encryptionErrorTitle" | ||
defaultMessage="You must set an encryption key" | ||
/> | ||
), | ||
text: toMountPoint( | ||
<div role="banner"> | ||
{i18n.translate('xpack.monitoring.healthCheck.encryptionErrorBeforeKey', { | ||
defaultMessage: 'To create an alert, set a value for ', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, like before, the user will not understand what this means because they aren't consciously enabling or interacting with alerts There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah you're right! Wondering if we should just use one generic message from https://github.com/elastic/kibana/pull/71846/files#r455776054 if any of the two requirements ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea I'm not sure what we want to say here. Something like "out of the box alerts require x, y, z. See {link} on how to configure this". Honestly, I'd default to @ravikesarwani @lcawl @gchaps for help here on the messaging There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Worked with @lcawl on the text. Does this work: Alerting requires Transport Layer Security between Kibana and Elasticsearch and an encryption key in your kibana.yml file. Learn how to enable TLS. where "Lean how to enable TLS" links to the documentation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea, I think that works. i'll open a new PR for this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #72310 |
||
})} | ||
<EuiText size="xs"> | ||
<EuiCode>{'xpack.encryptedSavedObjects.encryptionKey'}</EuiCode> | ||
</EuiText> | ||
{i18n.translate('xpack.monitoring.healthCheck.encryptionErrorAfterKey', { | ||
defaultMessage: ' in your kibana.yml file. ', | ||
})} | ||
<EuiLink | ||
href={`${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/alert-action-settings-kb.html#general-alert-action-settings`} | ||
external | ||
target="_blank" | ||
> | ||
{i18n.translate('xpack.monitoring.healthCheck.encryptionErrorAction', { | ||
defaultMessage: 'Learn how.', | ||
})} | ||
</EuiLink> | ||
</div> | ||
), | ||
}, | ||
{} | ||
); | ||
}; | ||
|
||
const showTlsError = () => { | ||
const { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } = Legacy.shims.docLinks; | ||
|
||
Legacy.shims.toastNotifications.addWarning({ | ||
title: toMountPoint( | ||
<FormattedMessage | ||
id="xpack.monitoring.healthCheck.tlsErrorTitle" | ||
defaultMessage="You must enable Transport Layer Security" | ||
/> | ||
), | ||
text: toMountPoint( | ||
<div role="banner"> | ||
{i18n.translate('xpack.monitoring.healthCheck.tlsError', { | ||
defaultMessage: | ||
'Alerting relies on API keys, which require TLS between Elasticsearch and Kibana. ', | ||
})} | ||
<EuiLink | ||
href={`${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/configuring-tls.html`} | ||
external | ||
target="_blank" | ||
> | ||
{i18n.translate('xpack.monitoring.healthCheck.tlsErrorAction', { | ||
defaultMessage: 'Learn how to enable TLS.', | ||
})} | ||
</EuiLink> | ||
</div> | ||
), | ||
}); | ||
}; | ||
|
||
export const showSecurityToast = (alertingHealth: AlertingFrameworkHealth) => { | ||
const { isSufficientlySecure, hasPermanentEncryptionKey } = alertingHealth; | ||
if ( | ||
Array.isArray(alertingHealth) || | ||
(!alertingHealth.hasOwnProperty('isSufficientlySecure') && | ||
!alertingHealth.hasOwnProperty('hasPermanentEncryptionKey')) | ||
) { | ||
return; | ||
} | ||
|
||
if (!isSufficientlySecure && !hasPermanentEncryptionKey) { | ||
showTlsAndEncryptionError(); | ||
} else if (!isSufficientlySecure) { | ||
showTlsError(); | ||
} else if (!hasPermanentEncryptionKey) { | ||
showEncryptionError(); | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
import { RequestHandlerContext } from 'kibana/server'; | ||
import { EncryptedSavedObjectsPluginSetup } from '../../../../encrypted_saved_objects/server'; | ||
|
||
export interface AlertingFrameworkHealth { | ||
isSufficientlySecure: boolean; | ||
hasPermanentEncryptionKey: boolean; | ||
} | ||
|
||
export interface XPackUsageSecurity { | ||
security?: { | ||
enabled?: boolean; | ||
ssl?: { | ||
http?: { | ||
enabled?: boolean; | ||
}; | ||
}; | ||
}; | ||
} | ||
|
||
export class AlertingSecurity { | ||
public static readonly getSecurityHealth = async ( | ||
context: RequestHandlerContext, | ||
encryptedSavedObjects: EncryptedSavedObjectsPluginSetup | ||
): Promise<AlertingFrameworkHealth> => { | ||
const { | ||
security: { | ||
enabled: isSecurityEnabled = false, | ||
ssl: { http: { enabled: isTLSEnabled = false } = {} } = {}, | ||
} = {}, | ||
}: XPackUsageSecurity = await context.core.elasticsearch.legacy.client.callAsInternalUser( | ||
'transport.request', | ||
{ | ||
method: 'GET', | ||
path: '/_xpack/usage', | ||
} | ||
); | ||
|
||
return { | ||
isSufficientlySecure: !isSecurityEnabled || (isSecurityEnabled && isTLSEnabled), | ||
hasPermanentEncryptionKey: !encryptedSavedObjects.usingEphemeralEncryptionKey, | ||
}; | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we probably want to modify this message slightly since the user didn't do any explicit actions to enable alerting and will probably have no context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! What do you think about:
Any suggestions would be helpful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure honestly. cc @ravikesarwani @lcawl @gchaps for help here