[ML] Fixing saved object authorization check when security is disabled (#89850)

* [ML] Fixing saved object authorization check when security is disabled

* updating to use mode.useRbacForRequest for check
This commit is contained in:
James Gowdy 2021-02-01 16:19:56 +00:00 committed by GitHub
parent 19332c097a
commit 178637ce29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -10,6 +10,15 @@ import { ML_SAVED_OBJECT_TYPE } from '../../common/types/saved_objects';
export function authorizationProvider(authorization: SecurityPluginSetup['authz']) {
async function authorizationCheck(request: KibanaRequest) {
const shouldAuthorizeRequest = authorization?.mode.useRbacForRequest(request) ?? false;
if (shouldAuthorizeRequest === false) {
return {
canCreateGlobally: true,
canCreateAtSpace: true,
};
}
const checkPrivilegesWithRequest = authorization.checkPrivilegesWithRequest(request);
// Checking privileges "dynamically" will check against the current space, if spaces are enabled.
// If spaces are disabled, then this will check privileges globally instead.