Added organization settings to disable plugin import and sharing

This commit is contained in:
Thorsten Sommer 2026-08-04 19:46:58 +02:00
parent 6adfd24061
commit 294d242986
Signed by untrusted user who does not match committer: tsommer
GPG Key ID: 371BBA77A02C0108
14 changed files with 192 additions and 6 deletions

View File

@ -3280,6 +3280,9 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::HALLUZINATIONREMINDER::T3528806904"] = "L
-- Issues
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ISSUES::T3229841001"] = "Issues"
-- This feature is managed by your organization and has therefore been disabled.
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANAGEDFEATURELOCK::T1416426626"] = "This feature is managed by your organization and has therefore been disabled."
-- Your Pandoc installation meets the requirements.
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANAGEPANDOCDEPENDENCY::T1167365374"] = "Your Pandoc installation meets the requirements."
@ -7948,12 +7951,21 @@ UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3143506997"] = "The assistant plugin
-- An error occurred while sharing the plugin.
UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3184210266"] = "An error occurred while sharing the plugin."
-- Your organization has disabled importing plugins.
UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3212529834"] = "Your organization has disabled importing plugins."
-- Import assistant plugin
UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3246593895"] = "Import assistant plugin"
-- Your organization has disabled exporting plugins.
UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3342440765"] = "Your organization has disabled exporting plugins."
-- Share plugin archive
UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3355474457"] = "Share plugin archive"
-- Your organization has disabled sharing plugins.
UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3379469503"] = "Your organization has disabled sharing plugins."
-- Close
UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3448155331"] = "Close"
@ -9562,6 +9574,9 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::ASSISTANTPLUGININSTALLSERVICE::T2955
-- The generated assistant plugin uses the ID of an internal AI Studio plugin.
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::ASSISTANTPLUGININSTALLSERVICE::T3162363526"] = "The generated assistant plugin uses the ID of an internal AI Studio plugin."
-- Your organization has disabled importing plugins.
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::ASSISTANTPLUGININSTALLSERVICE::T3212529834"] = "Your organization has disabled importing plugins."
-- The plugin archive must contain exactly one plugin.lua file.
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::ASSISTANTPLUGININSTALLSERVICE::T3355918609"] = "The plugin archive must contain exactly one plugin.lua file."
@ -9664,6 +9679,9 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::PLUGINSHARESERVICE::T2350673880"] =
-- The plugin has no local directory.
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::PLUGINSHARESERVICE::T3284289028"] = "The plugin has no local directory."
-- Your organization has disabled sharing plugins.
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::PLUGINSHARESERVICE::T3379469503"] = "Your organization has disabled sharing plugins."
-- The plugin directory is invalid: {0}
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::PLUGINSHARESERVICE::T3774594541"] = "The plugin directory is invalid: {0}"

View File

@ -0,0 +1,9 @@
@inherits MSGComponentBase
@if (this.IsLocked())
{
@* MudTooltip.RootStyle is set as a workaround for issue -> https://github.com/MudBlazor/MudBlazor/issues/10882 *@
<MudTooltip Text="@this.LockTextOrDefault" Arrow="true" Placement="@this.Placement" RootStyle="display:inline-flex;">
<MudIcon Icon="@Icons.Material.Filled.Lock" Color="Color.Error" Size="Size.Small" Class="@this.Class"/>
</MudTooltip>
}

View File

@ -0,0 +1,65 @@
using Microsoft.AspNetCore.Components;
namespace AIStudio.Components;
/// <summary>
/// Shows a lock icon for features that a configuration plugin has disabled. The related
/// control stays visible but must be disabled by the caller, so users still see that the
/// feature exists and learn that their organization has locked it.
/// </summary>
public partial class ManagedFeatureLock : MSGComponentBase
{
/// <summary>
/// Is the feature locked by a configuration plugin?
/// </summary>
[Parameter]
public Func<bool> IsLocked { get; set; } = () => false;
/// <summary>
/// An optional text that explains the lock. Without it, the generic explanation is used.
/// </summary>
[Parameter]
public string LockText { get; set; } = string.Empty;
/// <summary>
/// Where should the tooltip be placed?
/// </summary>
[Parameter]
public Placement Placement { get; set; } = Placement.Left;
/// <summary>
/// The CSS class to apply to the lock icon.
/// </summary>
[Parameter]
public string Class { get; set; } = "mr-1";
private string LockTextOrDefault => string.IsNullOrWhiteSpace(this.LockText)
? this.T("This feature is managed by your organization and has therefore been disabled.")
: this.LockText;
#region Overrides of ComponentBase
protected override async Task OnInitializedAsync()
{
this.ApplyFilters([], [ Event.CONFIGURATION_CHANGED ]);
await base.OnInitializedAsync();
}
#endregion
#region Overrides of MSGComponentBase
protected override Task ProcessIncomingMessage<T>(ComponentBase? sendingComponent, Event triggeredEvent, T? data) where T : default
{
switch (triggeredEvent)
{
case Event.CONFIGURATION_CHANGED:
this.StateHasChanged();
break;
}
return Task.CompletedTask;
}
#endregion
}

View File

@ -10,8 +10,9 @@
@T("Plugins")
</MudText>
<MudSpacer />
<ManagedFeatureLock IsLocked="@(() => !this.AllowPluginImport)" LockText="@T("Your organization has disabled importing plugins.")"/>
<MudTooltip Text="@T("Import assistant plugin")">
<MudButton Variant="Variant.Outlined" StartIcon="@IMPORT_ICON" OnClick="@this.ImportAssistantPluginAsync" Disabled="@this.isImportingAssistantPlugin">
<MudButton Variant="Variant.Outlined" StartIcon="@IMPORT_ICON" OnClick="@this.ImportAssistantPluginAsync" Disabled="@(this.isImportingAssistantPlugin || !this.AllowPluginImport)">
@T("Import")
</MudButton>
</MudTooltip>
@ -118,8 +119,9 @@
@if (context is IAvailablePlugin shareablePlugin && CanSharePlugin(shareablePlugin))
{
<ManagedFeatureLock IsLocked="@(() => !this.AllowPluginSharing)" LockText="@this.SharePluginLockText"/>
<MudTooltip Text="@this.SharePluginTooltip">
<MudIconButton Icon="@SharePluginIcon" Size="Size.Medium" OnClick="@(() => this.SharePluginAsync(shareablePlugin))" Disabled="@(!CanSharePlugin(shareablePlugin))"/>
<MudIconButton Icon="@SharePluginIcon" Size="Size.Medium" OnClick="@(() => this.SharePluginAsync(shareablePlugin))" Disabled="@(!this.AllowPluginSharing || !CanSharePlugin(shareablePlugin))"/>
</MudTooltip>
}

View File

@ -53,7 +53,7 @@ public partial class Plugins : MSGComponentBase
protected override async Task OnInitializedAsync()
{
this.ApplyFilters([], [ Event.PLUGINS_RELOADED ]);
this.ApplyFilters([], [ Event.PLUGINS_RELOADED, Event.CONFIGURATION_CHANGED ]);
this.groupConfig = new TableGroupDefinition<IPluginMetadata>
{
@ -214,6 +214,16 @@ public partial class Plugins : MSGComponentBase
private static bool CanSharePlugin(IAvailablePlugin plugin) => plugin is { IsInternal: false, IsManagedByConfigServer: false } && !string.IsNullOrWhiteSpace(plugin.LocalPath) && !IS_SHARING_PLUGIN;
/// <summary>
/// Organizations may disable importing plugin archives by using a configuration plugin.
/// </summary>
private bool AllowPluginImport => this.SettingsManager.ConfigurationData.App.AllowUserToImportPlugins;
/// <summary>
/// Organizations may disable sharing and exporting plugins by using a configuration plugin.
/// </summary>
private bool AllowPluginSharing => this.SettingsManager.ConfigurationData.App.AllowUserToSharePlugins;
/// <summary>
/// Linux has no native share sheet, hence the plugin archive is exported to a location of the
/// user's choice there. The action must be labeled accordingly.
@ -222,6 +232,8 @@ public partial class Plugins : MSGComponentBase
private string SharePluginTooltip => OperatingSystem.IsLinux() ? this.T("Export plugin archive") : this.T("Share plugin archive");
private string SharePluginLockText => OperatingSystem.IsLinux() ? this.T("Your organization has disabled exporting plugins.") : this.T("Your organization has disabled sharing plugins.");
private async Task OpenAssistantPluginEditorDialogAsync(IAvailablePlugin plugin)
{
var parameters = new DialogParameters<AssistantPluginEditorDialog>
@ -299,6 +311,9 @@ public partial class Plugins : MSGComponentBase
if (this.isImportingAssistantPlugin)
return;
if (!this.AllowPluginImport)
return;
this.isImportingAssistantPlugin = true;
await this.InvokeAsync(this.StateHasChanged);

View File

@ -235,6 +235,15 @@ CONFIG["SETTINGS"] = {}
-- Configure the user permission to add providers:
-- CONFIG["SETTINGS"]["DataApp.AllowUserToAddProvider"] = false
-- Configure the user permission to import plugin archives from disk.
-- When set to false, the import button on the plugins page stays visible but is disabled.
-- CONFIG["SETTINGS"]["DataApp.AllowUserToImportPlugins"] = false
-- Configure the user permission to share or export plugins as archives.
-- When set to false, the share button on the plugins page stays visible but is disabled.
-- On Linux, this button exports the plugin archive instead of using a native share sheet.
-- CONFIG["SETTINGS"]["DataApp.AllowUserToSharePlugins"] = false
-- Configure whether administration settings are visible in the UI:
-- CONFIG["SETTINGS"]["DataApp.ShowAdminSettings"] = true

View File

@ -3282,6 +3282,9 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::HALLUZINATIONREMINDER::T3528806904"] = "L
-- Issues
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ISSUES::T3229841001"] = "Probleme"
-- This feature is managed by your organization and has therefore been disabled.
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANAGEDFEATURELOCK::T1416426626"] = "Diese Funktion wird von Ihrer Organisation verwaltet und wurde daher deaktiviert."
-- Your Pandoc installation meets the requirements.
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANAGEPANDOCDEPENDENCY::T1167365374"] = "Ihre Pandoc-Installation erfüllt die Anforderungen."
@ -7950,12 +7953,21 @@ UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3143506997"] = "Das Assistent-Plugin
-- An error occurred while sharing the plugin.
UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3184210266"] = "Beim Teilen des Plugins ist ein Fehler aufgetreten."
-- Your organization has disabled importing plugins.
UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3212529834"] = "Ihre Organisation hat das Importieren von Plugins deaktiviert."
-- Import assistant plugin
UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3246593895"] = "Assistenten-Plugin importieren"
-- Your organization has disabled exporting plugins.
UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3342440765"] = "Ihre Organisation hat das Exportieren von Plugins deaktiviert."
-- Share plugin archive
UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3355474457"] = "Plugin-Archiv teilen"
-- Your organization has disabled sharing plugins.
UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3379469503"] = "Ihre Organisation hat das Teilen von Plugins deaktiviert."
-- Close
UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3448155331"] = "Schließen"
@ -9564,6 +9576,9 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::ASSISTANTPLUGININSTALLSERVICE::T2955
-- The generated assistant plugin uses the ID of an internal AI Studio plugin.
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::ASSISTANTPLUGININSTALLSERVICE::T3162363526"] = "Das generierte Assistent-Plugin verwendet die ID eines internen AI-Studio-Plugins."
-- Your organization has disabled importing plugins.
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::ASSISTANTPLUGININSTALLSERVICE::T3212529834"] = "Ihre Organisation hat das Importieren von Plugins deaktiviert."
-- The plugin archive must contain exactly one plugin.lua file.
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::ASSISTANTPLUGININSTALLSERVICE::T3355918609"] = "Das Plugin-Archiv muss genau eine plugin.lua-Datei enthalten."
@ -9666,6 +9681,9 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::PLUGINSHARESERVICE::T2350673880"] =
-- The plugin has no local directory.
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::PLUGINSHARESERVICE::T3284289028"] = "Das Plugin hat kein lokales Verzeichnis."
-- Your organization has disabled sharing plugins.
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::PLUGINSHARESERVICE::T3379469503"] = "Ihre Organisation hat das Teilen von Plugins deaktiviert."
-- The plugin directory is invalid: {0}
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::PLUGINSHARESERVICE::T3774594541"] = "Das Plugin-Verzeichnis ist ungültig: {0}"

View File

@ -3282,6 +3282,9 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::HALLUZINATIONREMINDER::T3528806904"] = "L
-- Issues
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ISSUES::T3229841001"] = "Issues"
-- This feature is managed by your organization and has therefore been disabled.
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANAGEDFEATURELOCK::T1416426626"] = "This feature is managed by your organization and has therefore been disabled."
-- Your Pandoc installation meets the requirements.
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANAGEPANDOCDEPENDENCY::T1167365374"] = "Your Pandoc installation meets the requirements."
@ -7950,12 +7953,21 @@ UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3143506997"] = "The assistant plugin
-- An error occurred while sharing the plugin.
UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3184210266"] = "An error occurred while sharing the plugin."
-- Your organization has disabled importing plugins.
UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3212529834"] = "Your organization has disabled importing plugins."
-- Import assistant plugin
UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3246593895"] = "Import assistant plugin"
-- Your organization has disabled exporting plugins.
UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3342440765"] = "Your organization has disabled exporting plugins."
-- Share plugin archive
UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3355474457"] = "Share plugin archive"
-- Your organization has disabled sharing plugins.
UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3379469503"] = "Your organization has disabled sharing plugins."
-- Close
UI_TEXT_CONTENT["AISTUDIO::PAGES::PLUGINS::T3448155331"] = "Close"
@ -9564,6 +9576,9 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::ASSISTANTPLUGININSTALLSERVICE::T2955
-- The generated assistant plugin uses the ID of an internal AI Studio plugin.
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::ASSISTANTPLUGININSTALLSERVICE::T3162363526"] = "The generated assistant plugin uses the ID of an internal AI Studio plugin."
-- Your organization has disabled importing plugins.
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::ASSISTANTPLUGININSTALLSERVICE::T3212529834"] = "Your organization has disabled importing plugins."
-- The plugin archive must contain exactly one plugin.lua file.
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::ASSISTANTPLUGININSTALLSERVICE::T3355918609"] = "The plugin archive must contain exactly one plugin.lua file."
@ -9666,6 +9681,9 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::PLUGINSHARESERVICE::T2350673880"] =
-- The plugin has no local directory.
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::PLUGINSHARESERVICE::T3284289028"] = "The plugin has no local directory."
-- Your organization has disabled sharing plugins.
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::PLUGINSHARESERVICE::T3379469503"] = "Your organization has disabled sharing plugins."
-- The plugin directory is invalid: {0}
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::PLUGINSHARESERVICE::T3774594541"] = "The plugin directory is invalid: {0}"

View File

@ -148,7 +148,17 @@ public sealed class DataApp(Expression<Func<Data, DataApp>>? configSelection = n
/// Should the user be allowed to add providers?
/// </summary>
public bool AllowUserToAddProvider { get; set; } = ManagedConfiguration.Register(configSelection, n => n.AllowUserToAddProvider, true);
/// <summary>
/// Should the user be allowed to import plugin archives from disk?
/// </summary>
public bool AllowUserToImportPlugins { get; set; } = ManagedConfiguration.Register(configSelection, n => n.AllowUserToImportPlugins, true);
/// <summary>
/// Should the user be allowed to share or export plugins as archives?
/// </summary>
public bool AllowUserToSharePlugins { get; set; } = ManagedConfiguration.Register(configSelection, n => n.AllowUserToSharePlugins, true);
/// <summary>
/// Should administration settings be visible in the UI?
/// </summary>

View File

@ -179,6 +179,12 @@ public sealed class PluginConfiguration(bool isInternal, LuaState state, PluginT
// Config: allow the user to add providers?
ManagedConfiguration.TryProcessConfiguration(x => x.App, x => x.AllowUserToAddProvider, this.Id, settingsTable, dryRun);
// Config: allow the user to import plugin archives?
ManagedConfiguration.TryProcessConfiguration(x => x.App, x => x.AllowUserToImportPlugins, this.Id, settingsTable, dryRun);
// Config: allow the user to share or export plugins?
ManagedConfiguration.TryProcessConfiguration(x => x.App, x => x.AllowUserToSharePlugins, this.Id, settingsTable, dryRun);
// Config: show administration settings?
ManagedConfiguration.TryProcessConfiguration(x => x.App, x => x.ShowAdminSettings, this.Id, settingsTable, dryRun);

View File

@ -265,6 +265,14 @@ public static partial class PluginFactory
if(ManagedConfiguration.IsConfigurationLeftOver(x => x.App, x => x.AllowUserToAddProvider, AVAILABLE_PLUGINS))
wasConfigurationChanged = true;
// Check for the plugin import permission:
if(ManagedConfiguration.IsConfigurationLeftOver(x => x.App, x => x.AllowUserToImportPlugins, AVAILABLE_PLUGINS))
wasConfigurationChanged = true;
// Check for the plugin sharing permission:
if(ManagedConfiguration.IsConfigurationLeftOver(x => x.App, x => x.AllowUserToSharePlugins, AVAILABLE_PLUGINS))
wasConfigurationChanged = true;
// Check for admin settings visibility:
if(ManagedConfiguration.IsConfigurationLeftOver(x => x.App, x => x.ShowAdminSettings, AVAILABLE_PLUGINS))
wasConfigurationChanged = true;

View File

@ -152,6 +152,9 @@ public sealed class AssistantPluginInstallService
/// <returns>Installation result that contains success state, installed plugin metadata, and a user-facing issue when installation failed.</returns>
public async Task<AssistantPluginInstallResult> InstallArchiveAsync(string archivePath, CancellationToken token)
{
if (!this.settingsManager.ConfigurationData.App.AllowUserToImportPlugins)
return Error(TB("Your organization has disabled importing plugins."));
if (!FileTypes.IsAllowedPath(archivePath, FileTypes.PLUGIN_ARCHIVE))
return Error(TB("Please select a plugin archive with the extension .mwplugin or .zip."));

View File

@ -1,10 +1,11 @@
using System.IO.Compression;
using AIStudio.Settings;
using AIStudio.Tools.PluginSystem;
using AIStudio.Tools.Rust;
namespace AIStudio.Tools.Services;
public sealed class PluginShareService(NativeShareService nativeShareService, RustService rustService, ILogger<PluginShareService> logger)
public sealed class PluginShareService(NativeShareService nativeShareService, RustService rustService, SettingsManager settingsManager, ILogger<PluginShareService> logger)
{
private static PluginShareResult ShareError(IAvailablePlugin plugin, string issue) => new(false, plugin.Name, string.Empty, issue);
@ -36,6 +37,9 @@ public sealed class PluginShareService(NativeShareService nativeShareService, Ru
if (plugin.IsManagedByConfigServer)
return ShareError(plugin, TB("Config Server managed plugins cannot be shared."));
if (!settingsManager.ConfigurationData.App.AllowUserToSharePlugins)
return ShareError(plugin, TB("Your organization has disabled sharing plugins."));
if (!TryGetPluginRoot(plugin, out var pluginRoot, out var issue))
return ShareError(plugin, issue);

View File

@ -2,6 +2,7 @@
- Added a prototype Visual Briefing Assistant that turns documents, data, images, audio, and video into self-contained interactive HTML briefings.
- Added organization-configurable defaults and visibility controls for the Visual Briefing Assistant.
- Added a share button for plugins, which uses the native share dialog on Windows and macOS. For Linux, we added an export option for plugins, which stores the plugin archive at a location of your choice.
- Added an import button on the plugins page to install plugin archives directly from your disk.
- Added an import button on the plugin page to install plugin archives directly from your files.
- Added the dedicated file extension `.mwplugin` for plugin archives.
- Added an option for organizations to disable importing, sharing, and exporting plugins.
- Upgraded dependencies to their latest versions to improve security and stability.