mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Uses asCurrentUser in getClusterUuid (#82908)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
e1b7073a64
commit
fdb9d76fbd
2 changed files with 10 additions and 6 deletions
|
@ -73,8 +73,9 @@ export function registerStatsRoute({
|
|||
return collectorSet.toObject(usage);
|
||||
};
|
||||
|
||||
const getClusterUuid = async (callCluster: LegacyAPICaller): Promise<string> => {
|
||||
const { cluster_uuid: uuid } = await callCluster('info', { filterPath: 'cluster_uuid' });
|
||||
const getClusterUuid = async (asCurrentUser: ElasticsearchClient): Promise<string> => {
|
||||
const { body } = await asCurrentUser.info({ filter_path: 'cluster_uuid' });
|
||||
const { cluster_uuid: uuid } = body;
|
||||
return uuid;
|
||||
};
|
||||
|
||||
|
@ -103,7 +104,7 @@ export function registerStatsRoute({
|
|||
let extended;
|
||||
if (isExtended) {
|
||||
const callCluster = context.core.elasticsearch.legacy.client.callAsCurrentUser;
|
||||
const esClient = context.core.elasticsearch.client.asCurrentUser;
|
||||
const { asCurrentUser } = context.core.elasticsearch.client;
|
||||
const savedObjectsClient = context.core.savedObjects.client;
|
||||
|
||||
if (shouldGetUsage) {
|
||||
|
@ -114,9 +115,12 @@ export function registerStatsRoute({
|
|||
}
|
||||
|
||||
const usagePromise = shouldGetUsage
|
||||
? getUsage(callCluster, esClient, savedObjectsClient)
|
||||
? getUsage(callCluster, asCurrentUser, savedObjectsClient)
|
||||
: Promise.resolve({});
|
||||
const [usage, clusterUuid] = await Promise.all([usagePromise, getClusterUuid(callCluster)]);
|
||||
const [usage, clusterUuid] = await Promise.all([
|
||||
usagePromise,
|
||||
getClusterUuid(asCurrentUser),
|
||||
]);
|
||||
|
||||
let modifiedUsage = usage;
|
||||
if (isLegacy) {
|
||||
|
|
|
@ -30,7 +30,7 @@ export default function ({ getService }) {
|
|||
});
|
||||
|
||||
it('should return 401 for extended', async () => {
|
||||
await supertestNoAuth.get('/api/stats?extended').expect(401);
|
||||
await supertestNoAuth.get('/api/stats?extended').auth(null, null).expect(401);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue