Manager: reduce password strength of Workers
The password check of worker API calls was 2 orders of magnitude slower than actually handling the API call itself. Since the Worker authentication is not that important (it's all on the same network anyway, and Worker account registration is automatic too), lowering the BCrypt cost to the minimum helps. On my machine, this reduces the time for password checks from 50 to 2 ms.
This commit is contained in:
parent
65427ee38e
commit
90be370095
@ -18,6 +18,10 @@ import (
|
|||||||
"git.blender.org/flamenco/pkg/api"
|
"git.blender.org/flamenco/pkg/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// The default BCrypt cost is made for important passwords. For Flamenco, the
|
||||||
|
// Worker password is not that important.
|
||||||
|
const bcryptCost = bcrypt.MinCost
|
||||||
|
|
||||||
// RegisterWorker registers a new worker and stores it in the database.
|
// RegisterWorker registers a new worker and stores it in the database.
|
||||||
func (f *Flamenco) RegisterWorker(e echo.Context) error {
|
func (f *Flamenco) RegisterWorker(e echo.Context) error {
|
||||||
logger := requestLogger(e)
|
logger := requestLogger(e)
|
||||||
@ -33,7 +37,7 @@ func (f *Flamenco) RegisterWorker(e echo.Context) error {
|
|||||||
|
|
||||||
logger.Info().Str("nickname", req.Nickname).Msg("registering new worker")
|
logger.Info().Str("nickname", req.Nickname).Msg("registering new worker")
|
||||||
|
|
||||||
hashedPassword, err := bcrypt.GenerateFromPassword([]byte(req.Secret), bcrypt.DefaultCost)
|
hashedPassword, err := bcrypt.GenerateFromPassword([]byte(req.Secret), bcryptCost)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Warn().Err(err).Msg("error hashing worker password")
|
logger.Warn().Err(err).Msg("error hashing worker password")
|
||||||
return sendAPIError(e, http.StatusBadRequest, "error hashing password")
|
return sendAPIError(e, http.StatusBadRequest, "error hashing password")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user