-
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.
[Fleet] Add base Fleet authz logic and API (#119199)
* Add base Fleet authz logic and API * Fix linter error * Fix ts checks * Fix ts checks again Co-authored-by: criamico <[email protected]> Co-authored-by: Kibana Machine <[email protected]> # Conflicts: # x-pack/plugins/fleet/storybook/context/index.tsx
- Loading branch information
Showing
12 changed files
with
246 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
export interface FleetAuthz { | ||
fleet: { | ||
all: boolean; | ||
setup: boolean; | ||
readEnrollmentTokens: boolean; | ||
}; | ||
|
||
integrations: { | ||
readPackageInfo: boolean; | ||
readInstalledPackages: boolean; | ||
installPackages: boolean; | ||
upgradePackages: boolean; | ||
removePackages: boolean; | ||
|
||
readPackageSettings: boolean; | ||
writePackageSettings: boolean; | ||
|
||
readIntegrationPolicies: boolean; | ||
writeIntegrationPolicies: boolean; | ||
}; | ||
} | ||
|
||
interface CalculateParams { | ||
fleet: { | ||
all: boolean; | ||
setup: boolean; | ||
}; | ||
|
||
integrations: { | ||
all: boolean; | ||
read: boolean; | ||
}; | ||
} | ||
|
||
export const calculateAuthz = ({ fleet, integrations }: CalculateParams): FleetAuthz => ({ | ||
fleet: { | ||
all: fleet.all && (integrations.all || integrations.read), | ||
|
||
// These are currently used by Fleet Server setup | ||
setup: fleet.all || fleet.setup, | ||
readEnrollmentTokens: fleet.all || fleet.setup, | ||
}, | ||
|
||
integrations: { | ||
readPackageInfo: fleet.all || fleet.setup || integrations.all || integrations.read, | ||
readInstalledPackages: integrations.all || integrations.read, | ||
installPackages: fleet.all && integrations.all, | ||
upgradePackages: fleet.all && integrations.all, | ||
removePackages: fleet.all && integrations.all, | ||
|
||
readPackageSettings: fleet.all && integrations.all, | ||
writePackageSettings: fleet.all && integrations.all, | ||
|
||
readIntegrationPolicies: fleet.all && integrations.all, | ||
writeIntegrationPolicies: fleet.all && integrations.all, | ||
}, | ||
}); |
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
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
Oops, something went wrong.