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

* [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 18:12:54 +00:00 committed by GitHub
parent 43927b8707
commit 420906569e
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.