-
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
Beginning to use the ES APIs to insert/check privileges #18645
Changes from 2 commits
d243802
d9c93b7
5aaf5bc
05c594f
4d60ca1
03c429a
1d2b564
a9fda18
80494b8
6567941
d93b758
442ee73
3019006
5a16dea
92ab282
bb87576
6f83da2
1ea7cb9
dddccb6
f0f705e
98c9d8c
19dd2bc
c35e759
4385765
e621440
4096be9
22a22ac
9d73c4b
ab2d9ff
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 |
---|---|---|
|
@@ -17,12 +17,14 @@ export class SecureSavedObjectsClient { | |
request, | ||
baseClient, | ||
application, | ||
kibanaVersion, | ||
} = options; | ||
|
||
this.errors = baseClient.errors; | ||
|
||
this._client = baseClient; | ||
this._application = application; | ||
this._kibanaVersion = kibanaVersion; | ||
this._callCluster = getClient(server).callWithRequest; | ||
this._request = request; | ||
} | ||
|
@@ -48,8 +50,7 @@ export class SecureSavedObjectsClient { | |
} | ||
|
||
async find(options = {}) { | ||
// TODO(legrego) - need to constrain which types users can search for... | ||
await this._performAuthorizationCheck(null, 'search', null, options); | ||
await this._performAuthorizationCheck(options.type, 'search', null, options); | ||
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. Is 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. I still need to track down all the usages, the basic features that I've tested provide the options.type, and if they don't it's not going to authorize them 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. Have you come across any where we aren't providing this? |
||
|
||
return await this._client.find(options); | ||
} | ||
|
@@ -75,22 +76,21 @@ export class SecureSavedObjectsClient { | |
} | ||
|
||
async _performAuthorizationCheck(type, action, attributes = {}, options = {}) { // eslint-disable-line no-unused-vars | ||
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. We might be able to remove 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. Awesome, I'll remove it for the time being and we can add it back if we need to. |
||
return; | ||
// TODO(legrego) use ES Custom Privilege API once implemented. | ||
const kibanaAction = `saved-objects/${type}/${action}`; | ||
const version = `version:${this._kibanaVersion}`; | ||
const kibanaAction = `action:saved-objects/${type}/${action}`; | ||
|
||
const privilegeCheck = await this._callCluster(this._request, 'shield.hasPrivileges', { | ||
body: { | ||
applications: [{ | ||
application: this._application, | ||
resources: ['default'], | ||
privileges: [kibanaAction] | ||
privileges: [version, kibanaAction] | ||
}] | ||
} | ||
}); | ||
|
||
if (!privilegeCheck.has_all_requested) { | ||
throw Boom.unauthorized(`User ${privilegeCheck.username} is not authorized to ${action} objects of type ${type}`); | ||
throw Boom.forbidden(`User ${privilegeCheck.username} is not authorized to ${action} objects of type ${type}`); | ||
} | ||
} | ||
} |
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.
Do you have any thoughts yet on how we'd make this space aware? We don't need a solution for phase 1, but what do you think about parameterizing or abstracting this piece?
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've been delaying that for the moment, and have 'default' hard-coded a few places. We can introduce a constant that we use for this at the moment, a bunch of stuff is going to likely change once we become space aware but we'll likely still need the constant around because we'll be treating the default space "special" when it comes to routing and behaving without spaces.