aboutsummaryrefslogtreecommitdiff
path: root/setup
diff options
context:
space:
mode:
authorKegsay <kegan@matrix.org>2021-03-08 13:19:02 +0000
committerGitHub <noreply@github.com>2021-03-08 13:19:02 +0000
commit850abb1dde2ce6f85554457e3ee94a9837e13897 (patch)
tree4b9068e9e4bca77ac1be1291c10fc53d8a704648 /setup
parentc3ad2cca49a7ad5890dddf2d8eec3e3cbbff16d1 (diff)
Make bcrypt cost configurable (#1793)
Diffstat (limited to 'setup')
-rw-r--r--setup/base.go2
-rw-r--r--setup/config/config_userapi.go6
2 files changed, 7 insertions, 1 deletions
diff --git a/setup/base.go b/setup/base.go
index e9aa2a45..4c50a6be 100644
--- a/setup/base.go
+++ b/setup/base.go
@@ -263,7 +263,7 @@ func (b *BaseDendrite) KeyServerHTTPClient() keyserverAPI.KeyInternalAPI {
// CreateAccountsDB creates a new instance of the accounts database. Should only
// be called once per component.
func (b *BaseDendrite) CreateAccountsDB() accounts.Database {
- db, err := accounts.NewDatabase(&b.Cfg.UserAPI.AccountDatabase, b.Cfg.Global.ServerName)
+ db, err := accounts.NewDatabase(&b.Cfg.UserAPI.AccountDatabase, b.Cfg.Global.ServerName, b.Cfg.UserAPI.BCryptCost)
if err != nil {
logrus.WithError(err).Panicf("failed to connect to accounts db")
}
diff --git a/setup/config/config_userapi.go b/setup/config/config_userapi.go
index 91b351d1..e6912384 100644
--- a/setup/config/config_userapi.go
+++ b/setup/config/config_userapi.go
@@ -1,10 +1,15 @@
package config
+import "golang.org/x/crypto/bcrypt"
+
type UserAPI struct {
Matrix *Global `yaml:"-"`
InternalAPI InternalAPIOptions `yaml:"internal_api"`
+ // The cost when hashing passwords.
+ BCryptCost int `yaml:"bcrypt_cost"`
+
// The Account database stores the login details and account information
// for local users. It is accessed by the UserAPI.
AccountDatabase DatabaseOptions `yaml:"account_database"`
@@ -20,6 +25,7 @@ func (c *UserAPI) Defaults() {
c.DeviceDatabase.Defaults(10)
c.AccountDatabase.ConnectionString = "file:userapi_accounts.db"
c.DeviceDatabase.ConnectionString = "file:userapi_devices.db"
+ c.BCryptCost = bcrypt.DefaultCost
}
func (c *UserAPI) Verify(configErrs *ConfigErrors, isMonolith bool) {