Restrict concurrent password hashes (#5437)
* internal/auth/password: add resizable pool The resizable pool wraps the permit pool with a mutex to allow it to be resized at runtime. * internal/auth/password: add concurrency limit The default concurrency limit is 1, and it can be set using the SetHashingPermits function. * internal/cmd/config: allow configuring hashing limits The new concurrent_password_hash_workers configuration value can be used to loosen the constraints on the userpass auth method hashing operation. * internal/cmd: set password hashing constraints Sets the password hashing concurrency constraints on startup and config reload. * CHANGELOG: add notice about password concurrency limit
This commit is contained in:
1 parent
aad833fe09
commit
40cb9f5c9e
11 files changed
+457
-10
No files matched your search
@@ -495,6 +495,12 @@ func New(ctx context.Context, conf *Config) (*Controller, error) {
|
||||
event.WriteSysEvent(ctx, op, "unable to ensure worker auth roots exist, may be due to multiple controllers starting at once, continuing")
|
||||
}
|
||||
|
||||
if c.conf.RawConfig.Controller.ConcurrentPasswordHashWorkers > 0 {
|
||||
if err := password.SetHashingPermits(int(c.conf.RawConfig.Controller.ConcurrentPasswordHashWorkers)); err != nil {
|
||||
return nil, fmt.Errorf("unable to set number of concurrent password workers: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
if graphFactory != nil {
|
||||
boundVer := version.Get().VersionNumber()
|
||||
c.downstreamWorkers, err = graphFactory(ctx, "root", boundVer)
|
||||
|
||||
Reference in new issue
Block a user