fix: add configuration changes to work with brute force protection

This commit is contained in:
Juan Pablo Villafáñez committed 2026-01-23 12:05:18 +01:00
1 parent d3f328320a
commit c9722c3d89
3 files changed
+23

No files matched your search

@@ -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"`
}
@@ -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",
},
}
}
@@ -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,
},
},
},