Control which extensions users can install
Control Code - OSS extension installation by using a ConfigMap. Enforce a fine-grained allow or deny list by using the AllowedExtensions policy.
You can also block installs through the CLI, default extensions, and the workbench.extensions.command.installFromVSIX API command. The following properties are supported:
-
BlockCliExtensionsInstallation— when enabled, blocks installation of extensions through the CLI. -
BlockDefaultExtensionsInstallation— when enabled, blocks installation of default extensions. See Preinstall extensions in every workspace. -
BlockInstallFromVSIXCommandExtensionsInstallation— when enabled, blocks installation of extensions through theworkbench.extensions.command.installFromVSIXAPI command. -
AllowedExtensions— provides fine-grained control over Code - OSS extension installation. When this policy is applied, already installed extensions that are not allowed are disabled and display a warning. For conceptual background, see Configure allowed extensions.
-
An active
kubectlsession with administrative permissions to the Kubernetes cluster. See Overview of kubectl.
-
Add a new ConfigMap to the eclipse-che namespace and specify the properties you want to add:
kind: ConfigMap apiVersion: v1 metadata: name: vscode-editor-configurations namespace: eclipse-che labels: app.kubernetes.io/component: workspaces-config app.kubernetes.io/part-of: che.eclipse.org annotations: controller.devfile.io/mount-as: subpath controller.devfile.io/mount-path: /checode-config controller.devfile.io/read-only: 'true' data: policy.json: | { "BlockCliExtensionsInstallation": true, "BlockDefaultExtensionsInstallation": true, "BlockInstallFromVSIXCommandExtensionsInstallation": true, "AllowedExtensions": { "*": true, "dbaeumer.vscode-eslint": false, "ms-python.python": false, "redhat": false } }Ensure that the ConfigMap contains data in a valid JSON format.
-
Optional: To completely disable extension installation instead of using fine-grained control, set all extensions to disallowed:
kind: ConfigMap apiVersion: v1 metadata: name: vscode-editor-configurations namespace: eclipse-che labels: app.kubernetes.io/component: workspaces-config app.kubernetes.io/part-of: che.eclipse.org annotations: controller.devfile.io/mount-as: subpath controller.devfile.io/mount-path: /checode-config controller.devfile.io/read-only: 'true' data: policy.json: | { "AllowedExtensions": { "*": false } } -
Start or restart your workspace.
-
Optional: Add the ConfigMap in the user’s namespace:
kind: ConfigMap apiVersion: v1 metadata: name: vscode-editor-configurations labels: controller.devfile.io/mount-to-devworkspace: 'true' controller.devfile.io/watch-configmap: 'true' annotations: controller.devfile.io/mount-as: subpath controller.devfile.io/mount-path: /checode-config controller.devfile.io/read-only: 'true' data: policy.json: | { "AllowedExtensions": { "*": false } }When the ConfigMap is stored in the user’s namespace, the user can edit its values.
-
Verify that the
BlockCliExtensionsInstallationproperty is applied:-
Press F1, select Preferences: Open Settings (UI), and enter
BlockCliExtensionsInstallationin search. -
Provide a
.vsixfile and try CLI install. The installation fails with "Installation of extensions via CLI has been blocked by an administrator".
-
-
Verify that the
BlockDefaultExtensionsInstallationproperty is applied:-
Check Settings for the property.
-
Configure default extensions and verify they are not installed on workspace start or restart.
-
-
Verify that the
BlockInstallFromVSIXCommandExtensionsInstallationproperty is applied:-
Check Settings for the property.
-
The
workbench.extensions.command.installFromVSIXAPI command is blocked.
-
-
Verify that rules defined in the
AllowedExtensionssection are applied:-
Check Settings →
extensions.allowed. -
Disallowed extensions display a "This extension cannot be installed because it is not in the allowed list" warning.
-