Skip to content
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

Add remote index privileges to role management #154948

Merged
merged 10 commits into from
Apr 19, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ export interface SecurityLicenseFeatures {
*/
readonly allowRoleFieldLevelSecurity: boolean;

/**
* Indicates whether we allow users to define remote index privileges in roles.
*/
readonly allowRoleRemoteIndexPrivileges: boolean;

/**
* Indicates whether we allow Role-based access control (RBAC).
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ describe('license features', function () {
allowAccessAgreement: false,
allowRoleDocumentLevelSecurity: false,
allowRoleFieldLevelSecurity: false,
allowRoleRemoteIndexPrivileges: false,
layout: 'error-es-unavailable',
allowRbac: false,
allowSubFeaturePrivileges: false,
Expand All @@ -48,6 +49,7 @@ describe('license features', function () {
allowAccessAgreement: false,
allowRoleDocumentLevelSecurity: false,
allowRoleFieldLevelSecurity: false,
allowRoleRemoteIndexPrivileges: false,
layout: 'error-xpack-unavailable',
allowRbac: false,
allowSubFeaturePrivileges: false,
Expand Down Expand Up @@ -78,6 +80,7 @@ describe('license features', function () {
"allowRbac": false,
"allowRoleDocumentLevelSecurity": false,
"allowRoleFieldLevelSecurity": false,
"allowRoleRemoteIndexPrivileges": false,
"allowSubFeaturePrivileges": false,
"allowUserProfileCollaboration": false,
"layout": "error-xpack-unavailable",
Expand All @@ -100,6 +103,7 @@ describe('license features', function () {
"allowRbac": true,
"allowRoleDocumentLevelSecurity": true,
"allowRoleFieldLevelSecurity": true,
"allowRoleRemoteIndexPrivileges": true,
"allowSubFeaturePrivileges": true,
"allowUserProfileCollaboration": true,
"showLinks": true,
Expand Down Expand Up @@ -132,6 +136,7 @@ describe('license features', function () {
allowAccessAgreement: false,
allowRoleDocumentLevelSecurity: false,
allowRoleFieldLevelSecurity: false,
allowRoleRemoteIndexPrivileges: false,
allowRbac: true,
allowSubFeaturePrivileges: false,
allowAuditLogging: false,
Expand All @@ -158,6 +163,7 @@ describe('license features', function () {
allowAccessAgreement: false,
allowRoleDocumentLevelSecurity: false,
allowRoleFieldLevelSecurity: false,
allowRoleRemoteIndexPrivileges: false,
allowRbac: false,
allowSubFeaturePrivileges: false,
allowAuditLogging: false,
Expand All @@ -183,6 +189,7 @@ describe('license features', function () {
allowAccessAgreement: false,
allowRoleDocumentLevelSecurity: false,
allowRoleFieldLevelSecurity: false,
allowRoleRemoteIndexPrivileges: false,
allowRbac: true,
allowSubFeaturePrivileges: false,
allowAuditLogging: false,
Expand All @@ -208,6 +215,7 @@ describe('license features', function () {
allowAccessAgreement: true,
allowRoleDocumentLevelSecurity: false,
allowRoleFieldLevelSecurity: false,
allowRoleRemoteIndexPrivileges: false,
allowRbac: true,
allowSubFeaturePrivileges: true,
allowAuditLogging: true,
Expand All @@ -233,6 +241,7 @@ describe('license features', function () {
allowAccessAgreement: true,
allowRoleDocumentLevelSecurity: true,
allowRoleFieldLevelSecurity: true,
allowRoleRemoteIndexPrivileges: true,
allowRbac: true,
allowSubFeaturePrivileges: true,
allowAuditLogging: true,
Expand Down
3 changes: 3 additions & 0 deletions x-pack/plugins/security/common/licensing/license_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export class SecurityLicenseService {
allowAuditLogging: false,
allowRoleDocumentLevelSecurity: false,
allowRoleFieldLevelSecurity: false,
allowRoleRemoteIndexPrivileges: false,
allowRbac: false,
allowSubFeaturePrivileges: false,
allowUserProfileCollaboration: false,
Expand All @@ -104,6 +105,7 @@ export class SecurityLicenseService {
allowAuditLogging: false,
allowRoleDocumentLevelSecurity: false,
allowRoleFieldLevelSecurity: false,
allowRoleRemoteIndexPrivileges: false,
allowRbac: false,
allowSubFeaturePrivileges: false,
allowUserProfileCollaboration: false,
Expand All @@ -124,6 +126,7 @@ export class SecurityLicenseService {
// Only platinum and trial licenses are compliant with field- and document-level security.
allowRoleDocumentLevelSecurity: isLicensePlatinumOrBetter,
allowRoleFieldLevelSecurity: isLicensePlatinumOrBetter,
allowRoleRemoteIndexPrivileges: isLicensePlatinumOrBetter,
allowRbac: true,
allowUserProfileCollaboration: isLicenseStandardOrBetter,
};
Expand Down
7 changes: 6 additions & 1 deletion x-pack/plugins/security/common/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ export { shouldProviderUseLoginForm } from './authentication_provider';
export type { BuiltinESPrivileges } from './builtin_es_privileges';
export type { RawKibanaPrivileges, RawKibanaFeaturePrivileges } from './raw_kibana_privileges';
export type { FeaturesPrivileges } from './features_privileges';
export type { Role, RoleIndexPrivilege, RoleKibanaPrivilege } from './role';
export type {
Role,
RoleIndexPrivilege,
RoleRemoteIndexPrivilege,
RoleKibanaPrivilege,
} from './role';
export {
copyRole,
isRoleDeprecated,
Expand Down
5 changes: 5 additions & 0 deletions x-pack/plugins/security/common/model/role.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export interface RoleIndexPrivilege {
query?: string;
}

export interface RoleRemoteIndexPrivilege extends RoleIndexPrivilege {
clusters: string[];
}

export interface RoleKibanaPrivilege {
spaces: string[];
base: string[];
Expand All @@ -33,6 +37,7 @@ export interface Role {
elasticsearch: {
cluster: string[];
indices: RoleIndexPrivilege[];
remote_indices?: RoleRemoteIndexPrivilege[];
run_as: string[];
};
kibana: RoleKibanaPrivilege[];
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ function useRole(
return;
}

if (fetchedRole.elasticsearch.indices.length === 0) {
const isEditingExistingRole = !!roleName && action === 'edit';
if (!isEditingExistingRole && fetchedRole.elasticsearch.indices.length === 0) {
thomheymann marked this conversation as resolved.
Show resolved Hide resolved
const emptyOption: RoleIndexPrivilege = {
names: [],
privileges: [],
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading