From a1c4912600babc26040af0de4e9df53e9e25c669 Mon Sep 17 00:00:00 2001 From: Jannik Stehle <50302941+JammingBen@users.noreply.github.com> Date: Tue, 21 Nov 2023 15:53:22 +0100 Subject: [PATCH] feat: add and adjust configs for Web embed mode (#7766) * feat: add and adjust configs for embed mode * Update services/web/pkg/config/options.go Co-authored-by: Martin * docs: adjust description for WEB_OPTION_EMBED_TARGET --------- Co-authored-by: Martin --- changelog/5.0.0_2023-11-08/web-embed-mode-config.md | 7 ++++--- services/web/pkg/config/defaults/defaultconfig.go | 7 +++++++ services/web/pkg/config/options.go | 10 ++++++++-- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/changelog/5.0.0_2023-11-08/web-embed-mode-config.md b/changelog/5.0.0_2023-11-08/web-embed-mode-config.md index 580ad22074..4cfbbc8262 100644 --- a/changelog/5.0.0_2023-11-08/web-embed-mode-config.md +++ b/changelog/5.0.0_2023-11-08/web-embed-mode-config.md @@ -1,9 +1,10 @@ Enhancement: Configs for Web embed mode -Two new configs for the Web embed mode have been added: +New configs for the Web embed mode have been added: -* `mode` Defines the mode in which Web will be running. -* `embedTarget` Defines how Web is being integrated when running in embed mode. +* `enabled` Defines if embed mode is enabled. +* `target` Defines how Web is being integrated when running in embed mode. +* `messagesOrigin` Defines a URL under which Web can be integrated via iFrame. https://github.com/owncloud/ocis/pull/7670 https://github.com/owncloud/web/issues/9768 diff --git a/services/web/pkg/config/defaults/defaultconfig.go b/services/web/pkg/config/defaults/defaultconfig.go index ad50ca93ac..c3483f1a22 100644 --- a/services/web/pkg/config/defaults/defaultconfig.go +++ b/services/web/pkg/config/defaults/defaultconfig.go @@ -117,6 +117,7 @@ func DefaultConfig() *config.Config { AccountEditLink: &config.AccountEditLink{}, Editor: &config.Editor{}, FeedbackLink: &config.FeedbackLink{}, + Embed: &config.Embed{}, Routing: config.Routing{ IDBased: true, }, @@ -197,4 +198,10 @@ func Sanitize(cfg *config.Config) { if cfg.Web.Config.Options.Upload.XHR.Timeout == 0 && cfg.Web.Config.Options.Upload.CompanionURL == "" { cfg.Web.Config.Options.Upload = nil } + // remove Embed parent if no value is set + if cfg.Web.Config.Options.Embed.Enabled == "" && + cfg.Web.Config.Options.Embed.Target == "" && + cfg.Web.Config.Options.Embed.MessagesOrigin == "" { + cfg.Web.Config.Options.Embed = nil + } } diff --git a/services/web/pkg/config/options.go b/services/web/pkg/config/options.go index 8fbdf1d290..285e972d3f 100644 --- a/services/web/pkg/config/options.go +++ b/services/web/pkg/config/options.go @@ -26,8 +26,7 @@ type Options struct { AccessDeniedHelpURL string `json:"accessDeniedHelpUrl,omitempty" yaml:"accessDeniedHelpUrl" env:"WEB_OPTION_ACCESS_DENIED_HELP_URL" desc:"Specifies the target URL valid for the ocis instance for the generic logged out / access denied page."` TokenStorageLocal bool `json:"tokenStorageLocal" yaml:"tokenStorageLocal" env:"WEB_OPTION_TOKEN_STORAGE_LOCAL" desc:"Specifies whether the access token will be stored in the local storage when set to 'true' or in the session storage when set to 'false'. If stored in the local storage, login state will be persisted across multiple browser tabs, means no additional logins are required."` DisabledExtensions []string `json:"disabledExtensions,omitempty" yaml:"disabledExtensions" env:"WEB_OPTION_DISABLED_EXTENSIONS" desc:"A list to disable specific Web extensions identified by their ID. The ID can e.g. be taken from the 'index.ts' file of the web extension. Example: 'com.github.owncloud.web.files.search,com.github.owncloud.web.files.print'. See the Environment Variable Types description for more details."` - Mode string `json:"mode,omitempty" yaml:"mode" env:"WEB_OPTION_MODE" desc:"Defines the mode in which Web will be running. Currently, the only supported options are '' (empty) and 'embed'. With '' which is the default, Web will run as usual with all functionality enabled. 'embed' will enable a stripped down version of Web with reduced functionality used to integrate Web into other applications like via iFrame. See the text description for more details."` - EmbedTarget string `json:"embedTarget,omitempty" yaml:"embedTarget" env:"WEB_OPTION_EMBED_TARGET" desc:"Defines how Web is being integrated when running in 'embed' mode. Currently, the only supported options are '' (empty) and 'location'. With '' which is the default, Web will run regular as defined via the 'mode' config option. With 'location', Web will run embedded as location picker. Resource selection will be disabled and the selected resources array always includes the current folder as the only item. See the text description for more details."` + Embed *Embed `json:"embed,omitempty" yaml:"embed"` } // AccountEditLink are the AccountEditLink options @@ -73,3 +72,10 @@ type Editor struct { AutosaveEnabled bool `json:"autosaveEnabled,omitempty" yaml:"autosaveEnabled" env:"WEB_OPTION_EDITOR_AUTOSAVE_ENABLED" desc:"Specifies if the autosave for the editor apps is enabled."` AutosaveInterval int `json:"autosaveInterval,omitempty" yaml:"autosaveInterval" env:"WEB_OPTION_EDITOR_AUTOSAVE_INTERVAL" desc:"Specifies the time interval for the autosave of editor apps in seconds. Has no effect when WEB_OPTION_EDITOR_AUTOSAVE_ENABLED is set to 'false'."` } + +// Embed are the Embed options +type Embed struct { + Enabled string `json:"enabled,omitempty" yaml:"enabled" env:"WEB_OPTION_EMBED_ENABLED" desc:"Defines whether Web should be running in 'embed' mode. Setting this to 'true' will enable a stripped down version of Web with reduced functionality used to integrate Web into other applications like via iFrame. Setting it to 'false' or not setting it (default) will run Web as usual with all functionality enabled. See the text description for more details."` + Target string `json:"target,omitempty" yaml:"target" env:"WEB_OPTION_EMBED_TARGET" desc:"Defines how Web is being integrated when running in 'embed' mode. Currently, the only supported options are '' (empty) and 'location'. With '' which is the default, Web will run regular as defined via the 'embed.enabled' config option. With 'location', Web will run embedded as location picker. Resource selection will be disabled and the selected resources array always includes the current folder as the only item. See the text description for more details."` + MessagesOrigin string `json:"messagesOrigin,omitempty" yaml:"messagesOrigin" env:"WEB_OPTION_EMBED_MESSAGES_ORIGIN" desc:"Defines a URL under which Web can be integrated via iFrame in 'embed' mode. Note that setting this is mandatory when running Web in 'embed' mode. Use '*' as value to allow running the iFrame under any URL, although this is not recommended for security resons. See the text description for more details."` +}