[Feature] add new config to enforce public link password (#7547)
* add new config to enforce public link password * add api test
This commit is contained in:
@@ -138,6 +138,7 @@ type OCS struct {
|
||||
CacheWarmupDriver string `yaml:"cache_warmup_driver,omitempty"` // not supported by the oCIS product, therefore not part of docs
|
||||
CacheWarmupDrivers CacheWarmupDrivers `yaml:"cache_warmup_drivers,omitempty"` // not supported by the oCIS product, therefore not part of docs
|
||||
EnableDenials bool `yaml:"enable_denials" env:"FRONTEND_OCS_ENABLE_DENIALS" desc:"EXPERIMENTAL: enable the feature to deny access on folders."`
|
||||
PublicShareMustHavePassword bool `yaml:"public_sharing_share_must_have_password" env:"OCIS_SHARING_PUBLIC_SHARE_MUST_HAVE_PASSWORD;FRONTEND_OCS_PUBLIC_SHARE_MUST_HAVE_PASSWORD" desc:"Set this to true if you want to enforce passwords on all public shares."`
|
||||
WriteablePublicShareMustHavePassword bool `yaml:"public_sharing_writeableshare_must_have_password" env:"OCIS_SHARING_PUBLIC_WRITEABLE_SHARE_MUST_HAVE_PASSWORD;FRONTEND_OCS_PUBLIC_WRITEABLE_SHARE_MUST_HAVE_PASSWORD" desc:"Set this to true if you want to enforce passwords on Uploader, Editor or Contributor shares."`
|
||||
}
|
||||
|
||||
|
||||
@@ -51,5 +51,10 @@ func Validate(cfg *config.Config) error {
|
||||
cfg.GRPCClientTLS = structs.CopyOrZeroValue(cfg.Commons.GRPCClientTLS)
|
||||
}
|
||||
|
||||
// Set password enforcement on all public links when config is set
|
||||
if cfg.OCS.PublicShareMustHavePassword {
|
||||
cfg.OCS.WriteablePublicShareMustHavePassword = true
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ func FrontendConfigFromStruct(cfg *config.Config, logger log.Logger) (map[string
|
||||
"password": map[string]interface{}{
|
||||
"enforced": false,
|
||||
"enforced_for": map[string]interface{}{
|
||||
"read_only": false,
|
||||
"read_only": cfg.OCS.PublicShareMustHavePassword,
|
||||
"read_write": cfg.OCS.WriteablePublicShareMustHavePassword,
|
||||
"read_write_delete": cfg.OCS.WriteablePublicShareMustHavePassword,
|
||||
"upload_only": cfg.OCS.WriteablePublicShareMustHavePassword,
|
||||
|
||||
Reference in New Issue
Block a user