kibana/x-pack/legacy/plugins/ml/server/lib/security_utils.js
2019-12-13 23:17:13 -07:00

19 lines
919 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.
*/
/*
* Contains utility functions related to x-pack security.
*/
export function isSecurityDisabled(xpackMainPlugin) {
const xpackInfo = xpackMainPlugin && xpackMainPlugin.info;
// we assume that `xpack.isAvailable()` always returns `true` because we're inside x-pack
// if for whatever reason it returns `false`, `isSecurityDisabled()` would also return `false`
// which would result in follow-up behavior assuming security is enabled. This is intentional,
// because it results in more defensive behavior.
const securityInfo = xpackInfo && xpackInfo.isAvailable() && xpackInfo.feature('security');
return securityInfo && securityInfo.isEnabled() === false;
}