-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Monitoring] Improve permissions required around setup mode (#50421)
* Add error messages when setup mode is not enabled, disable it for users without the necessary permissions, and change one query to relax the privilege requirements * Fix default value * PR feedback * Forgot to update this part * Fix tests
- Loading branch information
1 parent
bde2895
commit 66038f5
Showing
14 changed files
with
186 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,7 @@ | |
}, | ||
"_meta": { | ||
"secondsAgo": 30, | ||
"liveClusterUuid": null | ||
"liveClusterUuid": null, | ||
"hasPermissions": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,7 @@ | |
}, | ||
"_meta": { | ||
"secondsAgo": 30, | ||
"liveClusterUuid": null | ||
"liveClusterUuid": null, | ||
"hasPermissions": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,7 @@ | |
}, | ||
"_meta": { | ||
"secondsAgo": 30, | ||
"liveClusterUuid": null | ||
"liveClusterUuid": null, | ||
"hasPermissions": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,7 @@ | |
}, | ||
"_meta": { | ||
"secondsAgo": 30, | ||
"liveClusterUuid": null | ||
"liveClusterUuid": null, | ||
"hasPermissions": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,7 @@ | |
}, | ||
"_meta": { | ||
"secondsAgo": 30, | ||
"liveClusterUuid": null | ||
"liveClusterUuid": null, | ||
"hasPermissions": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,7 @@ | |
}, | ||
"_meta": { | ||
"secondsAgo": 30, | ||
"liveClusterUuid": null | ||
"liveClusterUuid": null, | ||
"hasPermissions": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,7 @@ | |
}, | ||
"_meta": { | ||
"secondsAgo": 30, | ||
"liveClusterUuid": null | ||
"liveClusterUuid": null, | ||
"hasPermissions": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,7 @@ | |
}, | ||
"_meta": { | ||
"secondsAgo": 30, | ||
"liveClusterUuid": null | ||
"liveClusterUuid": null, | ||
"hasPermissions": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,7 @@ | |
}, | ||
"_meta": { | ||
"secondsAgo": 30, | ||
"liveClusterUuid": null | ||
"liveClusterUuid": null, | ||
"hasPermissions": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
x-pack/test/api_integration/apis/monitoring/setup/collection/security.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* 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 expect from '@kbn/expect'; | ||
|
||
export default function ({ getService }) { | ||
const supertest = getService('supertest'); | ||
const esArchiver = getService('esArchiver'); | ||
const security = getService('security'); | ||
const supertestWithoutAuth = getService('supertestWithoutAuth'); | ||
|
||
describe('security', () => { | ||
const archive = 'monitoring/setup/collection/kibana_exclusive_mb'; | ||
const timeRange = { | ||
min: '2019-04-09T00:00:00.741Z', | ||
max: '2019-04-09T23:59:59.741Z' | ||
}; | ||
|
||
before('load archive', () => { | ||
return esArchiver.load(archive); | ||
}); | ||
|
||
after('unload archive', () => { | ||
return esArchiver.unload(archive); | ||
}); | ||
|
||
it('should allow access to elevated user', async () => { | ||
const { body } = await supertest | ||
.post('/api/monitoring/v1/setup/collection/cluster?skipLiveData=true') | ||
.set('kbn-xsrf', 'xxx') | ||
.send({ timeRange }) | ||
.expect(200); | ||
|
||
expect(body.hasPermissions).to.not.be(false); | ||
}); | ||
|
||
it('should say permission denied for limited user', async () => { | ||
const username = 'limited_user'; | ||
const password = 'changeme'; | ||
|
||
await security.user.create(username, { | ||
password: password, | ||
full_name: 'Limited User', | ||
roles: ['kibana_user', 'monitoring_user'] | ||
}); | ||
|
||
const { body } = await supertestWithoutAuth | ||
.post('/api/monitoring/v1/setup/collection/cluster?skipLiveData=true') | ||
.auth(username, password) | ||
.set('kbn-xsrf', 'xxx') | ||
.send({ timeRange }) | ||
.expect(200); | ||
|
||
expect(body._meta.hasPermissions).to.be(false); | ||
}); | ||
}); | ||
} |