From c9722c3d891aee799f99ff2db04f089a805e6c60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Pablo=20Villaf=C3=A1=C3=B1ez?= Date: Tue, 20 Jan 2026 14:54:56 +0100 Subject: [PATCH] fix: add configuration changes to work with brute force protection --- services/storage-publiclink/pkg/config/config.go | 11 +++++++++++ .../pkg/config/defaults/defaultconfig.go | 6 ++++++ services/storage-publiclink/pkg/revaconfig/config.go | 6 ++++++ 3 files changed, 23 insertions(+) diff --git a/services/storage-publiclink/pkg/config/config.go b/services/storage-publiclink/pkg/config/config.go index 23d8382786f..4c78432c1a8 100644 --- a/services/storage-publiclink/pkg/config/config.go +++ b/services/storage-publiclink/pkg/config/config.go @@ -19,6 +19,7 @@ type Config struct { TokenManager *TokenManager `yaml:"token_manager"` Reva *shared.Reva `yaml:"reva"` BruteForce BruteForce `yaml:"brute_force"` + Store Store `yaml:"store"` SkipUserGroupsInToken bool `yaml:"skip_user_groups_in_token" env:"STORAGE_PUBLICLINK_SKIP_USER_GROUPS_IN_TOKEN" desc:"Disables the loading of user's group memberships from the reva access token." introductionVersion:"pre5.0"` @@ -60,3 +61,13 @@ type BruteForce struct { TimeGap time.Duration `yaml:"time_gap" env:"STORAGE_PUBLICLINK_BRUTEFORCE_TIMEGAP" desc:"The duration of the time gap computed for the brute force protection." introductionVersion:"Curie"` MaxAttempts int `yaml:"max_attempts" env:"STORAGE_PUBLICLINK_BRUTEFORCE_MAXATTEMPTS" desc:"The maximum number of failed attempts allowed in the time gap defined in STORAGE_PUBLICLINK_BRUTEFORCE_TIMEGAP." introductionVersion:"Curie"` } + +// Store configures the store to use +type Store struct { + Store string `yaml:"store" env:"OCIS_PERSISTENT_STORE;STORAGE_PUBLICLINK_STORE_STORE" desc:"The type of the store. Supported values are: 'memory', 'nats-js-kv', 'redis-sentinel', 'noop'. See the text description for details." introductionVersion:"curie"` + Nodes []string `yaml:"nodes" env:"OCIS_PERSISTENT_STORE_NODES;STORAGE_PUBLICLINK_STORE_NODES" desc:"A list of nodes to access the configured store. This has no effect when 'memory' store is configured. Note that the behaviour how nodes are used is dependent on the library of the configured store. See the Environment Variable Types description for more details." introductionVersion:"curie"` + Database string `yaml:"database" env:"STORAGE_PUBLICLINK_STORE_DATABASE" desc:"The database name the configured store should use." introductionVersion:"curie"` + Table string `yaml:"table" env:"STORAGE_PUBLICLINK_STORE_TABLE" desc:"The database table the store should use." introductionVersion:"curie"` + AuthUsername string `yaml:"username" env:"OCIS_PERSISTENT_STORE_AUTH_USERNAME;STORAGE_PUBLICLINK_STORE_AUTH_USERNAME" desc:"The username to authenticate with the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"curie"` + AuthPassword string `yaml:"password" env:"OCIS_PERSISTENT_STORE_AUTH_PASSWORD;STORAGE_PUBLICLINK_STORE_AUTH_PASSWORD" desc:"The password to authenticate with the store. Only applies when store type 'nats-js-kv' is configured." introductionVersion:"curie"` +} diff --git a/services/storage-publiclink/pkg/config/defaults/defaultconfig.go b/services/storage-publiclink/pkg/config/defaults/defaultconfig.go index 36031d4f034..e1d7b19e2a7 100644 --- a/services/storage-publiclink/pkg/config/defaults/defaultconfig.go +++ b/services/storage-publiclink/pkg/config/defaults/defaultconfig.go @@ -41,6 +41,12 @@ func DefaultConfig() *config.Config { TimeGap: 1 * time.Hour, MaxAttempts: 5, }, + Store: config.Store{ + Store: "nats-js-kv", + Nodes: []string{"127.0.0.1:9233"}, + Database: "storage-publiclink", + Table: "brute-force-protection", + }, } } diff --git a/services/storage-publiclink/pkg/revaconfig/config.go b/services/storage-publiclink/pkg/revaconfig/config.go index 553ea165a3b..1464bacc320 100644 --- a/services/storage-publiclink/pkg/revaconfig/config.go +++ b/services/storage-publiclink/pkg/revaconfig/config.go @@ -40,6 +40,12 @@ func StoragePublicLinkConfigFromStruct(cfg *config.Config) map[string]interface{ "gateway_addr": cfg.Reva.Address, "brute_force_time_gap": cfg.BruteForce.TimeGap, "brute_force_max_attempts": cfg.BruteForce.MaxAttempts, + "store_type": cfg.Store.Store, + "store_nodes": cfg.Store.Nodes, + "store_database": cfg.Store.Database, + "store_table": cfg.Store.Table, + "store_username": cfg.Store.AuthUsername, + "store_password": cfg.Store.AuthPassword, }, }, },